CHUGENS, CHUBGRAPHS, CHUGINS: 3 TIERS FOR tick function, which accepts a single floating-point 1::second => delay.delay; EXTENDING CHUCK argument (the input sample) and returns a single }

floating-point value (the output sample). For example, (Chubgraphs that do not wish to process an input signal, this code uses a Chugen to synthesize a sinusoid using such as audio synthesizing algorithms, may omit the Spencer Salazar Ge Wang the cosine function: connection from inlet.) Center for Computer Research in Music and Acoustics Compared to Chugens, Chubgraphs have obvious class MyCosine extends Chugen performance advantages, as primary audio-rate Stanford University { {spencer, ge}@ccrma.stanford.edu 0 => int p; processing still occurs in the native machine code 440 => float f; underlying its component ugens. However Chubgraphs second/samp => float SRATE; are limited to audio algorithms that can be expressed as combinations of existing unit generators; implementing, ABSTRACT native compiled code, which is precisely the intent of fun float tick(float in) for example, intricate mathematical formulae or ChuGins. { The ChucK programming language lacks return Math.cos(p++*2*pi*f/SRATE); conditional logic in the form of a ugen graph is possible straightforward mechanisms for extension beyond its } but, in our experience, fraught with hazard. 2. RELATED WORK } built-in programming and processing facilities. Chugens address this issue by allowing programmers to live-code Extensibility is a primary concern of music of In the case of an audio that does not process 3.3. ChuGins new unit generators in ChucK in real-time. Chubgraphs all varieties. The popular audio programming an existing signal, the input sample may be ignored. also allow new unit generators to be built in ChucK, by environments /MSP [15], Pure Data [10], A Chugen defined so may be integrated into audio ChuGins (pronounced “chug-in”) allow near limitless SuperCollider [8], and [ ] all provide defining specific arrangements of existing unit 4 graphs like any standard ChucK ugen. Since the tick possibilities for expansion of ChucK’s capabilities. A generators. ChuGins allow a wide array of high- mechanisms for developing /C++-based compiled function is just a standard ChucK class member function, ChuGin is a distributable dynamic library, typically performance unit generators and general functionality to sound processing functions. Max also allows control-rate it can be as simple or as elaborate as required. Standard written in C or C++ compiled to native machine code, functionality to be encapsulated in-situ in the form of be exposed in ChucK by providing a dynamic binding library calls, file I/O, multiprocessing (using spork), and which ChucK can be instructed to load at runtime. When between ChucK and native C/C++-based compiled Javascript code snippets. Max’s Gen facility dynamically other general ChucK programming structures can be loaded, the ChuGin defines one or more classes that are compiles audio-rate processors, implemented as either code. Performance and code analysis shows that the integrated into the tick function and supporting code. subsequently available to ChucK programs. These most suitable approach for extending ChucK is data-flows or textual code, to native machine code. For performance reasons, its important to consider that classes may define new unit generators or provide Csound allows the execution of Tcl, Lua, and Python situation-dependent. the tick function will be called for every sample of general programmatic functionality beyond that built in code for control-rate and/or audio-rate manipulation and audio, so simple tick functions will typically perform to ChucK. Since these classes are normal ChucK classes 1. INTRODUCTION synthesis. The Impromptu environment supports live- better. Moreover, the intrinsic overhead of ChucK’s implemented with native code, member functions and coding of audio-rate processors in a Scheme-like variables can be used to provide an interface to control Since its introduction, the ChucK programming virtual machine architecture will cause Chugens to language [3], and LuaAV does the same for Lua [13]. parameters. language [14] has become a popular tool for computer underperform compared to a native C/C++ Pure allows programmers to dynamically write and ChuGins are best suited for audio algorithms that are music composers, educators, and application software implementation. Lastly, since Chugens are execute audio signal processors using Faust [5]. A reasonably well understood and stand to gain from the developers. However, to date, its catalogue of audio fundamentally a specialization of a ChucK class, it may thriving ecosystem revolves around extensions to performance of compiled machine code. The “write- processing unit generators and general programming define functions to provide structured access to popular digital audio workstation software, in the form compile-run” development cycle and C/C++-based functionality has been largely limited to those that are whichever parameters it wishes to expose to the of VST, RTAS, AudioUnits, and LADSPA plugins programming mandated by ChuGins makes built-in when the ChucK binary executable is compiled. programmer. developed primarily in C and C++. For general-purpose implementation of audio processors require Adding new unit generators mandates recompilation of computing, JNI provides a highly flexible binding comparatively more effort than the Chubgraph or 3.2. Chubgraphs the entirety of ChucK, requiring a level of expertise and between native machine code and the Java virtual Chugen approaches. However for ugens a programmer motivation reserved for an elite group of power-users. machine-based run-time environment [7]. RubyGems is intends to use over an extended period of time, the effort Furthermore, community-based development efforts are Chubgraphs (pronounced “chub-graph”) provide a way a complete plugin and package management tool for to construct new unit generators by composition, to implement a ChuGin will quickly pay off in the form hampered by this centralization of functionality, as both Ruby-based plugins and C/C++ libraries compiled of lower CPU usage. developers of new unit generators have no easy way to arranging multiple existing ugens into a single unit. In with Ruby bindings [11]. this way, common arrangements of existing unit An additional advantage of ChuGins is that they may share their work. generators can be defined and instantiated. Furthermore, provide functionality far outside the intrinsic The aim of the work described herein is to provide 3. CHUGENS, CHUBGRAPHS, CHUGINS Chubgraph parameters can be exposed in a structured capabilities of ChucK. Complex synthesis C/C++ based ChucK with multiple levels of extensibility, each manner via class member functions. synthesis packages can be imported wholesale into essential and appropriate to specific tasks and levels of ChucK, opening up an abundance of sonic possibilities. 3.1. Chugens A Chubgraph is defined by extending the Chubgraph user expertise. On the one hand, ChucK’s pervasive For example, ChuGins have been implemented to bring class. The Chubgraph class has member variables named ethos of on-the-fly development creates the desire to The goal of Chugens (pronounced “chyoo-jen”) is to audio processing programs from the Faust programming inlet and outlet; inlet is a ugen that represents the design and implement new audio processors in ChucK facilitate rapid prototyping of audio synthesis and language into ChucK. Similarly, the SoundFont renderer input signal to the Chubgraph, and outlet is the output itself in real-time, working down to the per-sample level processing algorithms. Additionally, Chugens provide a FluidSynth has been packaged as a ChuGin. This if necessary. Furthermore, implementing these signal. The Chubgraph’s internal audio processing graph basic framework for extending ChucK’s built-in audio is created by spanning a sequence of ugens between functionality is not limited to audio processing; a serial components in ChucK allows their use on any operating processing functionality. Using the Chugen system, a port input/output ChuGin is under development, as are inlet and outlet. The following Chubgraph system ChucK supports with no additional effort from programmer can implement sample-rate audio other general purpose programming libraries. the developer. For these cases we have developed implements a basic feedback echo processor: algorithms within the ChucK development environment, Development of a ChuGin is somewhat more complex Chugens and Chubgraphs. utilizing the full array of programming facilities than Chubgraphs or Chugens, and does not lend itself to On the other hand, real-time performance class Feedback extends Chubgraph provided by ChucK. These processing units can be { explicit presentation of code herein. Using a set of requirements often mandate the use of compiled native naturally integrated into standard ChucK programs, even inlet => Gain dry => outlet; convenience macros, a ChuGin developer first defines a machine code for complex audio-rate processing. There in the same script file, providing seamless control of dry => Delay delay => outlet; function, which ChucK calls upon first loading also exists a wealth of C/C++-based software libraries query audio-rate processing, control-rate manipulation, and delay => Gain feedback => delay; the ChuGin. ChucK provides the query function with for audio synthesis and effects, such as FluidSynth [4] higher-level compositional organization. routines with which to define unit generators and and Faust [9]. These situations can be straightforwardly A Chugen is created first by subclassing the built-in 0.8 => feedback.gain; classes, specify what member variables and functions handled given portable bindings between ChucK and Chugen class. This subclass is required to implement a _60 _61

CHUGENS, CHUBGRAPHS, CHUGINS: 3 TIERS FOR tick function, which accepts a single floating-point 1::second => delay.delay; EXTENDING CHUCK argument (the input sample) and returns a single }

floating-point value (the output sample). For example, (Chubgraphs that do not wish to process an input signal, this code uses a Chugen to synthesize a sinusoid using such as audio synthesizing algorithms, may omit the Spencer Salazar Ge Wang the cosine function: connection from inlet.) Center for Computer Research in Music and Acoustics Compared to Chugens, Chubgraphs have obvious class MyCosine extends Chugen performance advantages, as primary audio-rate Stanford University { {spencer, ge}@ccrma.stanford.edu 0 => int p; processing still occurs in the native machine code 440 => float f; underlying its component ugens. However Chubgraphs second/samp => float SRATE; are limited to audio algorithms that can be expressed as combinations of existing unit generators; implementing, ABSTRACT native compiled code, which is precisely the intent of fun float tick(float in) for example, intricate mathematical formulae or ChuGins. { The ChucK programming language lacks return Math.cos(p++*2*pi*f/SRATE); conditional logic in the form of a ugen graph is possible straightforward mechanisms for extension beyond its } but, in our experience, fraught with hazard. 2. RELATED WORK } built-in programming and processing facilities. Chugens address this issue by allowing programmers to live-code Extensibility is a primary concern of music software of In the case of an audio synthesizer that does not process 3.3. ChuGins new unit generators in ChucK in real-time. Chubgraphs all varieties. The popular audio programming an existing signal, the input sample may be ignored. also allow new unit generators to be built in ChucK, by environments Max/MSP [15], Pure Data [10], A Chugen defined so may be integrated into audio ChuGins (pronounced “chug-in”) allow near limitless SuperCollider [8], and Csound [ ] all provide defining specific arrangements of existing unit 4 graphs like any standard ChucK ugen. Since the tick possibilities for expansion of ChucK’s capabilities. A generators. ChuGins allow a wide array of high- mechanisms for developing C/C++-based compiled function is just a standard ChucK class member function, ChuGin is a distributable dynamic library, typically performance unit generators and general functionality to sound processing functions. Max also allows control-rate it can be as simple or as elaborate as required. Standard written in C or C++ compiled to native machine code, functionality to be encapsulated in-situ in the form of be exposed in ChucK by providing a dynamic binding library calls, file I/O, multiprocessing (using spork), and which ChucK can be instructed to load at runtime. When between ChucK and native C/C++-based compiled Javascript code snippets. Max’s Gen facility dynamically other general ChucK programming structures can be loaded, the ChuGin defines one or more classes that are compiles audio-rate processors, implemented as either code. Performance and code analysis shows that the integrated into the tick function and supporting code. subsequently available to ChucK programs. These most suitable approach for extending ChucK is data-flows or textual code, to native machine code. For performance reasons, its important to consider that classes may define new unit generators or provide Csound allows the execution of Tcl, Lua, and Python situation-dependent. the tick function will be called for every sample of general programmatic functionality beyond that built in code for control-rate and/or audio-rate manipulation and audio, so simple tick functions will typically perform to ChucK. Since these classes are normal ChucK classes 1. INTRODUCTION synthesis. The Impromptu environment supports live- better. Moreover, the intrinsic overhead of ChucK’s implemented with native code, member functions and coding of audio-rate processors in a Scheme-like variables can be used to provide an interface to control Since its introduction, the ChucK programming virtual machine architecture will cause Chugens to language [3], and LuaAV does the same for Lua [13]. parameters. language [14] has become a popular tool for computer underperform compared to a native C/C++ Pure allows programmers to dynamically write and ChuGins are best suited for audio algorithms that are music composers, educators, and application software implementation. Lastly, since Chugens are execute audio signal processors using Faust [5]. A reasonably well understood and stand to gain from the developers. However, to date, its catalogue of audio fundamentally a specialization of a ChucK class, it may thriving ecosystem revolves around extensions to performance of compiled machine code. The “write- processing unit generators and general programming define functions to provide structured access to popular digital audio workstation software, in the form compile-run” development cycle and C/C++-based functionality has been largely limited to those that are whichever parameters it wishes to expose to the of VST, RTAS, AudioUnits, and LADSPA plugins programming mandated by ChuGins makes built-in when the ChucK binary executable is compiled. programmer. developed primarily in C and C++. For general-purpose implementation of audio processors require Adding new unit generators mandates recompilation of computing, JNI provides a highly flexible binding comparatively more effort than the Chubgraph or 3.2. Chubgraphs the entirety of ChucK, requiring a level of expertise and between native machine code and the Java virtual Chugen approaches. However for ugens a programmer motivation reserved for an elite group of power-users. machine-based run-time environment [7]. RubyGems is intends to use over an extended period of time, the effort Furthermore, community-based development efforts are Chubgraphs (pronounced “chub-graph”) provide a way a complete plugin and package management tool for to construct new unit generators by composition, to implement a ChuGin will quickly pay off in the form hampered by this centralization of functionality, as both Ruby-based plugins and C/C++ libraries compiled of lower CPU usage. developers of new unit generators have no easy way to arranging multiple existing ugens into a single unit. In with Ruby bindings [11]. this way, common arrangements of existing unit An additional advantage of ChuGins is that they may share their work. generators can be defined and instantiated. Furthermore, provide functionality far outside the intrinsic The aim of the work described herein is to provide 3. CHUGENS, CHUBGRAPHS, CHUGINS Chubgraph parameters can be exposed in a structured capabilities of ChucK. Complex synthesis C/C++ based ChucK with multiple levels of extensibility, each manner via class member functions. synthesis packages can be imported wholesale into essential and appropriate to specific tasks and levels of ChucK, opening up an abundance of sonic possibilities. 3.1. Chugens A Chubgraph is defined by extending the Chubgraph user expertise. On the one hand, ChucK’s pervasive For example, ChuGins have been implemented to bring class. The Chubgraph class has member variables named ethos of on-the-fly development creates the desire to The goal of Chugens (pronounced “chyoo-jen”) is to audio processing programs from the Faust programming inlet and outlet; inlet is a ugen that represents the design and implement new audio processors in ChucK facilitate rapid prototyping of audio synthesis and language into ChucK. Similarly, the SoundFont renderer input signal to the Chubgraph, and outlet is the output itself in real-time, working down to the per-sample level processing algorithms. Additionally, Chugens provide a FluidSynth has been packaged as a ChuGin. This if necessary. Furthermore, implementing these signal. The Chubgraph’s internal audio processing graph basic framework for extending ChucK’s built-in audio is created by spanning a sequence of ugens between functionality is not limited to audio processing; a serial components in ChucK allows their use on any operating processing functionality. Using the Chugen system, a port input/output ChuGin is under development, as are inlet and outlet. The following Chubgraph system ChucK supports with no additional effort from programmer can implement sample-rate audio other general purpose programming libraries. the developer. For these cases we have developed implements a basic feedback echo processor: algorithms within the ChucK development environment, Development of a ChuGin is somewhat more complex Chugens and Chubgraphs. utilizing the full array of programming facilities than Chubgraphs or Chugens, and does not lend itself to On the other hand, real-time performance class Feedback extends Chubgraph provided by ChucK. These processing units can be { explicit presentation of code herein. Using a set of requirements often mandate the use of compiled native naturally integrated into standard ChucK programs, even inlet => Gain dry => outlet; convenience macros, a ChuGin developer first defines a machine code for complex audio-rate processing. There in the same script file, providing seamless control of dry => Delay delay => outlet; function, which ChucK calls upon first loading also exists a wealth of C/C++-based software libraries query audio-rate processing, control-rate manipulation, and delay => Gain feedback => delay; the ChuGin. ChucK provides the query function with for audio synthesis and effects, such as FluidSynth [4] higher-level compositional organization. routines with which to define unit generators and and Faust [9]. These situations can be straightforwardly A Chugen is created first by subclassing the built-in 0.8 => feedback.gain; classes, specify what member variables and functions handled given portable bindings between ChucK and Chugen class. This subclass is required to implement a _60 _61

are associated with these, and indicate a tick function } Chubgraphs are ill suited to tasks involving conditional [2] Cook, P., and Scavone, G. 1999. “STK: The in the case of unit generators. These functions are then As can be seen in Table 1, the ChuGin variant of logic and intricate non-linear arithmetic manipulation. Synthesis Toolkit.” In Proceedings of the defined in C/C++, using predefined macros for CombFilter performs best, but the Chubgraph version is Therefore, this algorithm would be ideal to develop and International Conference. interactions with the upper-level ChucK runtime, such not far behind. The Chugen version performs poorly as a prototype as a Chugen. If a computer musician finds him Beijing, China. as retrieving function arguments, getting and setting or herself using this Chugen often, or requires faster result of requiring execution of ChucK code at audio- [3] Brown, A. R. and Sorenson, A. 2007. member variables, and handling input/output samples. rate, and also requires more code than the Chubgraph, as execution time, reimplementation as a ChuGin would be This code is then compiled into a dynamic library using appropriate. "Dynamic Media Arts Programming in the delay line and moving average filter needed to be impromptu." In Proceedings of the 6th ACM the standard facilities for doing so on the target implemented from scratch. Given the vastly superior computing platform ( for Mac OS X and SIGCHI conference on Creativity & Cognition. gcc lines of code and aptness metrics, the Chubgraph is Bitcrusher Time (s) Lines of Code Aptness Washington, DC, USA. systems, Visual C++ for Windows systems). Additional probably the best approach to use in this case. Chugen 10.600 21 223 C/C++ code or libraries, such as STK, may be compiled Chubgraph excels here because CombFilter is essentially [4] FluidSynth. http://www.fluidsynth.org/. into the dynamic library using the mechanisms standard a particular arrangement of existing unit generator Chubgraph 6.544 41 268 Accessed February 11, 2012. for those operations on the target platform. Furthermore, primitives, i.e. Delay and OneZero, allowing a concise [5] Gräf, A. 2011. “Functional Faust DSP code can be automatically converted to and efficient implementation. A ChuGin may be more ChuGin 1.965 84 165 ChuGin form using FaucK, a Faust architecture file and with Pure and Faust Using the LLVM Toolkit.” appropriate if speed is the utmost concern, but its Table 2. Performance and complexity measurements for an accompanying compilation script. In Proceedings of the Sound and Music inferior code complexity makes it largely undesirable in Bitcrusher. Computing Conference. Padua, Italy. this class of audio processing algorithm. 4. PERFORMANCE CASE STUDIES 5. FUTURE WORK [6] Lazzarini, V. 2005. “Extensions to the Csound CombFilter Time (s) Lines of Code Aptness Language: from User- Defined to Plugin- Execution speed of audio software is typically a vital Further developments we are pursuing include metric for computer musicians, as real-time audio Opcodes and Beyond.” In Proceedings of the Chugen 10.944 18 197 mechanisms for creating general purpose programming Linux Audio Conference. Karlsruhe, Germany. synthesis requires timely production of tens of thousands libraries in ChucK. Additionally we are investigating a Chubgraph 2.841 9 26 of samples per second. To evaluate the performance of unified ChuGin repository and distribution system, [7] Liang, S. 1996. The Java Native Interface: our mechanisms for extending ChucK, we designed and ChuGin 2.001 65 130 similar to Debian APT [1] or RubyGems, to simplify the Programmers Guide and Specification. implemented several reference unit generators using task of finding and installing ChucK extensions. Addison-Wesley, Reading, MA. each method. For each method, we measured the time Table 1. Performance and complexity measurements for Our current system of importing ChuGins does not CombFilter. [8] McCartney, J. 2002. “Rethinking the Computer required to offline-render 5 minutes of audio using the scale well, as ChuGins cannot be loaded on demand. resulting unit generator. Music Language: SuperCollider,” Computer Rather, ChucK will load every ChuGin that is installed Music Journal, 26(4): 61-68. In many situations not only is CPU time at a premium, 4.2. Bitcrusher on a system, which may take a noticeable amount of but a programmer’s time to implement a specified time if there are many ChuGins present. In the future we [9] Orlarey, Y., Fober, D., and Letz, S. 2009. This audio processor performs sample rate reduction by application is also limited. Therefore, often “less wish to more intelligently load ChuGins only when their “Faust: an Efficient Functional Approach to decimation and destructive sample-width compression complex” programs are more desirable than “more component ugens and classes are invoked by active DSP Programming,” New Computational to recreate its input at a specific sample rate and sample complex” programs because they can be developed ChucK code. Paradigms for Computer Music. Edition width. The result typically sounds as if it was faster and be better understood by other programmers. Chugens generate audio by executing ChucK virtual Delatour, France. synthesized by vintage, low-resolution audio or video While quantifying code complexity is a nuanced and machine code at audio-rate; dynamically compiling game hardware such as the Casiotone family of [10] Puckette, M. S. 1997. "Pure data." In volatile field of inquiry, we have chosen to represent it in Chugens instead to native machine code may introduce consumer keyboards or the Nintendo Entertainment Proceedings of the International Computer the form of lines of code required to implement the unit significant performance gains. Environments such as System. For reference, the shortest version, a Chugen, is Music Conference. Thessaloniki, Greece. generator using each method. In addition to LuaAV, Gen, and Pure do just this, compiling high-level listed here: characterizing code complexity, lines of code gives an programs to native code for audio-rate execution. [11] RubyGems. http://rubygems.org/. Accessed

approximation of much time the extension may have Additional improvements may be required in the form February 10, 2012. taken to develop. public class Bitcrusher extends Chugen of process and memory safety in ChuGins. Currently, { [12] Steiglitz, K. 1996. Digital Signal Processing To construct an overall picture of performance vs. ChuGins execute in the same process space as ChucK 8 => int bits; Primer. Addison-Wesley, Reading, MA. development effort, we have created a composite 4 => int downsample; itself, which means that buggy ChuGins can crash statistic formed by the product of these two metrics, float sample; ChucK outright. Technological approaches can alleviate [13] Wakefield, G., Smith, W., and Roberts, C. int count; named “aptness.” A lower aptness indicates that a these problems somewhat, but organizational solutions 2010. “LuaAV: Extensibility and particular technique is more appropriate for a particular Math.pow(2,31) => float fINT_MAX; may also be desirable, such as having registries of Heterogeneity for Audiovisual Computing.” In processing application than a technique with a higher fun float tick(float in) vetted and thoroughly tested ChuGins. Proceedings of the Linux Audio Conference. aptness. { if(count++ % downsample == 0) Utrecht, the Netherlands. 6. ACKNOWLEDGEMENTS Math.min(1,Math.max(-1,in))=> sample; [14] Wang, G. 2008. The ChucK Audio 4.1. CombFilter (sample * fINT_MAX) $ int => int q32; Special thanks to Kassen Oud, Casper Schipper, Jorge Programming Language: A Strongly-timed, For this case study we implemented a simple comb 32-bits => int shift; Herrera, and Hongchan Choi for their invaluable beta On-the-fly Environ/mentality. PhD Thesis. filter, the “plucked string filter” described in [12]. For ((q32 >> shift) << shift) => q32; testing, bug finding, and feature requesting. Additional Princeton University. support for this research was made possible by a reference, the comparatively concise Chubgraph version return q32 / fINT_MAX; National Science Foundation Creative IT Grant, No. IIS- [15] Zicarelli, D. 1998. “An Extensible Real-Time is as follows: } Signal Processing Environment for MAX.” In } 0855758. Proceedings of the International Computer public class CombFilter extends Chubgraph The results in Table 2 once again show the ChuGin as Music Conference. Ann Arbor, MI. { 7. REFERENCES inlet => Delay d => outlet; the performance leader. Chugen is the most concise, and, d => OneZero oz => d; unsurprisingly, the poorest performing contender. [1] Apt. http://wiki.debian.org/Apt. Accessed Chubgraph performs better than Chugen, but much -1 => oz.zero; February 10, 2012. 100::samp => d.delay; worse than ChuGin, and is far more complex in this 0.75 => oz.gain; case. The built-in unit generators at the disposal of _62 _63

are associated with these, and indicate a tick function } Chubgraphs are ill suited to tasks involving conditional [2] Cook, P., and Scavone, G. 1999. “STK: The in the case of unit generators. These functions are then As can be seen in Table 1, the ChuGin variant of logic and intricate non-linear arithmetic manipulation. Synthesis Toolkit.” In Proceedings of the defined in C/C++, using predefined macros for CombFilter performs best, but the Chubgraph version is Therefore, this algorithm would be ideal to develop and International Computer Music Conference. interactions with the upper-level ChucK runtime, such not far behind. The Chugen version performs poorly as a prototype as a Chugen. If a computer musician finds him Beijing, China. as retrieving function arguments, getting and setting or herself using this Chugen often, or requires faster result of requiring execution of ChucK code at audio- [3] Brown, A. R. and Sorenson, A. 2007. member variables, and handling input/output samples. rate, and also requires more code than the Chubgraph, as execution time, reimplementation as a ChuGin would be This code is then compiled into a dynamic library using appropriate. "Dynamic Media Arts Programming in the delay line and moving average filter needed to be impromptu." In Proceedings of the 6th ACM the standard facilities for doing so on the target implemented from scratch. Given the vastly superior computing platform ( for Mac OS X and Linux SIGCHI conference on Creativity & Cognition. gcc lines of code and aptness metrics, the Chubgraph is Bitcrusher Time (s) Lines of Code Aptness Washington, DC, USA. systems, Visual C++ for Windows systems). Additional probably the best approach to use in this case. Chugen 10.600 21 223 C/C++ code or libraries, such as STK, may be compiled Chubgraph excels here because CombFilter is essentially [4] FluidSynth. http://www.fluidsynth.org/. into the dynamic library using the mechanisms standard a particular arrangement of existing unit generator Chubgraph 6.544 41 268 Accessed February 11, 2012. for those operations on the target platform. Furthermore, primitives, i.e. Delay and OneZero, allowing a concise [5] Gräf, A. 2011. “Functional Signal Processing Faust DSP code can be automatically converted to and efficient implementation. A ChuGin may be more ChuGin 1.965 84 165 ChuGin form using FaucK, a Faust architecture file and with Pure and Faust Using the LLVM Toolkit.” appropriate if speed is the utmost concern, but its Table 2. Performance and complexity measurements for an accompanying compilation script. In Proceedings of the Sound and Music inferior code complexity makes it largely undesirable in Bitcrusher. Computing Conference. Padua, Italy. this class of audio processing algorithm. 4. PERFORMANCE CASE STUDIES 5. FUTURE WORK [6] Lazzarini, V. 2005. “Extensions to the Csound CombFilter Time (s) Lines of Code Aptness Language: from User- Defined to Plugin- Execution speed of audio software is typically a vital Further developments we are pursuing include metric for computer musicians, as real-time audio Opcodes and Beyond.” In Proceedings of the Chugen 10.944 18 197 mechanisms for creating general purpose programming Linux Audio Conference. Karlsruhe, Germany. synthesis requires timely production of tens of thousands libraries in ChucK. Additionally we are investigating a Chubgraph 2.841 9 26 of samples per second. To evaluate the performance of unified ChuGin repository and distribution system, [7] Liang, S. 1996. The Java Native Interface: our mechanisms for extending ChucK, we designed and ChuGin 2.001 65 130 similar to Debian APT [1] or RubyGems, to simplify the Programmers Guide and Specification. implemented several reference unit generators using task of finding and installing ChucK extensions. Addison-Wesley, Reading, MA. each method. For each method, we measured the time Table 1. Performance and complexity measurements for Our current system of importing ChuGins does not CombFilter. [8] McCartney, J. 2002. “Rethinking the Computer required to offline-render 5 minutes of audio using the scale well, as ChuGins cannot be loaded on demand. resulting unit generator. Music Language: SuperCollider,” Computer Rather, ChucK will load every ChuGin that is installed Music Journal, 26(4): 61-68. In many situations not only is CPU time at a premium, 4.2. Bitcrusher on a system, which may take a noticeable amount of but a programmer’s time to implement a specified time if there are many ChuGins present. In the future we [9] Orlarey, Y., Fober, D., and Letz, S. 2009. This audio processor performs sample rate reduction by application is also limited. Therefore, often “less wish to more intelligently load ChuGins only when their “Faust: an Efficient Functional Approach to decimation and destructive sample-width compression complex” programs are more desirable than “more component ugens and classes are invoked by active DSP Programming,” New Computational to recreate its input at a specific sample rate and sample complex” programs because they can be developed ChucK code. Paradigms for Computer Music. Edition width. The result typically sounds as if it was faster and be better understood by other programmers. Chugens generate audio by executing ChucK virtual Delatour, France. synthesized by vintage, low-resolution audio or video While quantifying code complexity is a nuanced and machine code at audio-rate; dynamically compiling game hardware such as the Casiotone family of [10] Puckette, M. S. 1997. "Pure data." In volatile field of inquiry, we have chosen to represent it in Chugens instead to native machine code may introduce consumer keyboards or the Nintendo Entertainment Proceedings of the International Computer the form of lines of code required to implement the unit significant performance gains. Environments such as System. For reference, the shortest version, a Chugen, is Music Conference. Thessaloniki, Greece. generator using each method. In addition to LuaAV, Gen, and Pure do just this, compiling high-level listed here: characterizing code complexity, lines of code gives an programs to native code for audio-rate execution. [11] RubyGems. http://rubygems.org/. Accessed

approximation of much time the extension may have Additional improvements may be required in the form February 10, 2012. taken to develop. public class Bitcrusher extends Chugen of process and memory safety in ChuGins. Currently, { [12] Steiglitz, K. 1996. Digital Signal Processing To construct an overall picture of performance vs. ChuGins execute in the same process space as ChucK 8 => int bits; Primer. Addison-Wesley, Reading, MA. development effort, we have created a composite 4 => int downsample; itself, which means that buggy ChuGins can crash statistic formed by the product of these two metrics, float sample; ChucK outright. Technological approaches can alleviate [13] Wakefield, G., Smith, W., and Roberts, C. int count; named “aptness.” A lower aptness indicates that a these problems somewhat, but organizational solutions 2010. “LuaAV: Extensibility and particular technique is more appropriate for a particular Math.pow(2,31) => float fINT_MAX; may also be desirable, such as having registries of Heterogeneity for Audiovisual Computing.” In processing application than a technique with a higher fun float tick(float in) vetted and thoroughly tested ChuGins. Proceedings of the Linux Audio Conference. aptness. { if(count++ % downsample == 0) Utrecht, the Netherlands. 6. ACKNOWLEDGEMENTS Math.min(1,Math.max(-1,in))=> sample; [14] Wang, G. 2008. The ChucK Audio 4.1. CombFilter (sample * fINT_MAX) $ int => int q32; Special thanks to Kassen Oud, Casper Schipper, Jorge Programming Language: A Strongly-timed, For this case study we implemented a simple comb 32-bits => int shift; Herrera, and Hongchan Choi for their invaluable beta On-the-fly Environ/mentality. PhD Thesis. filter, the “plucked string filter” described in [12]. For ((q32 >> shift) << shift) => q32; testing, bug finding, and feature requesting. Additional Princeton University. support for this research was made possible by a reference, the comparatively concise Chubgraph version return q32 / fINT_MAX; National Science Foundation Creative IT Grant, No. IIS- [15] Zicarelli, D. 1998. “An Extensible Real-Time is as follows: } Signal Processing Environment for MAX.” In } 0855758. Proceedings of the International Computer public class CombFilter extends Chubgraph The results in Table 2 once again show the ChuGin as Music Conference. Ann Arbor, MI. { 7. REFERENCES inlet => Delay d => outlet; the performance leader. Chugen is the most concise, and, d => OneZero oz => d; unsurprisingly, the poorest performing contender. [1] Apt. http://wiki.debian.org/Apt. Accessed Chubgraph performs better than Chugen, but much -1 => oz.zero; February 10, 2012. 100::samp => d.delay; worse than ChuGin, and is far more complex in this 0.75 => oz.gain; case. The built-in unit generators at the disposal of _62 _63