Emulating a Combo Organ Using Faust Sampo SAVOLAINEN Foo-plugins http://foo-plugins.googlecode.com/ [email protected] Abstract nents. ThismakesforagoodtestofFaust’sper- formance and parallelization capabilities. Ac- This paper describes the working principles of a 40 cess to an operational organ was also a factor in yearoldtransistororganandhowitisemulatedwith software. The emulation presented in this paper is the choice, as it makes it possible to match the open source and written in a functional language emulation quality against the original. called Faust. The architecture of the organ proved The contents of this paper is organized into to be challenging for Faust. The process of writing four sections. The first section covers how the thisemulationhighlightedsomeofFaust’sstrengths real organ operates. This is followed by a de- and helped identify ways to improve the language. scription of how the organ is emulated. The third section covers the performance aspects of Keywords the emulation. The last section offers analysis Faust, synthesis, emulation of Faust’s strengths and gives proposals on how to improve the language. 1 Introduction 2 YC-20 Faust[Yann Orlarey, 2009b] stands for Func- tional AUdio STream and as the name implies This section covers the operations of the or- it is a functional language designed for audio gan in detail[Yamaha, 1969]. The informa- processing. The Faust compiler is an intermedi- tion in this is section is later referred to and ary compiler, which produces source code for a detailed further when discussing the emulated C++ signal processor class which is integrated parts. Figure 1 shows a block diagram of the into a chosen C++ architecture. This archi- device. tecture file provides a run-time environment, or wrapper, for the processor. This wrapper can 2.1 Features be for example a stand-alone Linux Jack appli- Theorganhasonephysicalmanualwith61keys cation or an audio processing plug-in. with a switchable 17 key bass manual and two This paper describes how an emulation of a voice sections. Instead of drawbars like Ham- 1970’s combo-organ was written in Faust. The mondorgans,thevoicesarecontrolledbyalever Yamaha YC-20 is a fairly typical organ of its system used in Yamaha organs of the time. As time, a transistor based relatively light instru- the word drawbar is commonplace when dis- ment meant for musicians on the road. The cussing organ voicing, the word is used in place organ is a divide-down design and its working of lever for the voice controls. While the con- principles are discussed in detail in section 2. trols are potentiometers, they have notches to The emulation is released as open source under help the user achieve repeatable settings. Each the GNU General Public License (v3). In the drawbar lever in the organ has four positions spiritofopensource,theworkingprinciplesand (end stops and two notches) from off to full vol- decisionstakenduringwritingtheemulationare ume. described in this paper for all to read. Section I has drawbars 16’, 8’, 4’, 2-2/3’, 2’, The YC-20 was chosen to be emulated as its 1-3/5’ and 1’ and section II has drawbars 16’, architecture is very different from typical soft- 8’, 4’, 2’ and a continuous brightness lever. The ware and virtual analog synthesizers. Instead sectionscanbeselectedormixedtogetherusing of the complex controllability and routability of a continuous balance lever. Enabling the bass typical synthesizers, this organ requires a large manual switches the lowest 17 keys (white on number of fixed parallel processes and compo- black) to bass section sounds with drawbars 16’ 2.3 Sections The drawbar controls are potentiometers which control how much of each bus bar is mixed to each section of the organ. While in section I, drawbars are simply mixed together using resis- tors, SectionIIdrawbarshavemorecomplexfil- tering. Each section II drawbar is divided into two streams, each filtered separately with RC networks. One stream is low pass filtered while the other is high pass filtered. The low passed and high passed signals are mixed through re- sistors to combine into bright and dull signals which are then buffered. The brightness poten- tiometer controls a mix of the two which, after further buffering, is the output of section II. The key switches on the lowest 17 keys feed separatebassbusbars. Thebassmanualswitch controls whether these bus bars are kept sepa- rate or mixed with the main bus bars. Thus, with the bass feature disabled, the bass keys work exactly as the rest of the manual. With the switch enabled, the bass bus bars are sepa- rate and only feed the bass section. It is worth notingthatwhenenabledthebasssectioneffec- Figure 1: Block diagram of the YC-20 tivelydiscardsthesignalofbassbusbars2-2/3’, 2’, 1-3/5’ and 1’. and 8’. There are controls for pitch, overall vol- Bass section differs from the two main sec- ume, bass volume, vibrato depth, vibrato speed tions in that both bass manual drawbars (16’ and an obscure ”touch vibrato” feature. The and 8’) use a mix of multiple bass bus bars. organ also has a single percussion drawbar and The16’drawbarisamixofbassbusbars16’, 8’ an integrated volume pedal. Like the drawbars, and 4’. The bus bars are mixed through differ- all vibrato controls have four notches. ent value resistors. 16’ has the least resistance and 4’ the highest resistance. The 8’ drawbar 2.2 Tone generation is a mix of the 8’ bass bus bar with lower re- Thesynthesizerarchitecturecomprisesof12os- sistance and 4’ bass bus bar with higher resis- cillators, one per each note in a twelve-tone tance. While section I and section II drawbar equal temperament (12-TET) scale. Each os- control potentiometers are wired in a standard cillator produces a sawtooth wave. For each volume configuration, the bass manual drawbar oscillator, there are 7 frequency divider stages controls are wired center-tap to source with the so each oscillator produces 8 voices totalling 96 other tip grounded and the other tip as the out- voices. The dividers produce square waves. put. Thisconfigurationmakesthedrawbarcon- These voices are next fed through a passive trol not only affect how much of the drawbar is filter bank. The divided voices have both a mixed in, but it also varies the impedance of high pass and low pass filters while the oscilla- the signal source. The different mixing resistors tor voices are only high pass filtered to remove and the varying impedance of the drawbar con- bias. This totals 180 resistor-capacitor (RC) trols,combinedwithafixedcapacitortoground filter networks. Filtered voices are connected (after summing the drawbar signals) makes the to switches on the actual keys of the keyboard. network act as a fairly complex RC filter. This The keyboard is thus in fact a matrix mixer filterhasavaryingcutoffpointandmixamount connecting the voices to bus bars. A key feeds per bass bus bar. each bus bar with the appropriate voice match- 2.4 Percussion ing that key and octave, or the matching har- monic voice in case of the 2-2/3’ and 1-3/5’ bus Percussion manual sounds are created by mix- bars. ingtogetherbusbars1’,2-2/3’and16’viaresis- tors. There is a substantially larger resistance the organ with, as Faust’s functional semantics on the 1’ bus bar leading to less 1’ voices in fit well with having all processing running at all the percussion section. The volume of this sig- times. Faustalsomakesittrivialtohavealarge naliscontrolledbyasimpleenvelopegenerator. amount of streams flowing from one circuit to This envelope generator is triggered by activity another. This emulation was also intended as a on the 1’ bus bar. The envelope attack is in- test of Faust in a real world use. stantaneous and the release time is fast while 3.2 Tone generation the sustain level is zero. This causes a fast at- tack sound, but the effect only works when no The 12 main oscillators produce sawtooth keys are pressed down before. In other words, waves. Theyshareacommon,varyingbiasvolt- the percussion effect is not heard, for example, age (see section 3.3) which affects the oscillator when playing legato. However there is a sub- frequencies. The main oscillator voices are di- stantial amount of bleed from the percussion vided by an array of flip flop circuits each di- section which is audible when all other draw- viding the frequency in half and the next one bars are off. dividing the previously divided voice. The flip If the bass manual is enabled, it disengages flops produce square wave signals. This means the bass bus bars from the main bus bars. Thus each oscillator produces a total of 8 phase- the bass keys will not mix sounds onto the 1’ synchronized voices, each one an octave down bus bar. Therefore playing the bass manual from the previous voice. will not trigger the percussion and percussion As the main oscillator frequencies are high soundswilltriggerevenwhenbasskeysareheld (4–8kHz), a naive oscillator implementation down. would suffer massively from aliasing when us- ing typical sampling rates (44.1–96kHz). Nat- 2.5 Main output urally, also the dividers would suffer from The main output of the device is a mix of sec- aliasing as well. After evaluating differ- tions I and II, the percussion part and the bass ent methods to band-limit the signals, the manual. The mix between sections I and II is PolyBLEP1[V¨alim¨aki and Huovilainen, 2007] controlled by the balance lever (a potentiome- method was chosen. While BLEP[Brandt, ter). The amount of percussion mixed in is con- 2001] would produce less aliasing components, trolledbythepercussiondrawbar. Bassmanual it is computationally more expensive. More is summed into the main output via a poten- importantly, the BLEP step function is cur- tiometercontrollingthebassvolume. Thiscom- rently impossible to calculate in Faust as it re- binedsignalisthenpreamplified. Thepreampli- quiresusingFourierandinverseFouriertransfer fied output can then be attenuated by the main functions. The quality of BLIT-SWS2[Stilson, volumepotentiometerofthedeviceandthevol- 1996] is good at high frequencies, but it pro- ume pedal. The volume pedal action controls a duces aliasing components below the funda- mechanical shutter between a small light bulb mental frequency[V¨alim¨aki and Huovilainen, and a light dependent resistor. 2007]. Also, BLIT-SWS is problematic when it comes to band-limiting hard synchronized os- 3 The emulation cillators[Brandt, 2001] which is one strategy to Theemphasiswasoncreatingaplayableinstru- emulate the divider circuits. ment which sounds like the original organ. A Second, third, and fourth order polynomial playable emulation needs to be able to work at residual functions were evaluated for the Poly- low latencies and it needs to be efficient enough BLEP. The higher order residual functions re- to be ran on commodity hardware. The emula- ducedhighfrequencyaliasingonlyslightlymore tion tries not only to emulate the ideal circuit compared to the second order function. Fur- but also some of the inaccuracies in the real in- thermore a band-limited signal using the sec- strument. ondorderfunctionhasconsiderablylessaliasing 3.1 Why Faust? components below the fundamental frequency when compared to the third and fourth or- Instead of taking an approach where sounds are synthesized only when needed, this emulation 1BLEP = band-limited step function. PolyBLEP keeps all oscillators, dividers and filters running uses a step function derived from a simple polynomial allthetime–justliketherealorgan. Faustwas 2BLIT = band-limited impulse train, SWS refers to chosenastheprogramminglanguagetoemulate the use of windowed sinc functions der functions. This confirmed previous find- Frequency (A) (B) (C) ings[Pekonen, 2007]. The chosen second order 5kHz 352 800 44 100 10 000 polynomial residual function r(t) is shown as 1kHz 352 800 44 100 2 000 equation 1. 500Hz 352 800 44 100 1 000 Table 1: Amount of PolyBLEP calculations per (cid:40) t2/2+t+1/2, if −1 ≤ t ≤ 0 second for a square wave at Fs = 44.1kHz. r(t) = (1) (A) an implementation where per each frame −t2/2+t−1/2, if 0 < t ≤ 1 the PolyBLEP is evaluated for both the pre- vious and current sample for both discontinu- Thedividercircuitsareemulatedasslavedos- ities. The branched nature of the residual func- cillators. The main oscillator function outputs tion multiplies this number further by a factor both the signal and phase information. One di- of two. (B) an ideal implementation without visor function divides the phase and feeds this branching where only one PolyBLEP is evalu- to a slave oscillator. The slave again produces ated per frame. (C) is the number of required both a signal and phase information. The com- PolyBLEP calculations. plete divider circuit for one oscillator is seven such divisor functions piggybacked. PolyBLEP works by adding the polynomial to ground after the series capacitor. This al- band-limited step function to two samples: the ters the next stage impedance compared to the sample before and after a discontinuity in the other filters. signal. To achieve this, the implementation de- Filtering is very complex to emulate exactly lays its output by one sample. At each frame, right, as one voice might be connected to mul- thephaseisinspected. Ifthephasepassedadis- tiple bus bars. This varies the high-pass filter continuityinthewaveform,thePolyBLEPfunc- load resistance and therefore affects the filter tion is evaluated for and added (rising wave) or cutoff frequency depending on what keys are subtracted (falling wave) for the previous sam- depressed. This is not emulated. Instead, the ple and the current sample. As Faust lacks high-pass filter load is estimated based on the true branches, all possible branches of condi- expectationthat there is only oneconnection to tional statements are always calculated. Table a bus bar. 1 shows the amount of residual function evalu- ations required under different conditions. The 3.3 Oscillator bias table shows that branching would be far supe- Each oscillator produces a saw wave at a differ- rior to any non-branching solution. This is be- ent frequency. The frequencies are chosen from cause without branching the amount of Poly- a 12-TET scale. However all oscillators share BLEP evaluations done is purely a function of a single bias voltage affecting their frequency. the sampling rate while the amount of required This bias voltage is controlled by the vibrato evaluationsisafunctionofthesignalfrequency. circuit, touch vibrato and the master pitch po- To be able to run the emulation in real time, tentiometer. The master pitch potentiometer is a truly branching solution had to be developed emulated by a simple slider widget with a DC asanexternalC++function. Thiswashowever output. Touch vibrato would be controlled by easy to integrate with the Faust processing as horizontalmovementofthekeys. AssuchMIDI theffunction operatorletsoneuseexternalsjust keyboards are extremely rare3 this feature was as native functions. left out of the emulation. The filter bank contains tailored filtering for Vibrato control voltage is created by a simple eachofthe96voicesproducedbytheoscillators sine wave oscillator. The vibrato speed controls and dividers. The main oscillators only have a the speed of this oscillator. The vibrato speed single capacitor in series. This is emulated as range (5-8Hz) was measured from the real de- a high-pass RC filter using an approximation vice. The vibrato depth is simply an attenu- of the next stage impedance as the load resis- ation control for the vibrato oscillator output. tor value. The first four divided signals have a Vibrato depth range was empirically selected. trivial RC low-pass filter before a single capac- The depth control deliberately never goes to itor in series similar to the the main oscillator filter. The lowest three voices are filtered like 3Only one keyboard was found claiming such capa- the previous four, except that there is a resistor bility: the Yamaha STAGEA ELS-01C. zero, thus the vibrato has a miniscule effect on the bias voltage even when turned down. 3.4 Keyboard matrix mixer The keyboard matrix mixing, while a relatively simplepart, containsmanyseparateoperations. Each key is a Faust button4 connecting multi- plevoicestodifferentbusbars. Thismeanseach key button is used as a multiplier for 7 differ- ent voices (one per bus bar). So the signals on the emulated bus bars are the outcome of 61∗7 = 427 discrete multiplications summed to appropriate busses. There is also added logic for the bass manual where the resulting down- mixes from the 17 bottom keys are fed to either the main bus bars or the bass bus bars. The matrix mixer could be written as sets Figure 2: Comparison between emulated and of floating point tables multiplied together. In real manual I drawbar 8’ sounds. Faust however, there are no such array opera- tors. This results in a number of separate mul- tiplications and sums which are difficult for the organ was measured while playing a stable note Faustcompilertooptimize,asvectoroperations with all drawbars off except one drawbar which areunusableifthedataisnotinorderedarrays. was tested in all three on positions. The off The key action is not band-limited. The key positionisexpectedtobe-inf. Comparedtofull switches on the real organ are simple switches volume,thetwomiddlepositionsweremeasured connecting voices to bus bars. This operation at -12dB and -18dB. causes clicks in the real organ as switches open This can be translated into a continuous and close. The naive non-band-limited key ac- transfer function (see equation 2). p is the posi- tion of the emulation matches the sound of the tion of the lever from 0 (off) to 1 (full volume). real organ surprisingly well. However, this is The function returns a gain coefficient usable in something that could be improved at a later the emulation. The function emulates the taper stage. and can be used with slider controls provided Writing the keyboard matrix mixer also re- by the Faust architecture. Further work on a vealed an issue with the service manual. The graphical user interface should provide four po- service manual indicates wrongly which voices sition levers. are connected to the harmonic bus bars (2-2/3’ and 1-3/5’). The manual states that 2-2/3’ is coeff(p) = 2.81p3−2.81p2+p connected to a voice five semitones higher than coeff(0) = −inf dB thevoiceconnectedto4’and1-3/5’withavoice eight semitones higher than 2’. The real organ coeff(1/3) ≈ −18.05 dB (2) connectsvoicessevenandthreesemitonesabove coeff(2/3) ≈ −12.03 dB respectively. The emulation follows the real or- coeff(1) = +0.00 dB gan instead of the service manual. Figure 2 shows C2 played on section I with 3.5 Section I only the 8’ drawbar engaged. The line depicts SectionIisamixofthemainbusbarsmixedto- the frequency spectrum of the emulation out- getherthroughthedrawbarpotentiometersand put. The crosses show peaks measured from a additional resistors. There is no extra filtering YC-20 organ using the same settings. applied to the signal. Thus the only part left to emulate for section I sounds is the drawbar 3.6 Section II controls. As described earlier in section 2.3, Section II Thedrawbarpotentiometersdonotfollowthe has a controllable brightness feature. The vari- typical linear or logarithmic tapers. The real able brightness is done by dividing each bus bar 4Button output signal is 1 when it is being pressed into two streams, one of which is high-passed down and otherwise 0. and the other low-passed. The streams derived from different bus bars are then mixed together into bright and dull streams. The brightness control is a simple balance control between the two streams. The high-pass filtering is done by a two stage RC filter with a resistor in parallel with the ca- pacitor of the first filter. Thus the filter is ef- fectively a shelving high pass filter. The shelf is emulated by calculating a voltage divider be- tweentheparallelresistorandtheresistorinthe RC high pass filter. The voltage divider gives a gain coefficient C which is used to mix together the high-passed and unfiltered signals. Unfil- teredsignalismultipliedbyC whilethefiltered is multiplied by 1-C and the results are added together. This keeps gain at high frequencies at 0dB as with the original passive filter. The two Figure 3: Comparison between emulated and passive filters also affect each other and could real bright section II drawbar 8’ sounds. not be emulated by simply chaining two digital filters. The load applied by two filter stages is envelope is then used to control the volume of emulated by dividing the resistance of the sec- a mix of the 1’, 2-2/3’ and 16’ bus bars. Some ond filter by two. This doubles the cutoff fre- bleed is added to the envelope generator out- quency of the filter. This method was found by put to emulate the bleed exhibited by the real trial and error. Figure 4 shows the block dia- organ. gram of the complete filter. The low-pass stage is much more straightfor- 3.8 Bass manual ward. Filtering consists of two chained RC low- Emulating the bass section perfectly is a com- pass filters. However, the best match with the plex task due to how mixing resistors and the original organ was achieved by not compensat- variable impedances of the potentiometers af- ing for load posed by the chained filters. This fect the RC filter. Measurements from the real filter stage is emulated by two digital RC low organ however suggest that the low frequency pass filters in series. fundamentals dominate the signal and an ac- Figure 3 shows C2 played on a fully bright ceptable emulation is achieved by carefully con- section II with only the 8’ drawbar engaged. trolling the mix of the bass bus bars and by This measurement was done at the same overall using a single fixed RC low-pass filter. This one levelasmeasurementsinfigure2. Themeasure- filter is applied to a mix of both bass drawbars. ment shows a slight overall volume difference and that the section II high-pass filters are not 4 Performance perfect. However, while harmonics for this par- Running this emulation requires a substantial ticularsounddonotlineupexactly,thebalance amount of processing power. There are 96 os- between harmonics is good enough. The har- cillators working all of the time and there are monics of many other notes (for example C3) hundreds of filters being applied at many stages line up perfectly. of the design. Faust is designed to easily har- ness multiple processing units in parallel. The 3.7 Percussion designoftheemulationhasalotofpotentialfor The percussion uses the signal on the 1’ bus parallelization and as such, it should work as a bar to trigger an envelope generator. There good real world test for Faust’s SMP features. is a root-mean-square envelope follower on the The performance numbers shown here are 1’ bus bar and the envelope is triggered when measured using a modified version of the Faust the follower exceeds a set threshold. The enve- benchmarking suite. These numbers are es- lope generator starts off with a signal where a timates of achieved memory bandwidth in one frame unit impulse is created at the trigger megabytes of audio data generated per second. point. Thisimpulsesignalislow-passfilteredto The Faust benchmark uses this measurement, match the measured percussion envelope. This asmemorybandwidthonSMPsystemsisapre- cious commodity. In the case of the YC-20, the a jack application. The measurements shown processing creates much more data than what in table 3 were done by running the emulation comesoutofitssinglemonooutput. Thusthese compiled with different flags and observing the figures can only be compared to each other. DSP percentage meter in qjackctl. This meter Tests were done on a Dell D820 laptop with tells how much of the time between jack engine a Core 2 Duo T7400 (2.16GHz) processor using callbacks is spent doing processing inside jack theinternalsoundinterface. Theoperatingsys- clients. tem was 32 bit Ubuntu 9.10. The processor fre- Tests Faust flags Load quency governor was switched to performance on both cores before running the tests. The scalar none ∼ 49% kernel was a standard Ubuntu package, 2.6.31- vectorized -vec -vs 32 ∼ 34% 19-generic and the used gcc version was 4.4.1- scheduler -sch -g -vs 256 ∼ 29% 4ubuntu9. Benchmarks were done on YC-20 Table 3: All tests were compiled with the fol- code revision 2275. Figures in column C are lowing gcc flags: from a slightly modified version of the YC-20 -O3-march=native-mfpmath=sse-msse-msse2 code and it shows the performance impact of -msse3 -ffast-math -ftree-vectorize. non-branching PolyBLEP calculations. The re- Jack 1 was running real-time with a dummy sults in MB/s are shown in table 2. back-end simulating a 48kHz sample rate with Faust benchmark (A) (B) (C) 512 frame buffers. scalar (galsascal) 0.40 0.43 0.28 vectorized (galsavec) 0.58 0.59 0.35 vectorized 2 (galsavec2) 0.62 0.62 0.34 5 Conclusions OpenMP (galsomp2) 0.51 0.55 0.29 The software presented in this paper emulates scheduler (galsasch) 0.90 0.88 N/A the YC-20 organ well. While some parts of scheduler 2 (galsasch2) 0.93 0.89 N/A the emulation could benefit from more polish, Table 2: The tests were ran with different sets other parts of the emulation can sound very of gcc parameters: much like a real YC-20. A better quality anti- (A) Branching C++ PolyBLEP evaluations. aliasing method could be beneficial, although gcc -O3 -march=native -mfpmath=sse -msse these methods would come at the expense of -msse2 -msse3 -ffast-math -ftree-vectorize CPU cycles. The real organ has considerable (B) Branching C++ PolyBLEP evaluations. bleed and inconsistencies which might also be gcc -O3 -march=native -mfpmath=sse -msse worth emulating. -msse2 -msse3 -ffast-math -ftree-vectorize 5.1 How to improve Faust -fgcse-sm -funsafe-math-optimizations (C) Divider slave oscillators use non-branched As discussed in section 3.2, and shown in the PolyBLEP operations. gcc -O3 -march=native benchmarks in section 4, there is a strong case -mfpmath=sse -msse -msse2 -msse3 -ffast-math foratrulybranchingselectoperation. However, -ftree-vectorize -fgcse-sm -funsafe-math- the semantics of Faust requires all of the pro- optimizations cessing graph to be evaluated for every frame. GCC was unable to compile the scheduler Truly branching operations would cause some versions of the emulation with non-branching function evaluations to be skipped. The op- PolyBLEP operations. erating semantics are however compatible with branching operations if the skipped functions are stateless. This is because if the function has no state, the next evaluation of the func- The multi-threaded scheduler tests were no- tion does not depend on previous evaluations. tably faster than other benchmarks. There is There are two ways truly branching opera- an increase of 50% in memory bandwidth when tionscouldbeaddedtoFaust: eitherselect2and comparedtovectorizedsinglethreadtests. This select3 calls with no stateful function branches data is backed by tests done by measuring the are compiled automatically as truly branching performanceoftheYC-20emulationrunningas or a new branching select call is created. Both 5Subversion repository available at http://foo- cases require the specification of rules on what plugins.googlecode.com/svn/trunk/ a stateless function is. Also, the compiler must check whether the functions being skipped over 96 inputs of the keyboard mixer and the but- comply to these specifications before allowing tons representing the keys of the organ could compilation of such code. be arranged into arrays, the mixing could be This logic could also be generalized to multi- done algorithmically using the aggregate func- plication functions. Function f(x) in equation tionssuchassumandvectormultiply. Suchop- 3 is an example of a function where evaluating erations also open up ways to further optimize t2(x) can be skipped if x ≤ 0 as t1(x) evaluates the created C++ code. As it stands, the key- to 0 for x ≤ 0 and t2 is stateless. board mixing is compiled into a large amount of separate discrete multiplication and addition operations which can not be vectorized. t1(x) = (x > 0) The Faust code shown as equation 4 is am- t2(x) = x2−fmod(x,1.0) (3) biguous,butcanbecompiledwithoutanywarn- f(x) = t1(x)∗t2(x) ing. Thiscanleadtoanywherefromunexpected results to complete failure. It would be good Thecompilererrormessagesareoftenunhelp- form for the Faust compiler to at least warn the ful. Theydonotalwaysspecifyinwhichfilethe user of the situation. compilationerroroccurred. Optimallythecom- piler should identify the file name, line number and if possible, the name of the function the f(x,y) = x+y (4) error occurred in. One specific issue with the with{x = y∗y;}; compilermessagesisworthgivingspecialatten- tion to. It is cases where the number of inputs 5.2 Benefits of Faust and outputs of functions in a sequential compo- Functional thinking suits audio applications sition do not match. In such cases, instead of very well as solutions to problems can often printing the names of the offending functions, be expressed as mathematical equations. This Faust outputs a quite exhaustive description of model sidesteps many of the issues procedural both functions. For example, if the YC-20 emu- programs face, as the processes can be written lation would fail to cut the phase output of the atahigherabstractionlevel. Unlikewithproce- last divider (dividers would then output a total dural languages, Faust allows signal processing of108insteadof96streams),theresultingerror programmers to not worry about buffers, their message is 67 kilobytes. lengths or loop structures or real-time thread For signal processing, the lack of support for constraints. This also saves time for the pro- Fourier transforms restricts what problems can grammer as less time is spent debugging issues be solved. As mentioned in section 3.2, the bet- not directly connected with the signal process- ter band-limiting method (BLEP) is not possi- ing task at hand. ble to implement in pure Faust. Fourier trans- Faustcodeiseasytokeepreadableasthesyn- forms would naturally be useful for a variety of tax offers tools, such as sequential composition, other tasks as well. Fortunately there has been which help keep functions simple and concise. promising news of multi-rate support for Faust See listings 1, 2 and 3 for an example. While which would allow processing such as Fourier listing2isprettycompact, oneshouldnotethat transforms. functions are presented to the reader in reverse As procedural programming is the prevailing orderanditisalsodifficulttoseetowhichfunc- model of programming, it is safe to say many tion return value the multiplication is applied potential users of Faust are familiar with only to. thatmodel. Thisappliespressuretothequality of documentation. The current documentation float dostuff(float f) { should abbreviate the definitions of the more f = func1(f); f = func2(f); advanced features of the language. Especially f = f ∗ 2.5; recursion and the rdtable and rwtable functions f = func3(f); could benefit from better explanations. Cur- return f; rently the features are almost side-stepped and } almost nothing but their syntax is described. Listing 1: Consecutive calls Implementingthematrixmixerrequiredalot of hand-crafting. Having a concept of index- float dostuff(float f) { able arrays would help such operations. If the return func3( func2( func1(f)) ∗ 2.5 ); refactor the modules to match. Faust proces- sors naturally fit with each other. This model works very well with open source as it makes it easier to spread good ideas and implementa- tions. It might even lead to a resource library of truly reusable components usable with any Faust project – as long as the licenses are com- patible. Faust also provides automatic parallelization and vectorization. This allows all Faust pro- grams to benefit from these advanced optimiza- tion methods which usually require expert pro- gramming skills to implement. These capabil- ities have been discussed in detail by Orlarey, Fober and Letz[Yann Orlarey, 2009a]. Faust also allows the developer to easily test and compare different optimization methods with- out refactoring their code. 6 Acknowledgements Thanks to Petri Junno for support and all the help with analyzing the original organ. I would also like to thank Sakari Bergen, Torben Hohn and Yann Orlarey for providing advice. Thanks also to Fons Adriaensen for Japa which was an excellent tool for comparing the emulation to the real organ. References EliBrandt. 2001. Hardsyncwithoutaliasing. In Proceedings of the International Computer Music Conference (ICMC), Havana, Cuba, September. Figure 4: Faust SVG output of section II high pass filtering for a single drawbar. The param- Jussi Pekonen. 2007. Computationally effi- eters for the filters are resistance in ohms and cient music synthesis – methods and sound capacitance in microfarads. design. Master’s thesis, TKK Helsinki Uni- versity of Technology. } TimStilson. 1996. Alias-freedigitalsynthesis of classic analog waveforms. Listing 2: Enclosed statements Vesa V¨alim¨aki and Antti Huovilainen. 2007. dostuff = func1 : func2 : ∗(2.5) : func3; Antialiasing oscillators in subtractive syn- Listing 3: Faust sequential composition thesis. Signal Processing Magazine, IEEE, 24(2):116–125. The SVG output of the Faust compiler is Yamaha, 1969. YC-20 Service Manual. alsoworthmentioning. Thecompilercancreate Yamaha Corporation. hyper-linked SVG documents which depict the process function. This document can be an ex- Stephane Letz Yann Orlarey, Do- cellent learning and debugging tool as it shows minique Fober. 2009a. Adding automatic how the compiler understood the source code. parallelization to faust. In Grame, editor, Figure 4 shows an example of this output. Linux Audio Conference 2009. Thestreamconceptalsomakescodereusable. Stephane Letz Yann Orlarey, Do- When combining procedural code from multi- minique Fober. 2009b. FAUST : an Efficient ple sources you often need to either convert Functional Approach to DSP Programming. data types between the different modules or