HYBRIDIZING the FAUST and CHUCK AUDIO PROGRAMMING LANGUAGES Ge Wang, Romain Michon
Total Page:16
File Type:pdf, Size:1020Kb
FAUCK!! HYBRIDIZING THE FAUST AND CHUCK AUDIO PROGRAMMING LANGUAGES Ge Wang, Romain Michon To cite this version: Ge Wang, Romain Michon. FAUCK!! HYBRIDIZING THE FAUST AND CHUCK AUDIO PRO- GRAMMING LANGUAGES. Sound and Music Computing Conference (SMC-16), Aug 2016, Ham- burg, Germany. pp.310-313. hal-03162895 HAL Id: hal-03162895 https://hal.archives-ouvertes.fr/hal-03162895 Submitted on 8 Mar 2021 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. FAUCK!! HYBRIDIZING THE FAUST AND CHUCK AUDIO PROGRAMMING LANGUAGES Ge Wang Romain Michon CCRMA, Stanford University CCRMA, Stanford University [email protected] [email protected] ABSTRACT two things are already similar?). Might their profound dif- ferences give rise to something different from either alone? This paper presents a hybrid audio programming environ- Such curiosities provide the primary motivation for our ex- ment, called FAUCK, which combines the powerful, suc- ploration in hybridizing FAUST and CHUCK. cinct Functional AUdio STream (FAUST) language with the strongly-timed CHUCK audio programming language. dynamically FAUCK allows programmers to on-the-fly evaluate FAUST evaluates, runs code directly from CHUCK code and control FAUST sig- nal processors using CHUCK’s sample-precise timing and FAUST on-the-fly ChucK code rapid code concurrency mechanisms. The goal is to create an amal- iteration gam that plays to the strengths of each language, giving rise to new possibilities for rapid prototyping, interaction design and controller mapping, pedagogy, and new ways controls of working with both FAUST and CHUCK. We present our motivations, approach, implementation, and preliminary Figure 1. New FAUCK model. evaluation. FAUCK is open-source and freely available. FAUCK is a tight integration between FAUST and CHUCK that attempts to infuse their respective characteristics, re- 1. INTRODUCTION inforcing and even augmenting each language with aspects A variety of computer music programming languages exist of the other (Figure1). It is designed such that program- for the same reason there are many different types of tools: mers can embed and evaluate FAUST code directly from each is well-suited to different types of tasks, and speaks within a CHUCK program, take full advantage of CHUCK’s to different aesthetic and pragmatic preferences of the pro- sample-synchronous time-based control and concurrency, grammer. FAUST and CHUCK are two audio program- and do all of this on-the-fly. At the same time, this makes ming languages that effectively illustrate this point. FAUST available to CHUCK the entire existing body of FAUST (Functional AUdio STream) [1–4] embraces a declarative programs, ready to be used for synthesis and interaction and functional paradigm, is succinct, tailored to expres- design. In combination, FAUCK provides a different hy- sively describe low-level digital signal processing (DSP) bridized way to rapidly prototype sample-precise audio syn- algorithm, and generates optimized, efficient synthesis mod- thesis code in FAUST and control it precisely using CHUCK. ules. CHUCK, [5,6], on the other hand, is imperative, de- signed around a notion of temporal determinism that in- 2. RELATED WORK cludes sample-synchronous timing and concurrency (called strongly-timed), tailored for precise control, readability, and 2.1 Existing Paradigm an on-the-fly rapid-prototyping mentality [7]. Yet, they Thanks to its architecture system [8], FAUST can be used to share the general goal of sound synthesis for musical appli- easily build custom DSP modules that generate or process cations and both are text-based languages (e.g., not graph- samples as part of a larger host. The traditional paradigm ical patching). of incorporating FAUST into computer music systems in- What happens when one combines these two languages? volves a pipeline that 1) generates C++ code from FAUST More to the point, can these languages be combined in such code, 2) compiles into a plug-in, and 3) runs as part of a a way to take advantage of the respective strengths of both? host software system 1 (e.g., PureData 2 , Max/MSP 3 , Su- Furthermore, that the two languages seem vastly different perCollider 4 , etc.). In this regime, there is a new plug-in in syntax, semantics, and personality is all the more rea- created from any given FAUST program (Figure2). Such a son to explore their intersections (i.e., why try to combine system currently exists for compiling a given FAUST pro- gram into a CHUCK chug-in [9]. Copyright: c 2016 Ge Wang et al. This is an open-access article distributed 1 http://faust.grame.fr/Documentation/ contains an under the terms of the Creative Commons Attribution 3.0 Unported License, which exhaustive list of the FAUST architectures. 2 https://puredata.info/. permits unrestricted use, distribution, and reproduction in any medium, provided 3 https://cycling74.com/products/max/. the original author and source are credited. 4 http://supercollider.github.io/. effect.lib, math.lib) are, by default, automatically FAUST C++ Plug-in Host imported by FAUCK. Furthermore, note the use of the back- program code tick (‘) to delineate the inline FAUST code – this removes the need to manually escape single and double quotation marks used in the FAUST code. Figure 2. Traditional FAUST code to plug-in model. Alternately, the same object can load a FAUST program from the file system by invoking compile and providing 2.2 Dynamic FAUST Extensions a path to a FAUST .dsp file: Modules created using the technique described in §2.1 are foo.compile("osc.dsp"); static and cannot be modified once they are compiled. libfaustNext, the v method can be called at anytime to change the 5 [10] which is part of the FAUST2 distribution allows to value of a specific parameter defined on the FAUST object embed the FAUST compiler in any program written in C++ that is specified by its path (v stands for "value"; we chose to dynamically generate DSP modules on the fly (see §4). this abbreviation in anticipation that most program will in- Since its introduction in 2012 libfaust has been used voke this method often). For example, here we create a in various projects to integrate the FAUST compiler to ex- sine wave oscillator whose only parameter is its frequency isting platforms or to create new one. The FAUST back- (freq) and we set it to 440Hz: end [11] of the Pure programming language [12] that pre- dates the creation of libfaust was used as the basis for foo.eval(‘ frequency = nentry("freq", the design of this tool. 200,50,1000,0.01); libfaust was used for the first time in PureData within process = osc(frequency); a dynamic external that can be turned into any DSP ob- ‘); ject by modifying the FAUST code linked to it [13]. Simi- foo.v("freq",440); larly faustgen [14] is a dynamic MaxMSP external bor- Finally, the dump method can be called at any time to rowing the paradigm used in gen [15] to create custom print a list of the parameters of the FAUST object as well as unit generators. CSound 6 now hosts a dynamic opcode their current value. This is useful to observe large FAUST functioning the same way than the two previous exam- programs that have a large number of parameters in com- ples [16]. libfaust has also been used under different plex grouping paths. Programmers can also directly copy forms within the Web Audio API [17] to create custom dy- the path of any parameter to control for use with the v namic nodes [18, 19]. More recently, FAUST has been in- method. tegrated to the JUCE 7 platform [20] and the Processing 8 programming language. 3.2 Examples Finally, libfaust is at the core of the FAUSTLIVE "just in time" FAUST compiler [21] allowing to write FAUST 3.2.1 A Simple Example code in a text file and generating the corresponding stan- dalone audio application almost instantly. The following example puts together the different elements given in §3.1 by implementing a simple sine wave oscil- lator (specified in FAUST) whose frequency and gain are 3. THE FAUCK APPROACH randomly changed every 100ms (controlled in CHUCK). 3.1 Using FAUCK // connect a Faust object to ChucK dac FAUST objects can be used easily in any CHUCK code Faust foo => dac; Faust // evaluate through a chugin called . For example, a new FAUST foo.eval(‘ unit generator (e.g., an audio DSP effect that takes an input frequency = nentry("freq", from CHUCK) can be declared as follow: 200,50,1000,0.01) : smooth(0.999); gain = nentry("gain", adc => Faust foo => dac; 1,0,1,0.01) : smooth(0.999); In the case where foo would be a synthesizer, the adc process = osc(frequency)*gain; ‘); would be ignored and we could simply write: // ChucK time loop Faust foo => dac; while( true ){ // control frequency Any FAUST program can be associated with foo and dy- foo.v("frequency", Math.random2f(50,800)); namically evaluated by calling the eval method. // control gain foo.v("gain", Math.random2f(0,1)); foo.eval(‘process=osc(440);‘); // advance time For brevity and convenience, several common libraries 100::ms => now; } (music.lib, filter.lib, oscillator.lib, 5 https://sourceforge.net/p/faudiostream/code/ ci/faust2/tree/. 3.2.2 An Advanced Example 6 http://www.csounds.com/.