Untiteled Jan Jacob Hofmann ; ******************************************************************************************************************************* ; Version 0.56 , Feb 2nd 2012 coded 1999-2012 by Jan Jacob Hofmann ; jjh@sonicarchitecture.de +++ http://www.sonicarchitecture.de ; Comments and suggestions welcome. ; For non-comercial, artistic, scientific and educational use only - all rights reserved ; ******************************************************************************************************************************* ; This is a sequence of instruments for periphonic spatialisation of any sound input using the 2nd order Ambisonics ; and the Furse- Malham set of equations. It was conceived and coded 1999-2005 by Jan Jacob Hofmann. ; The Instrument is able to spatialize up to 20 soundsources simultaneously (this can be enhanced). To each ; source a trajectory is assigned, so independent movement of the sounds is possible. ; Besides assigning a position in space via Ambisonics, several distance clues are coded separately to enhance ; the perception of distance and depth. These are: lowpassfiltering according to distance, attenuation ; according to distance, ratio of global and local reverb, ratio of reverberated and direct sound, first 6 specular ; early reflections with position and energy of reflections changing according to the position of the sound in space, ; first 6 diffuse early reflections with position and energy of reflections changing according to the position of the sound in space. ; The early reflections also do increase the transparency of the perceived image. Also Doppler Frequency Shift is ; applied to the source. ; Remember that distribution of the sound works best with multi- speaker arrays. You do definitely need more than ; two speakers, this is not binauralisation, which would work with headphones and only two channels. Minimum for panphony ; is 4 speakers, although 5 are recomended. For periphony the minimum is an eight speakers cube, but twelve speakers ; are highly recomended. The speakers have to be same type, in-phase, and at the exact geometric location for which the decoding ; was made for. ; Setting up the test ; To get a quick overview please use the soundfile "test1" (e.g. Dr. Boulangers Speech) ; and put them into the "Sound Sample Directory". Now make 7 copies of the file "Test1" and ; name them "test2" through "test8". They represent your audio tracks to be fed into the "Soundfile Reader". Then set the number ; of decoding- channels ("nchnls ") to "2" for stereo listening . ; make sure that you specify for every track a continouus trajectory in Instr. 42/46 ; Now render. If you have chosen more speakers than two, it is important to pass the generated encoded files to the decoder (see "Ambidec.orc") ; and decode according to your listening conditions (stereo? eight speakers? sixteen?). it shoud generate files that ; can be read by your sound editor. Import them into your editor and assign the channels to the speakers according to the position ; of the speaker. See "Ambidec.orc" for correct assignment. Now play the soundfiles simultaneously, each feeding one speaker. ; How to use this orchestra ; This orchestra works in several steps: ; - First a trajectory is generated (xyz is converted to angle, elevation and distance automatically by instr. 42) ; - Optional: trajectory may be modulated (instr 47 +48) ; - the soundfile is read, Doppler shift is applied (instr 50) ; - Local reverb is generated (instr 60) ; - The sound is spatially encoded, local reverb is added to the sound (instr 72) ; - Global reverb is added ; - Early reflections are added (instr 74+75) ; - Sound is collected and written to disk (instr 80) ; You may read up to 16 tracks into the orchestra simultaneously. The name of the track has to be specified in instr 50. ; To each track you have to generate a trajectory by using either Cartesian coordinates (instr. 40) or polar co-ordinates (instr 46). ; You may divide up the total time of the soundfile for several trajectories and positions in space, but these must sum up at the end to ; an equivalent to the total duration of the track processed. There must be neither overlaps nor gaps in the sequence of trajectories generated, ; one trajectory should follow the other. you may modulate any trajectory by any amount using the "Modulator" (instr. 47) or the ; Randomiser (instr. 48) This modulation may be used at any time. Also multiple instances of this modulations are possible to generate ; complex movements in space automatically by the sum of the modulating waveforms. Instr. 50 is the soundfile reader, you can specify the ; duration and track -number of the soundfile to be processed. This Instrument also triggers the local reverb and the first reflections (Instr. 74 and 75) ; adjust the parameters to taste. ; Instr. 73 is the Global Spatial Reverb. Reverberation occurs from 12 different positions in space, equaly distributed at the unit-sphere. It also ; triggers the output (Instr. 80), so make sure it is running all the time. ; Instr 74 and 75 do add specular and diffuse early reflections, also spatially distributed to each track independently. To save computing ; time these instruments should be activated only for the final rendering. ; Note: The output soundfiles may distort. You can scale them by dividing 32768 by the highest peak of them and put the result into ; "girescale", close to the header. ; ************************************************************************************** ; Please send comments and bug reports to jjh@sonicarchitecture.de on http://www.sonicarchitecture.de you will also find a small Ambisonic-tutorial. ; More info: ; To find out more about Ambisonics, see ; http://www.ambisonic.net/ ; http://www.york.ac.uk/inst/mustech/3d_audio/ambison.htm (University of York) ; http://www.york.ac.uk/inst/mustech/3d_audio/ambison.htm (Richard Furse's pages) ; Credits: ; Thanks to Richard Furse and Dave Malham for the wonderful 2nd order equations. Also special thanks to Nora Bluhme, ; Ingo Herwig and Christoph Schuller for helping me with the math. Last not least thanks to all csounders who made this ; possible by their contribution of work and thoughts!!! 48000 10 2 48000 1 2 true false false false true true true false -3 -A false Name.aif true true true true false -3 -A false true 0 false Frozen SoundObject Player Instrument aChannel1, aChannel2, aChannel3, aChannel4, aChannel5, aChannel6, aChannel7, aChannel8 diskin p4, 1 outc aChannel1, aChannel2, aChannel3, aChannel4, aChannel5, aChannel6, aChannel7, aChannel8 Reverb SC israte = sr keffmix = <effmix> krvbdecay = <reverbdecay> kcutofffreq = <cuttofffreq> irandpchmod = <randompitchmodulation> ; INPUT OF CHANNELS ; read in signal to effect-position 1 asig inleta "aeff_1_in" ; input signal ; SIGNAL MODIFICATION aL, aR reverbsc asig, asig, krvbdecay, kcutofffreq, israte, irandpchmod, 1 ; generate effect aeff sum aL , aR ; sum channels aeff = aeff * keffmix + asig * ( 1 - keffmix) ; mix of direct / effect signal outleta "aeff_1_out", aeff reverbdecay 67 60 true 0.01 1.0 0.8909322 60 true 57 153 191 153 cuttofffreq 393 64 true 0.0 22000.0 18582.441 60 true 386 153 randompitchmodulation 223 94 1 50 effmix 62 228 true 0.0 1.0 0.1 0.4 200 true 62 268 Envelope Generator (sigmoid) ; FUNCTION TABLE READING ENVELOPE GENERATOR idur = p3 idurprolong = p4 idur = idur - idurprolong ; use original duration katt = <attack> * 0.01 ; attack [%] ienvfn = <envfn> ; envelope fn 1 of grain [e.g. 8 = sigmoid rising] ktrig init 1 cycle: ; start of (re)init pass iatt = i(katt) ; convert k- to i-rate if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" endif ktrig = 0 ; avoid repeating this every k-cycle ; ENVELOPE aenvndx linseg 0, idur * iatt, 1, idur - idur * iatt, 0 ; moving pointer for envelope fn rireturn ; end of (re)init pass aenv tablei aenvndx, ienvfn, 1 ; creating the sigmoid envelope outc aenv 25 484 envfn 98 196 8 50 98 226 attack 32 45 true 0.01 99.9 0.1 83.21001 400 true Envelope Generator ADSR (absolute time) ; ADSR ENVELOPE WITH ABSOLUTE TIME ienv = p4 katt = <attack> ; attack [s] kdec = <decay> ; decay [s] kslev = <sustain> ; sustain level [0-1] krel = <release> ; decay [s] ktrig init 1 cycle: ; start of (re)init pass iatt = i(katt) ; convert k- to i-rate idec = i(kdec) ; convert k- to i-rate islev = i(kslev) ; convert k- to i-rate irel = i(krel) ; convert k- to i-rate if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" ktrig = 0 ; avoid repeating this every k-cycle endif ; ENVELOPE aenv adsr iatt, idec, islev, irel ; creating the adsr envelope rireturn ; end of (re)init pass ; OUTPUT outc aenv ; output of EG 92 477 attack 92 31 true 0.01 10.0 1.0 2.01 400 true 181 477 decay 180 31 true 0.01 10.0 1.0 1.01 400 true 241 477 sustain 268 31 true 0.0 1.0 0.1 1.0 400 true 352 477 release 359 31 true 0.01 10.0 1.0 3.01 400 true Envelope Generator ADSR (relative time ; ADSR ENVELOPE WITH RELATIVE TIME idur = p3 idurprolong = p4 ; instrument duration katt = <attack> * 0.01 ; attack [%] kdec = <decay> * 0.01 ; decay [%] kslev = <sustain> ; sustain level [0-1] krel = <release> * 0.01 ; decay [%] idur = idur - idurprolong ; no extra instrument performance ktrig init 1 cycle: ; start of (re)init pass iatt = i(katt) ; convert k- to i-rate idec = i(kdec) ; convert k- to i-rate islev = i(kslev) ; convert k- to i-rate irel = i(krel) ; convert k- to i-rate ; ENVELOPE aenv adsr iatt * idur, idec * idur, islev, irel * idur ; creating the adsr envelope if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" ktrig = 0 ; avoid repeating this every k-cycle endif rireturn ; end of (re)init pass ; OUTPUT outc aenv 91 476 attack 93 31 true 0.01 99.0 1.0 10.01 400 true 181 477 decay 180 32 true 0.01 99.0 1.0 31.01 400 true 241 477 sustain 268 31 true 0.0 1.0 0.1 1.0 400 true 352 477 release 359 31 true 0.01 99.0 1.0 0.01 400 true Envelope Generator Expseg idur = p3 idurprolong = p4 idur = idur - idurprolong ; no extra instrument performance katt = <Attack> * 0.01 ; attack [percent of note duration] kdec = <Decay> * 0.01 ; decay [percent of note duration] krel = <Release> * 0.01 ; release [percent of note duration] ktrig init 1 cycle: ; start of (re)init pass aenv expseg .001, idur * i(katt), 1.001, idur * i(kdec), .001, idur - i(katt + kdec), .001 rireturn ; end of (re)init pass if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" ktrig = 0 ; avoid repeating this every k-cycle endif ; OUTPUT outc aenv ; output of EG Attack 84 96 true 0.0 100.0 0.1 0.0 300 false 48 449 265 452 Decay 301 96 true 0.0 100.0 0.1 0.0 300 false Envelope Generator Sweep idur = p3 ; duration ienvfn = abs(p4) ; envfn ifndir = p4 / ienvfn ; negative fn causes backwards reading ifnamp = p5 aenv oscil ifnamp, ifndir * (1/idur), ienvfn ; generation of envelope during note ; OUTPUT outc aenv ; output of EG Additive Synth (inharmonic) 0dbfs = 1 ; Written by Iain McCurdy, 2006 ; Modified for QuteCsound by Ren?, September 2010 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5 ktrig init 1 cyclestart: ;GUI kPartAmp_1 = <PartAmp_0> ; amplitude of partial kPartAmp_2 = <PartAmp_1> ; amplitude of partial kPartAmp_3 = <PartAmp_2> ; amplitude of partial kPartAmp_4 = <PartAmp_3> ; amplitude of partial kPartAmp_5 = <PartAmp_4> ; amplitude of partial kPartAmp_6 = <PartAmp_5> ; amplitude of partial kPartAmp_7 = <PartAmp_6> ; amplitude of partial kPartAmp_8 = <PartAmp_7> ; amplitude of partial kPartAmp_9 = <PartAmp_8> ; amplitude of partial kPartAmp_10 = <PartAmp_9> ; amplitude of partial kfund = <FundFreq> ; fundamental frequency kamp = <Amplitude> ; overall amplitude kratio_1 = <Ratio_0> ; ratio of the fundamental kratio_2 = <Ratio_1> ; ratio of the fundamental kratio_3 = <Ratio_2> ; ratio of the fundamental kratio_4 = <Ratio_3> ; ratio of the fundamental kratio_5 = <Ratio_4> ; ratio of the fundamental kratio_6 = <Ratio_5> ; ratio of the fundamental kratio_7 = <Ratio_6> ; ratio of the fundamental kratio_8 = <Ratio_7> ; ratio of the fundamental kratio_9 = <Ratio_8> ; ratio of the fundamental kratio_10 = <Ratio_9> ; ratio of the fundamental kampatt_1 = <Attack_0> * 0.01 ; attack [percent of note duration] kampatt_2 = <Attack_1> * 0.01 ; attack [percent of note duration] kampatt_3 = <Attack_2> * 0.01 ; attack [percent of note duration] kampatt_4 = <Attack_3> * 0.01 ; attack [percent of note duration] kampatt_5 = <Attack_4> * 0.01 ; attack [percent of note duration] kampatt_6 = <Attack_5> * 0.01 ; attack [percent of note duration] kampatt_7 = <Attack_6> * 0.01 ; attack [percent of note duration] kampatt_8 = <Attack_7> * 0.01 ; attack [percent of note duration] kampatt_9 = <Attack_8> * 0.01 ; attack [percent of note duration] kampatt_10 = <Attack_9> * 0.01 ; attack [percent of note duration] kampdec_1 = <Decay_0> * 0.01 ; decay [percent of note duration] kampdec_2 = <Decay_1> * 0.01 ; decay [percent of note duration] kampdec_3 = <Decay_2> * 0.01 ; decay [percent of note duration] kampdec_4 = <Decay_3> * 0.01 ; decay [percent of note duration] kampdec_5 = <Decay_4> * 0.01 ; decay [percent of note duration] kampdec_6 = <Decay_5> * 0.01 ; decay [percent of note duration] kampdec_7 = <Decay_6> * 0.01 ; decay [percent of note duration] kampdec_8 = <Decay_7> * 0.01 ; decay [percent of note duration] kampdec_9 = <Decay_8> * 0.01 ; decay [percent of note duration] kampdec_10 = <Decay_9> * 0.01 ; decay [percent of note duration] kamprel_1 = <Release_0> * 0.01 ; release [percent of note duration] kamprel_2 = <Release_1> * 0.01 ; release [percent of note duration] kamprel_3 = <Release_2> * 0.01 ; release [percent of note duration] kamprel_4 = <Release_3> * 0.01 ; release [percent of note duration] kamprel_5 = <Release_4> * 0.01 ; release [percent of note duration] kamprel_6 = <Release_5> * 0.01 ; release [percent of note duration] kamprel_7 = <Release_6> * 0.01 ; release [percent of note duration] kamprel_8 = <Release_7> * 0.01 ; release [percent of note duration] kamprel_9 = <Release_8> * 0.01 ; release [percent of note duration] kamprel_10 = <Release_9> * 0.01 ; release [percent of note duration] ;SYNTHESIS INSTRUMENT idur = p3 ; duration ifn = 1 ; function nr for the oscilator (sine) iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument idurprolong = p6 idur = idur - idurprolong ; no extra time in performance of this instrument kamp = kamp * iampdev ; apply deviation on this instrument kfund = kfund * ifreqdev ; apply deviation on this instrument printk 0.1, kfund iporttime = 0.05 ;PORTAMENTO TIME VARIABLE kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME kfund portk kfund, kporttime ;APPLY PORTAMENTO SMOOTHING kamp portk kamp, kporttime ;APPLY PORTAMENTO SMOOTHING ; endif ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) aenv_1 expsegr .001, idur * i(kampatt_1), 1.001, idur * i(kampdec_1), .001, idur * i(kamprel_1), .001 aenv_2 expsegr .001, idur * i(kampatt_2), 1.001, idur * i(kampdec_2), .001, idur * i(kamprel_2), .001 aenv_3 expsegr .001, idur * i(kampatt_3), 1.001, idur * i(kampdec_3), .001, idur * i(kamprel_3), .001 aenv_4 expsegr .001, idur * i(kampatt_4), 1.001, idur * i(kampdec_4), .001, idur * i(kamprel_4), .001 aenv_5 expsegr .001, idur * i(kampatt_5), 1.001, idur * i(kampdec_5), .001, idur * i(kamprel_5), .001 aenv_6 expsegr .001, idur * i(kampatt_6), 1.001, idur * i(kampdec_6), .001, idur * i(kamprel_6), .001 aenv_7 expsegr .001, idur * i(kampatt_7), 1.001, idur * i(kampdec_7), .001, idur * i(kamprel_7), .001 aenv_8 expsegr .001, idur * i(kampatt_8), 1.001, idur * i(kampdec_8), .001, idur * i(kamprel_8), .001 aenv_9 expsegr .001, idur * i(kampatt_9), 1.001, idur * i(kampdec_9), .001, idur * i(kamprel_9), .001 aenv_10 expsegr .001, idur * i(kampatt_10), 1.001, idur * i(kampdec_10),.001, idur * i(kamprel_10), .001 ;SEPARATE OSCILLATORS CREATE EACH OF THE PARTIALS (NOTE THAT FLTK VERTICAL SLIDERS ARE INVERTED TO ALLOW MINIMUM VALUES TO BE LOWEST ON THE SCREEN) ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE apart_1 oscili kamp * (aenv_1 - 0.001) * kPartAmp_1, kfund * kratio_1, ifn apart_2 oscili kamp * (aenv_2 - 0.001) * kPartAmp_2, kfund * kratio_2, ifn apart_3 oscili kamp * (aenv_3 - 0.001) * kPartAmp_3, kfund * kratio_3, ifn apart_4 oscili kamp * (aenv_4 - 0.001) * kPartAmp_4, kfund * kratio_4, ifn apart_5 oscili kamp * (aenv_5 - 0.001) * kPartAmp_5, kfund * kratio_5, ifn apart_6 oscili kamp * (aenv_6 - 0.001) * kPartAmp_6, kfund * kratio_6, ifn apart_7 oscili kamp * (aenv_7 - 0.001) * kPartAmp_7, kfund * kratio_7, ifn apart_8 oscili kamp * (aenv_8 - 0.001) * kPartAmp_8, kfund * kratio_8, ifn apart_9 oscili kamp * (aenv_9 - 0.001) * kPartAmp_9, kfund * kratio_9, ifn apart_10 oscili kamp * (aenv_10 - 0.001) * kPartAmp_10, kfund * kratio_10, ifn if ktrig == 1 then ; at first k-cycle ... ktrig = 0 ; avoid repeating this every k-cycle reinit cyclestart ; ... and reinit "cyclestart" endif rireturn ; end of (re)init pass ;SUM THE 10 OSCILLATORS: amix sum apart_1, apart_2, apart_3, apart_4, apart_5, apart_6, apart_7, apart_8, apart_9, apart_10 outc amix ;SEND MIXED SIGNAL TO THE OUTPUTS PartAmp 183 0 true 0.0 1.0 0.1 250 6 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 85 293 341 350 FundFreq 181 324 true 20.0 10000.0 1.0 4640.0 500 true Amplitude 187 376 true 0.0 1.0 0.01 0.35 500 true 366 404 Ratio 170 416 true 0.125 30.0 0.0010 300 6 true 0 0 true 0.125 30.0 0.0010 2.64 300 true 0 0 true 0.125 30.0 0.0010 5.26 300 true 0 0 true 0.125 30.0 0.0010 9.035001 300 true 0 0 true 0.125 30.0 0.0010 12.703001 300 true 0 0 true 0.125 30.0 0.0010 15.743001 300 true 0 0 true 0.125 30.0 0.0010 17.106 300 true 0 0 true 0.125 30.0 0.0010 17.839 300 true 0 0 true 0.125 30.0 0.0010 18.783 300 true 0 0 true 0.125 30.0 0.0010 19.307001 300 true 0 0 true 0.125 30.0 0.0010 21.088001 300 true 121 753 Attack 166 792 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 25.01 150 true 0 0 true 0.01 99.9 1.0 19.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 23.01 150 true 0 0 true 0.01 99.9 1.0 31.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 30.01 150 true 0 0 true 0.01 99.9 1.0 29.01 150 true 0 979 Decay 165 1021 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 49.01 150 true 0 0 true 0.01 99.9 1.0 71.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 63.01 150 true 0 0 true 0.01 99.9 1.0 59.01 150 true 0 0 true 0.01 99.9 1.0 48.01 150 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 1209 Release 166 1258 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 14.01 150 true 0 0 true 0.01 99.9 1.0 8.01 150 true 0 0 true 0.01 99.9 1.0 11.01 150 true 0 0 true 0.01 99.9 1.0 10.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 22.01 150 true 0 0 true 0.01 99.9 1.0 12.01 150 true 0 0 true 0.01 99.9 1.0 7.01 150 true 0 0 true 0.01 99.9 1.0 13.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 1445 0.44 0.01:0.01:5.01:12.01:23.01:31.01:32.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 534.0 1.0:0.90000004:0.8:0.6:0.4:0.3:0.0:0.0:0.0:0.0 1.0090001:2.3260002:4.2130003:6.623:9.348001:12.493001:15.429001:19.622002:23.289001:25.910002 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 0.35 27.01:25.01:19.01:26.01:27.01:23.01:31.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 1378.3958 0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.6 0.84700006:0.54:0.65000004:0.49800003:0.41700003:0.56700003:0.55300003:0.81700003:0.40300003:0.49800003 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 Additive Synth (inharmonic) + Reverb 0dbfs = 1 ; Written by Iain McCurdy, 2006 ; Modified for QuteCsound by Ren?, September 2010 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5 israte = sr ; specification of sample rate for reverb ktrig init 1 cyclestart: ;GUI - Additive Synth kPartAmp_1 = <PartAmp_0> ; amplitude of partial kPartAmp_2 = <PartAmp_1> ; amplitude of partial kPartAmp_3 = <PartAmp_2> ; amplitude of partial kPartAmp_4 = <PartAmp_3> ; amplitude of partial kPartAmp_5 = <PartAmp_4> ; amplitude of partial kPartAmp_6 = <PartAmp_5> ; amplitude of partial kPartAmp_7 = <PartAmp_6> ; amplitude of partial kPartAmp_8 = <PartAmp_7> ; amplitude of partial kPartAmp_9 = <PartAmp_8> ; amplitude of partial kPartAmp_10 = <PartAmp_9> ; amplitude of partial kfund = <FundFreq> ; fundamental frequency kamp = <Amplitude> ; overall amplitude kratio_1 = <Ratio_0> ; ratio of the fundamental kratio_2 = <Ratio_1> ; ratio of the fundamental kratio_3 = <Ratio_2> ; ratio of the fundamental kratio_4 = <Ratio_3> ; ratio of the fundamental kratio_5 = <Ratio_4> ; ratio of the fundamental kratio_6 = <Ratio_5> ; ratio of the fundamental kratio_7 = <Ratio_6> ; ratio of the fundamental kratio_8 = <Ratio_7> ; ratio of the fundamental kratio_9 = <Ratio_8> ; ratio of the fundamental kratio_10 = <Ratio_9> ; ratio of the fundamental kampatt_1 = <Attack_0> * 0.01 ; attack [percent of note duration] kampatt_2 = <Attack_1> * 0.01 ; attack [percent of note duration] kampatt_3 = <Attack_2> * 0.01 ; attack [percent of note duration] kampatt_4 = <Attack_3> * 0.01 ; attack [percent of note duration] kampatt_5 = <Attack_4> * 0.01 ; attack [percent of note duration] kampatt_6 = <Attack_5> * 0.01 ; attack [percent of note duration] kampatt_7 = <Attack_6> * 0.01 ; attack [percent of note duration] kampatt_8 = <Attack_7> * 0.01 ; attack [percent of note duration] kampatt_9 = <Attack_8> * 0.01 ; attack [percent of note duration] kampatt_10 = <Attack_9> * 0.01 ; attack [percent of note duration] kampdec_1 = <Decay_0> * 0.01 ; decay [percent of note duration] kampdec_2 = <Decay_1> * 0.01 ; decay [percent of note duration] kampdec_3 = <Decay_2> * 0.01 ; decay [percent of note duration] kampdec_4 = <Decay_3> * 0.01 ; decay [percent of note duration] kampdec_5 = <Decay_4> * 0.01 ; decay [percent of note duration] kampdec_6 = <Decay_5> * 0.01 ; decay [percent of note duration] kampdec_7 = <Decay_6> * 0.01 ; decay [percent of note duration] kampdec_8 = <Decay_7> * 0.01 ; decay [percent of note duration] kampdec_9 = <Decay_8> * 0.01 ; decay [percent of note duration] kampdec_10 = <Decay_9> * 0.01 ; decay [percent of note duration] kamprel_1 = <Release_0> * 0.01 ; release [percent of note duration] kamprel_2 = <Release_1> * 0.01 ; release [percent of note duration] kamprel_3 = <Release_2> * 0.01 ; release [percent of note duration] kamprel_4 = <Release_3> * 0.01 ; release [percent of note duration] kamprel_5 = <Release_4> * 0.01 ; release [percent of note duration] kamprel_6 = <Release_5> * 0.01 ; release [percent of note duration] kamprel_7 = <Release_6> * 0.01 ; release [percent of note duration] kamprel_8 = <Release_7> * 0.01 ; release [percent of note duration] kamprel_9 = <Release_8> * 0.01 ; release [percent of note duration] kamprel_10 = <Release_9> * 0.01 ; release [percent of note duration] ; GUI - Reverb keffmix = <effmix> krvbdecay = <reverbdecay> kcutofffreq = <cutofffreq> irandpchmod = <randompitchmodulation> ;SYNTHESIS INSTRUMENT idur = p3 ; duration ifn = 1 ; function nr for the oscilator (sine) iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument idurprolong = p6 idur = idur - idurprolong ; no extra time in performance of this instrument kamp = kamp * iampdev ; apply deviation on this instrument kfund = kfund * ifreqdev ; apply deviation on this instrument printk 0.1, kfund iporttime = 0.05 ;PORTAMENTO TIME VARIABLE kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME kfund portk kfund, kporttime ;APPLY PORTAMENTO SMOOTHING kamp portk kamp, kporttime ;APPLY PORTAMENTO SMOOTHING ; endif ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) aenv_1 expsegr .001, idur * i(kampatt_1), 1.001, idur * i(kampdec_1), .001, idur * i(kamprel_1), .001 aenv_2 expsegr .001, idur * i(kampatt_2), 1.001, idur * i(kampdec_2), .001, idur * i(kamprel_2), .001 aenv_3 expsegr .001, idur * i(kampatt_3), 1.001, idur * i(kampdec_3), .001, idur * i(kamprel_3), .001 aenv_4 expsegr .001, idur * i(kampatt_4), 1.001, idur * i(kampdec_4), .001, idur * i(kamprel_4), .001 aenv_5 expsegr .001, idur * i(kampatt_5), 1.001, idur * i(kampdec_5), .001, idur * i(kamprel_5), .001 aenv_6 expsegr .001, idur * i(kampatt_6), 1.001, idur * i(kampdec_6), .001, idur * i(kamprel_6), .001 aenv_7 expsegr .001, idur * i(kampatt_7), 1.001, idur * i(kampdec_7), .001, idur * i(kamprel_7), .001 aenv_8 expsegr .001, idur * i(kampatt_8), 1.001, idur * i(kampdec_8), .001, idur * i(kamprel_8), .001 aenv_9 expsegr .001, idur * i(kampatt_9), 1.001, idur * i(kampdec_9), .001, idur * i(kamprel_9), .001 aenv_10 expsegr .001, idur * i(kampatt_10), 1.001, idur * i(kampdec_10),.001, idur * i(kamprel_10), .001 ;SEPARATE OSCILLATORS CREATE EACH OF THE PARTIALS (NOTE THAT FLTK VERTICAL SLIDERS ARE INVERTED TO ALLOW MINIMUM VALUES TO BE LOWEST ON THE SCREEN) ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE apart_1 oscili kamp * (aenv_1 - 0.001) * kPartAmp_1, kfund * kratio_1, ifn apart_2 oscili kamp * (aenv_2 - 0.001) * kPartAmp_2, kfund * kratio_2, ifn apart_3 oscili kamp * (aenv_3 - 0.001) * kPartAmp_3, kfund * kratio_3, ifn apart_4 oscili kamp * (aenv_4 - 0.001) * kPartAmp_4, kfund * kratio_4, ifn apart_5 oscili kamp * (aenv_5 - 0.001) * kPartAmp_5, kfund * kratio_5, ifn apart_6 oscili kamp * (aenv_6 - 0.001) * kPartAmp_6, kfund * kratio_6, ifn apart_7 oscili kamp * (aenv_7 - 0.001) * kPartAmp_7, kfund * kratio_7, ifn apart_8 oscili kamp * (aenv_8 - 0.001) * kPartAmp_8, kfund * kratio_8, ifn apart_9 oscili kamp * (aenv_9 - 0.001) * kPartAmp_9, kfund * kratio_9, ifn apart_10 oscili kamp * (aenv_10 - 0.001) * kPartAmp_10, kfund * kratio_10, ifn if ktrig == 1 then ; at first k-cycle ... ktrig = 0 ; avoid repeating this every k-cycle reinit cyclestart ; ... and reinit "cyclestart" endif rireturn ; end of (re)init pass ;SUM THE 10 OSCILLATORS: asig sum apart_1, apart_2, apart_3, apart_4, apart_5, apart_6, apart_7, apart_8, apart_9, apart_10 ; SIGNAL MODIFICATION aL, aR reverbsc asig, asig, krvbdecay, kcutofffreq, israte, irandpchmod, 1 ; generate effect aeff sum aL , aR ; sum channels aeff = aeff * keffmix + asig * ( 1 - keffmix) ; mix of direct / effect signal outc aeff ;SEND MIXED SIGNAL TO THE OUTPUTS PartAmp 183 0 true 0.0 1.0 0.1 250 6 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 85 293 341 350 FundFreq 181 324 true 20.0 10000.0 5.0 5910.0 500 true Amplitude 187 376 true 0.0 1.0 0.01 0.0 500 true 366 404 Ratio 170 416 true 0.125 30.0 0.0010 300 6 true 0 0 true 0.125 30.0 0.0010 2.64 300 true 0 0 true 0.125 30.0 0.0010 5.26 300 true 0 0 true 0.125 30.0 0.0010 9.035001 300 true 0 0 true 0.125 30.0 0.0010 12.703001 300 true 0 0 true 0.125 30.0 0.0010 15.743001 300 true 0 0 true 0.125 30.0 0.0010 17.106 300 true 0 0 true 0.125 30.0 0.0010 17.839 300 true 0 0 true 0.125 30.0 0.0010 18.783 300 true 0 0 true 0.125 30.0 0.0010 19.307001 300 true 0 0 true 0.125 30.0 0.0010 21.088001 300 true 121 753 Attack 166 792 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 25.01 150 true 0 0 true 0.01 99.9 1.0 19.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 23.01 150 true 0 0 true 0.01 99.9 1.0 31.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 30.01 150 true 0 0 true 0.01 99.9 1.0 29.01 150 true 0 979 Decay 165 1021 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 49.01 150 true 0 0 true 0.01 99.9 1.0 71.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 63.01 150 true 0 0 true 0.01 99.9 1.0 59.01 150 true 0 0 true 0.01 99.9 1.0 48.01 150 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 1209 Release 166 1258 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 14.01 150 true 0 0 true 0.01 99.9 1.0 8.01 150 true 0 0 true 0.01 99.9 1.0 11.01 150 true 0 0 true 0.01 99.9 1.0 10.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 22.01 150 true 0 0 true 0.01 99.9 1.0 12.01 150 true 0 0 true 0.01 99.9 1.0 7.01 150 true 0 0 true 0.01 99.9 1.0 13.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 1445 randompitchmodulation 787 25 1 30 740 55 cutofffreq 773 103 true 200.0 16000.0 8054.3057 60 true reverbdecay 777 202 true 0.0 1.0 0.93487245 60 true 756 185 767 295 effmix 767 329 true 0.0 1.0 0.1 1.0 150 true 794 361 0.44 0.01:0.01:5.01:12.01:23.01:31.01:32.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 534.0 1.0:0.90000004:0.8:0.6:0.4:0.3:0.0:0.0:0.0:0.0 1.0090001:2.3260002:4.2130003:6.623:9.348001:12.493001:15.429001:19.622002:23.289001:25.910002 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 0.35 27.01:25.01:19.01:26.01:27.01:23.01:31.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 1378.3958 0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.6 0.84700006:0.54:0.65000004:0.49800003:0.41700003:0.56700003:0.55300003:0.81700003:0.40300003:0.49800003 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 Additive Synth (inharmonic) + Mode 0dbfs = 1 ; Written by Iain McCurdy, 2006 ; Modified for QuteCsound by Ren?, September 2010 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5 ktrig init 1 cyclestart: ;GUI kPartAmp_1 = <PartAmp_0> ; amplitude of partial kPartAmp_2 = <PartAmp_1> ; amplitude of partial kPartAmp_3 = <PartAmp_2> ; amplitude of partial kPartAmp_4 = <PartAmp_3> ; amplitude of partial kPartAmp_5 = <PartAmp_4> ; amplitude of partial kPartAmp_6 = <PartAmp_5> ; amplitude of partial kPartAmp_7 = <PartAmp_6> ; amplitude of partial kPartAmp_8 = <PartAmp_7> ; amplitude of partial kPartAmp_9 = <PartAmp_8> ; amplitude of partial kPartAmp_10 = <PartAmp_9> ; amplitude of partial kfund = <FundFreq> ; fundamental frequency kamp = <Amplitude> ; overall amplitude kratio_1 = <Ratio_0> ; ratio of the fundamental kratio_2 = <Ratio_1> ; ratio of the fundamental kratio_3 = <Ratio_2> ; ratio of the fundamental kratio_4 = <Ratio_3> ; ratio of the fundamental kratio_5 = <Ratio_4> ; ratio of the fundamental kratio_6 = <Ratio_5> ; ratio of the fundamental kratio_7 = <Ratio_6> ; ratio of the fundamental kratio_8 = <Ratio_7> ; ratio of the fundamental kratio_9 = <Ratio_8> ; ratio of the fundamental kratio_10 = <Ratio_9> ; ratio of the fundamental kampatt_1 = <Attack_0> * 0.01 ; attack [percent of note duration] kampatt_2 = <Attack_1> * 0.01 ; attack [percent of note duration] kampatt_3 = <Attack_2> * 0.01 ; attack [percent of note duration] kampatt_4 = <Attack_3> * 0.01 ; attack [percent of note duration] kampatt_5 = <Attack_4> * 0.01 ; attack [percent of note duration] kampatt_6 = <Attack_5> * 0.01 ; attack [percent of note duration] kampatt_7 = <Attack_6> * 0.01 ; attack [percent of note duration] kampatt_8 = <Attack_7> * 0.01 ; attack [percent of note duration] kampatt_9 = <Attack_8> * 0.01 ; attack [percent of note duration] kampatt_10 = <Attack_9> * 0.01 ; attack [percent of note duration] kampdec_1 = <Decay_0> * 0.01 ; decay [percent of note duration] kampdec_2 = <Decay_1> * 0.01 ; decay [percent of note duration] kampdec_3 = <Decay_2> * 0.01 ; decay [percent of note duration] kampdec_4 = <Decay_3> * 0.01 ; decay [percent of note duration] kampdec_5 = <Decay_4> * 0.01 ; decay [percent of note duration] kampdec_6 = <Decay_5> * 0.01 ; decay [percent of note duration] kampdec_7 = <Decay_6> * 0.01 ; decay [percent of note duration] kampdec_8 = <Decay_7> * 0.01 ; decay [percent of note duration] kampdec_9 = <Decay_8> * 0.01 ; decay [percent of note duration] kampdec_10 = <Decay_9> * 0.01 ; decay [percent of note duration] kamprel_1 = <Release_0> * 0.01 ; release [percent of note duration] kamprel_2 = <Release_1> * 0.01 ; release [percent of note duration] kamprel_3 = <Release_2> * 0.01 ; release [percent of note duration] kamprel_4 = <Release_3> * 0.01 ; release [percent of note duration] kamprel_5 = <Release_4> * 0.01 ; release [percent of note duration] kamprel_6 = <Release_5> * 0.01 ; release [percent of note duration] kamprel_7 = <Release_6> * 0.01 ; release [percent of note duration] kamprel_8 = <Release_7> * 0.01 ; release [percent of note duration] kamprel_9 = <Release_8> * 0.01 ; release [percent of note duration] kamprel_10 = <Release_9> * 0.01 ; release [percent of note duration] ;SYNTHESIS INSTRUMENT idur = p3 ; duration ifn = 1 ; function nr for the oscilator (sine) iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument idurprolong = p6 idur = idur - idurprolong ; no extra time in performance of this instrument kamp = kamp; * iampdev ; apply deviation on this instrument kfund = kfund; * ifreqdev ; apply deviation on this instrument iporttime = 0.05 ;PORTAMENTO TIME VARIABLE kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME kfund portk kfund, kporttime ;APPLY PORTAMENTO SMOOTHING kamp portk kamp, kporttime ;APPLY PORTAMENTO SMOOTHING ; endif ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) print i(kampatt_10) aenv_1 expsegr .001, idur * i(kampatt_1), 1.001, idur * i(kampdec_1), .001, idur * i(kamprel_1), .001 aenv_2 expsegr .001, idur * i(kampatt_2), 1.001, idur * i(kampdec_2), .001, idur * i(kamprel_2), .001 aenv_3 expsegr .001, idur * i(kampatt_3), 1.001, idur * i(kampdec_3), .001, idur * i(kamprel_3), .001 aenv_4 expsegr .001, idur * i(kampatt_4), 1.001, idur * i(kampdec_4), .001, idur * i(kamprel_4), .001 aenv_5 expsegr .001, idur * i(kampatt_5), 1.001, idur * i(kampdec_5), .001, idur * i(kamprel_5), .001 aenv_6 expsegr .001, idur * i(kampatt_6), 1.001, idur * i(kampdec_6), .001, idur * i(kamprel_6), .001 aenv_7 expsegr .001, idur * i(kampatt_7), 1.001, idur * i(kampdec_7), .001, idur * i(kamprel_7), .001 aenv_8 expsegr .001, idur * i(kampatt_8), 1.001, idur * i(kampdec_8), .001, idur * i(kamprel_8), .001 aenv_9 expsegr .001, idur * i(kampatt_9), 1.001, idur * i(kampdec_9), .001, idur * i(kamprel_9), .001 aenv_10 expsegr .001, idur * i(kampatt_10), 1.001, idur * i(kampdec_10),.001, idur * i(kamprel_10), .001 ;SEPARATE OSCILLATORS CREATE EACH OF THE PARTIALS (NOTE THAT FLTK VERTICAL SLIDERS ARE INVERTED TO ALLOW MINIMUM VALUES TO BE LOWEST ON THE SCREEN) ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE apart_1 oscili kamp * (aenv_1 - 0.001) * kPartAmp_1, kfund * kratio_1, ifn apart_2 oscili kamp * (aenv_2 - 0.001) * kPartAmp_2, kfund * kratio_2, ifn apart_3 oscili kamp * (aenv_3 - 0.001) * kPartAmp_3, kfund * kratio_3, ifn apart_4 oscili kamp * (aenv_4 - 0.001) * kPartAmp_4, kfund * kratio_4, ifn apart_5 oscili kamp * (aenv_5 - 0.001) * kPartAmp_5, kfund * kratio_5, ifn apart_6 oscili kamp * (aenv_6 - 0.001) * kPartAmp_6, kfund * kratio_6, ifn apart_7 oscili kamp * (aenv_7 - 0.001) * kPartAmp_7, kfund * kratio_7, ifn apart_8 oscili kamp * (aenv_8 - 0.001) * kPartAmp_8, kfund * kratio_8, ifn apart_9 oscili kamp * (aenv_9 - 0.001) * kPartAmp_9, kfund * kratio_9, ifn apart_10 oscili kamp * (aenv_10 - 0.001) * kPartAmp_10, kfund * kratio_10, ifn if ktrig == 1 then ; at first k-cycle ... ktrig = 0 ; avoid repeating this every k-cycle reinit cyclestart ; ... and reinit "cyclestart" endif rireturn ; end of (re)init pass ;SUM THE 10 OSCILLATORS: asig sum apart_1, apart_2, apart_3, apart_4, apart_5, apart_6, apart_7, apart_8, apart_9, apart_10 kfreq = <freqfilter> kQ = <quality> keffmix = <modeeffmix> ; SIGNAL MODIFICATION aeff mode asig, kfreq, kQ ; mode filter asig = aeff * keffmix + asig * ( 1 - keffmix) ; mix of direct / effect signal outc asig ;SEND MIXED SIGNAL TO THE OUTPUTS PartAmp 161 62 true 0.0 1.0 0.1 250 6 true 0 0 true 0.0 1.0 0.1 0.8 250 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 63 354 323 427 FundFreq 163 393 true 20.0 10000.0 1.0 4948.0 500 true Amplitude 167 483 true 0.0 1.0 0.01 0.8 500 true 360 510 Ratio 165 560 true 0.125 2.0 0.0010 150 6 true 0 0 true 0.125 2.0 0.0010 0.84700006 150 true 0 0 true 0.125 2.0 0.0010 0.54 150 true 0 0 true 0.125 2.0 0.0010 0.651 150 true 0 0 true 0.125 2.0 0.0010 0.499 150 true 0 0 true 0.125 2.0 0.0010 0.41700003 150 true 0 0 true 0.125 2.0 0.0010 0.568 150 true 0 0 true 0.125 2.0 0.0010 1.2900001 150 true 0 0 true 0.125 2.0 0.0010 0.818 150 true 0 0 true 0.125 2.0 0.0010 0.40300003 150 true 0 0 true 0.125 2.0 0.0010 0.499 150 true 121 753 Attack 166 792 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 29.01 150 true 0 0 true 0.01 99.9 1.0 19.987001 150 true 0 0 true 0.01 99.9 1.0 26.646002 150 true 0 0 true 0.01 99.9 1.0 27.386002 150 true 0 0 true 0.01 99.9 1.0 23.687002 150 true 0 0 true 0.01 99.9 1.0 32.565 150 true 0 0 true 0.01 99.9 1.0 26.646002 150 true 0 0 true 0.01 99.9 1.0 30.347002 150 true 0 0 true 0.01 99.9 1.0 29.607002 150 true 0 979 Decay 166 1021 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 62.163002 150 true 0 0 true 0.01 99.9 1.0 37.745 150 true 0 0 true 0.01 99.9 1.0 49.584 150 true 0 0 true 0.01 99.9 1.0 71.04201 150 true 0 0 true 0.01 99.9 1.0 17.028002 150 true 0 0 true 0.01 99.9 1.0 37.745 150 true 0 0 true 0.01 99.9 1.0 63.643 150 true 0 0 true 0.01 99.9 1.0 59.203003 150 true 0 0 true 0.01 99.9 1.0 48.845 150 true 0 0 true 0.01 99.9 1.0 62.902 150 true 0 1209 Release 166 1258 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 14.807001 150 true 0 0 true 0.01 99.9 1.0 8.148001 150 true 0 0 true 0.01 99.9 1.0 11.109001 150 true 0 0 true 0.01 99.9 1.0 10.368001 150 true 0 0 true 0.01 99.9 1.0 17.028002 150 true 0 0 true 0.01 99.9 1.0 22.946001 150 true 0 0 true 0.01 99.9 1.0 12.588001 150 true 0 0 true 0.01 99.9 1.0 7.4080005 150 true 0 0 true 0.01 99.9 1.0 13.328001 150 true 0 0 true 0.01 99.9 1.0 26.646002 150 true 0 1445 freqfilter 187 1510 true 20.0 5000.0 879.1831 60 true 188 1594 quality 327 1511 true 0.0 1.0 0.1 0.4 250 true 313 1811 modeeffmix 517 1536 true 0.0 1.0 0.1 0.4 150 true 526 1589 0.8 27.01:29.01:19.987001:26.646002:27.386002:23.687002:32.565:26.646002:30.347002:29.607002 62.163002:37.745:49.584:71.04201:17.028002:37.745:63.643:59.203003:48.845:62.902 4948.0 0.8:0.6:0.6:0.6:0.4:0.4:0.4:0.3:0.3:0.3 0.84700006:0.54:0.651:0.499:0.41700003:0.568:1.2900001:0.818:0.40300003:0.499 14.807001:8.148001:11.109001:10.368001:17.028002:22.946001:12.588001:7.4080005:13.328001:26.646002 ver2:879.1831054688 0.4 0.4 Additive Synth (inharmonic) + Reverb 0dbfs = 1 ; Written by Iain McCurdy, 2006 ; Modified for QuteCsound by Ren?, September 2010 ; Tested on Ubuntu 10.04 with csound-double cvs August 2010 and QuteCsound svn rev 733 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=alsa -Ma -m0 --midi-key-oct=4 --midi-velocity-amp=5 israte = sr ; specification of sample rate for reverb ktrig init 1 cyclestart: ;GUI - Additive Synth kPartAmp_1 = <PartAmp_0> ; amplitude of partial kPartAmp_2 = <PartAmp_1> ; amplitude of partial kPartAmp_3 = <PartAmp_2> ; amplitude of partial kPartAmp_4 = <PartAmp_3> ; amplitude of partial kPartAmp_5 = <PartAmp_4> ; amplitude of partial kPartAmp_6 = <PartAmp_5> ; amplitude of partial kPartAmp_7 = <PartAmp_6> ; amplitude of partial kPartAmp_8 = <PartAmp_7> ; amplitude of partial kPartAmp_9 = <PartAmp_8> ; amplitude of partial kPartAmp_10 = <PartAmp_9> ; amplitude of partial kfund = <FundFreq> ; fundamental frequency kamp = <Amplitude> ; overall amplitude kratio_1 = <Ratio_0> ; ratio of the fundamental kratio_2 = <Ratio_1> ; ratio of the fundamental kratio_3 = <Ratio_2> ; ratio of the fundamental kratio_4 = <Ratio_3> ; ratio of the fundamental kratio_5 = <Ratio_4> ; ratio of the fundamental kratio_6 = <Ratio_5> ; ratio of the fundamental kratio_7 = <Ratio_6> ; ratio of the fundamental kratio_8 = <Ratio_7> ; ratio of the fundamental kratio_9 = <Ratio_8> ; ratio of the fundamental kratio_10 = <Ratio_9> ; ratio of the fundamental kampatt_1 = <Attack_0> * 0.01 ; attack [percent of note duration] kampatt_2 = <Attack_1> * 0.01 ; attack [percent of note duration] kampatt_3 = <Attack_2> * 0.01 ; attack [percent of note duration] kampatt_4 = <Attack_3> * 0.01 ; attack [percent of note duration] kampatt_5 = <Attack_4> * 0.01 ; attack [percent of note duration] kampatt_6 = <Attack_5> * 0.01 ; attack [percent of note duration] kampatt_7 = <Attack_6> * 0.01 ; attack [percent of note duration] kampatt_8 = <Attack_7> * 0.01 ; attack [percent of note duration] kampatt_9 = <Attack_8> * 0.01 ; attack [percent of note duration] kampatt_10 = <Attack_9> * 0.01 ; attack [percent of note duration] kampdec_1 = <Decay_0> * 0.01 ; decay [percent of note duration] kampdec_2 = <Decay_1> * 0.01 ; decay [percent of note duration] kampdec_3 = <Decay_2> * 0.01 ; decay [percent of note duration] kampdec_4 = <Decay_3> * 0.01 ; decay [percent of note duration] kampdec_5 = <Decay_4> * 0.01 ; decay [percent of note duration] kampdec_6 = <Decay_5> * 0.01 ; decay [percent of note duration] kampdec_7 = <Decay_6> * 0.01 ; decay [percent of note duration] kampdec_8 = <Decay_7> * 0.01 ; decay [percent of note duration] kampdec_9 = <Decay_8> * 0.01 ; decay [percent of note duration] kampdec_10 = <Decay_9> * 0.01 ; decay [percent of note duration] kamprel_1 = <Release_0> * 0.01 ; release [percent of note duration] kamprel_2 = <Release_1> * 0.01 ; release [percent of note duration] kamprel_3 = <Release_2> * 0.01 ; release [percent of note duration] kamprel_4 = <Release_3> * 0.01 ; release [percent of note duration] kamprel_5 = <Release_4> * 0.01 ; release [percent of note duration] kamprel_6 = <Release_5> * 0.01 ; release [percent of note duration] kamprel_7 = <Release_6> * 0.01 ; release [percent of note duration] kamprel_8 = <Release_7> * 0.01 ; release [percent of note duration] kamprel_9 = <Release_8> * 0.01 ; release [percent of note duration] kamprel_10 = <Release_9> * 0.01 ; release [percent of note duration] ; GUI - Reverb keffmix = <effmix> krvbdecay = <reverbdecay> kcutofffreq = <cutofffreq> irandpchmod = <randompitchmodulation> ;SYNTHESIS INSTRUMENT idur = p3 ; duration ifn = 1 ; function nr for the oscilator (sine) iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument idurprolong = p6 idur = idur - idurprolong ; no extra time in performance of this instrument kamp = kamp * iampdev ; apply deviation on this instrument kfund = kfund * ifreqdev ; apply deviation on this instrument printk 0.1, kfund iporttime = 0.05 ;PORTAMENTO TIME VARIABLE kporttime linseg 0,0.001,iporttime,1,iporttime ;CREATE A RAMPING UP FUNCTION TO REPRESENT PORTAMENTO TIME kfund portk kfund, kporttime ;APPLY PORTAMENTO SMOOTHING kamp portk kamp, kporttime ;APPLY PORTAMENTO SMOOTHING ; endif ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) ;AMPLITUDE ENVELOPES (WITH MIDI RELEASE SEGMENT) aenv_1 expsegr .001, idur * i(kampatt_1), 1.001, idur * i(kampdec_1), .001, idur * i(kamprel_1), .001 aenv_2 expsegr .001, idur * i(kampatt_2), 1.001, idur * i(kampdec_2), .001, idur * i(kamprel_2), .001 aenv_3 expsegr .001, idur * i(kampatt_3), 1.001, idur * i(kampdec_3), .001, idur * i(kamprel_3), .001 aenv_4 expsegr .001, idur * i(kampatt_4), 1.001, idur * i(kampdec_4), .001, idur * i(kamprel_4), .001 aenv_5 expsegr .001, idur * i(kampatt_5), 1.001, idur * i(kampdec_5), .001, idur * i(kamprel_5), .001 aenv_6 expsegr .001, idur * i(kampatt_6), 1.001, idur * i(kampdec_6), .001, idur * i(kamprel_6), .001 aenv_7 expsegr .001, idur * i(kampatt_7), 1.001, idur * i(kampdec_7), .001, idur * i(kamprel_7), .001 aenv_8 expsegr .001, idur * i(kampatt_8), 1.001, idur * i(kampdec_8), .001, idur * i(kamprel_8), .001 aenv_9 expsegr .001, idur * i(kampatt_9), 1.001, idur * i(kampdec_9), .001, idur * i(kamprel_9), .001 aenv_10 expsegr .001, idur * i(kampatt_10), 1.001, idur * i(kampdec_10),.001, idur * i(kamprel_10), .001 ;SEPARATE OSCILLATORS CREATE EACH OF THE PARTIALS (NOTE THAT FLTK VERTICAL SLIDERS ARE INVERTED TO ALLOW MINIMUM VALUES TO BE LOWEST ON THE SCREEN) ;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE apart_1 oscili kamp * (aenv_1 - 0.001) * kPartAmp_1, kfund * kratio_1, ifn apart_2 oscili kamp * (aenv_2 - 0.001) * kPartAmp_2, kfund * kratio_2, ifn apart_3 oscili kamp * (aenv_3 - 0.001) * kPartAmp_3, kfund * kratio_3, ifn apart_4 oscili kamp * (aenv_4 - 0.001) * kPartAmp_4, kfund * kratio_4, ifn apart_5 oscili kamp * (aenv_5 - 0.001) * kPartAmp_5, kfund * kratio_5, ifn apart_6 oscili kamp * (aenv_6 - 0.001) * kPartAmp_6, kfund * kratio_6, ifn apart_7 oscili kamp * (aenv_7 - 0.001) * kPartAmp_7, kfund * kratio_7, ifn apart_8 oscili kamp * (aenv_8 - 0.001) * kPartAmp_8, kfund * kratio_8, ifn apart_9 oscili kamp * (aenv_9 - 0.001) * kPartAmp_9, kfund * kratio_9, ifn apart_10 oscili kamp * (aenv_10 - 0.001) * kPartAmp_10, kfund * kratio_10, ifn if ktrig == 1 then ; at first k-cycle ... ktrig = 0 ; avoid repeating this every k-cycle reinit cyclestart ; ... and reinit "cyclestart" endif rireturn ; end of (re)init pass ;SUM THE 10 OSCILLATORS: asig sum apart_1, apart_2, apart_3, apart_4, apart_5, apart_6, apart_7, apart_8, apart_9, apart_10 ; SIGNAL MODIFICATION aL, aR reverbsc asig, asig, krvbdecay, kcutofffreq, israte, irandpchmod, 1 ; generate effect aeff sum aL , aR ; sum channels aeff = aeff * keffmix + asig * ( 1 - keffmix) ; mix of direct / effect signal outc aeff ;SEND MIXED SIGNAL TO THE OUTPUTS PartAmp 183 0 true 0.0 1.0 0.1 250 6 true 0 0 true 0.0 1.0 0.1 0.6 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.4 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.3 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 0 0 true 0.0 1.0 0.1 0.2 250 true 85 293 341 350 FundFreq 181 324 true 20.0 10000.0 1.0 5911.0 500 true Amplitude 187 376 true 0.0 1.0 0.01 0.48 500 true 366 404 Ratio 170 416 true 0.125 30.0 0.0010 300 6 true 0 0 true 0.125 30.0 0.0010 2.64 300 true 0 0 true 0.125 30.0 0.0010 5.26 300 true 0 0 true 0.125 30.0 0.0010 9.035001 300 true 0 0 true 0.125 30.0 0.0010 12.703001 300 true 0 0 true 0.125 30.0 0.0010 15.743001 300 true 0 0 true 0.125 30.0 0.0010 17.106 300 true 0 0 true 0.125 30.0 0.0010 17.839 300 true 0 0 true 0.125 30.0 0.0010 18.783 300 true 0 0 true 0.125 30.0 0.0010 19.307001 300 true 0 0 true 0.125 30.0 0.0010 21.088001 300 true 121 753 Attack 166 792 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 25.01 150 true 0 0 true 0.01 99.9 1.0 19.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 27.01 150 true 0 0 true 0.01 99.9 1.0 23.01 150 true 0 0 true 0.01 99.9 1.0 31.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 0 true 0.01 99.9 1.0 30.01 150 true 0 0 true 0.01 99.9 1.0 29.01 150 true 0 979 Decay 165 1021 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 49.01 150 true 0 0 true 0.01 99.9 1.0 71.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 37.01 150 true 0 0 true 0.01 99.9 1.0 63.01 150 true 0 0 true 0.01 99.9 1.0 59.01 150 true 0 0 true 0.01 99.9 1.0 48.01 150 true 0 0 true 0.01 99.9 1.0 62.01 150 true 0 1209 Release 166 1258 true 0.01 99.9 1.0 150 6 true 0 0 true 0.01 99.9 1.0 14.01 150 true 0 0 true 0.01 99.9 1.0 8.01 150 true 0 0 true 0.01 99.9 1.0 11.01 150 true 0 0 true 0.01 99.9 1.0 10.01 150 true 0 0 true 0.01 99.9 1.0 17.01 150 true 0 0 true 0.01 99.9 1.0 22.01 150 true 0 0 true 0.01 99.9 1.0 12.01 150 true 0 0 true 0.01 99.9 1.0 7.01 150 true 0 0 true 0.01 99.9 1.0 13.01 150 true 0 0 true 0.01 99.9 1.0 26.01 150 true 0 1445 randompitchmodulation 787 25 1 30 740 55 cutofffreq 773 103 true 200.0 16000.0 8054.3057 60 true reverbdecay 777 202 true 0.0 1.0 0.93487245 60 true 756 185 767 295 effmix 767 329 true 0.0 1.0 0.1 1.0 150 true 794 361 0.44 0.01:0.01:5.01:12.01:23.01:31.01:32.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 534.0 1.0:0.90000004:0.8:0.6:0.4:0.3:0.0:0.0:0.0:0.0 1.0090001:2.3260002:4.2130003:6.623:9.348001:12.493001:15.429001:19.622002:23.289001:25.910002 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 0.35 27.01:25.01:19.01:26.01:27.01:23.01:31.01:26.01:30.01:29.01 62.01:37.01:49.01:71.01:17.01:37.01:63.01:59.01:48.01:62.01 1378.3958 0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.4:0.6 0.84700006:0.54:0.65000004:0.49800003:0.41700003:0.56700003:0.55300003:0.81700003:0.40300003:0.49800003 14.01:8.01:11.01:10.01:17.01:22.01:12.01:7.01:13.01:26.01 Noise + ResonFilter kamp = <amplitude> kcf = <centerfreq> kbw = <bandwith> ; ENVELOPE GENERATOR idur = p3 idurprolong = p6 idur = idur - idurprolong ; no extra instrument performance iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument kamp = kamp * iampdev ; apply deviation on this instrument kcf = kcf * ifreqdev ; apply deviation on this instrument katt = <Attack> * 0.01 ; attack [percent of note duration] kdec = <Decay> * 0.01 ; decay [percent of note duration] ktrig init 1 cycle: ; start of (re)init pass kenv expseg .001, idur * i(katt), 1.001, idur * i(kdec), .001, idur - i(katt + kdec), .001 rireturn ; end of (re)init pass if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" ktrig = 0 ; avoid repeating this every k-cycle endif ; SOUND PRODUCTION (NOISE) asig pinkish kamp ; FILTER asig reson asig, kcf * kenv, kbw ;[, iscl] [, iskip] ; OUTPUT outc asig centerfreq 92 77 true 20.0 15000.0 20.0 60 true 74 169 bandwith 268 78 true 20.0 1500.0 20.0 60 true 273 170 amplitude 89 271 true 0.0 1.0 0.01 0.85999995 300 true 75 619 Attack 286 275 true 0.0 100.0 0.1 50.9 300 false 250 628 467 631 Decay 503 275 true 0.0 100.0 0.1 0.0 300 false Noise + LPF18Filter kamp = <amplitude> kfco = <cuttoff_freq> kres = <resonance> isweepfn = <isweepfn> ; ENVELOPE GENERATOR idur = p3 idurprolong = p6 idur = idur - idurprolong ; no extra instrument performance iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument isweepfn = abs(isweepfn) ; E movement function nr isweepfndir = <isweepfn> / isweepfn ; negative fn causes backwards reading kamp = kamp * iampdev ; apply deviation on this instrument kfco = kfco * ifreqdev ; apply deviation on this instrument idist init 0 ; distortion ; SOUND PRODUCTION (NOISE) anoise pinkish kamp ; FILTER ksweep oscil 1, isweepfndir * (1/idur), isweepfn afilt lpf18 anoise, kfco + kfco * ksweep, kres, idist asig balance afilt, anoise ; OUTPUT outc asig cuttoff_freq 92 77 true 20.0 8000.0 412.38428 60 true 74 168 resonance 268 79 true 0.0 1.0 1.0 60 true 273 169 amplitude 412 253 true 0.0 2.0 0.01 0.45987657 300 true 394 604 isweepfn 81 210 31 100 74 241 Noise + LPF18Filter kamp = <amplitude_2> kfco = <cuttoff_freq_2> kres = <resonance_2> isweepfn = <isweepfn_2> ; ENVELOPE GENERATOR idur = p3 idurprolong = p6 idur = idur - idurprolong ; no extra instrument performance iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument isweepfn = abs(isweepfn) ; E movement function nr isweepfndir = <isweepfn_2> / isweepfn ; negative fn causes backwards reading kamp = kamp * iampdev ; apply deviation on this instrument kfco = kfco * ifreqdev ; apply deviation on this instrument idist init 0 ; SOUND PRODUCTION (NOISE) anoise pinkish kamp ; FILTER ksweep oscil 1, isweepfndir * (1/idur), isweepfn afilt lpf18 anoise, kfco + kfco * ksweep, kres, idist asig balance afilt, anoise ; OUTPUT outc asig cuttoff_freq_2 92 77 true 20.0 8000.0 658.39984 60 true 74 168 resonance_2 268 80 true 0.0 1.0 1.0 60 true 273 169 amplitude_2 412 247 true 0.0 2.0 0.01 1.2141799 300 true 394 604 isweepfn_2 81 210 31 100 74 241 Noise + ModeFilter kamp = <amplitude_29> kfreq = <freqfilter_29> kQ = <quality_29> isweepfn = <isweepfn_29> ; ENVELOPE GENERATOR idur = p3 idurprolong = p6 idur = idur - idurprolong ; no extra instrument performance iampdev = p4 ; amplitude deviation from master instrument ifreqdev = p5 ; frequency deviation from master instrument isweepfn = abs(isweepfn) ; E movement function nr isweepfndir = <isweepfn_29> / isweepfn ; negative fn causes backwards reading kamp = kamp * iampdev ; apply deviation on this instrument kfreq = kfreq * ifreqdev ; apply deviation on this instrument idist init 0 ; SOUND PRODUCTION (NOISE) anoise pinkish kamp ; FILTER ; SIGNAL MODIFICATION ksweep oscil 1, isweepfndir * (1/idur), isweepfn afilt mode anoise, kfreq * ksweep, kQ ; mode filter asig balance afilt, anoise ; OUTPUT outc asig amplitude_29 397 34 true 0.0 2.0 0.01 1.99 300 true 379 390 isweepfn_29 81 210 21 100 74 241 freqfilter_29 94 45 true 20.0 5000.0 3392.028 60 true 72 129 quality_29 244 30 true 0.0 1.0 0.1 0.8 250 true 242 322 Sine Oscillator kamp = 0dbfs * <amplitude> kfreq = <freq> ; frequency (pitch) of grain iampdev = p4 ifreqdev = p5 idurprolong = p6 adry oscil kamp * iampdev, kfreq * ifreqdev, 1 outc adry freq 93 33 true 20.0 5000.0 571.60913 60 true 94 116 amplitude 101 159 true 0.0 1.0 0.01 0.51 250 true 77 477 Sawtooth Oscillator ifn = <ifn> kamp = <amplitude> kfreq = <freq> ; frequency (pitch) of grain isweepfn_1 = <sweepfn_1> ksweepamp_1 = <sweepamp_1> iampdev = p4 ifreqdev = p5 kvdepth = <Vibratodepth> kvrate = <Vibratofreq> asweep init 1 kcf = <cutofffreq> kres = <resonance> isweepfn_2 = <sweepfn_2> ksweepamp_2 = <sweepamp_2> kfiltermix = <filtermix> idist init 0 ktrig init 1 cycle: ; start of (re)init pass isweepamp_1 = i(ksweepamp_1) isweepamp_2 = i(ksweepamp_2) if ktrig == 1 then ; at first k-cycle ... reinit cycle ; start reinit-pass from label "cycle" ktrig = 0 ; avoid repeating this every k-cycle endif ; SOUND PRODUCTION asweep_1 subinstr 15, isweepfn_1, isweepamp_1 rireturn ; end of (re)init pass ksweep_1 downsamp asweep_1 ksweep_1 = ksweep_1 + 1 kvib oscili kvdepth, kvrate, 1 adry oscili kamp * iampdev * kvib, kfreq * ifreqdev * ksweep_1, ifn ; FILTERING asweep_2 subinstr 15, isweepfn_2, isweepamp_2 rireturn ; end of (re)init pass ksweep_2 downsamp asweep_2 ksweep_2 = ksweep_2 + 1 afilt lpf18 adry, kcf * ksweep_2, kres, idist asig balance afilt, adry asig = adry * (1 - kfiltermix) + asig * kfiltermix ; OUTPUT outc asig freq 202 15 true 20.0 5000.0 1897.1241 60 true 203 103 amplitude 90 19 true 0.0 1.0 0.01 0.83 400 true 74 456 cutofffreq 493 18 true 20.0 15000.0 477.16772 60 true 472 106 resonance 491 138 true 0.0 1.0 1.0 60 true 490 226 sweepfn_2 635 191 11 40 612 225 sweepamp_2 633 264 true -0.5 1.0 0.1 1.0 150 true 585 454 filtermix 484 271 true 0.0 1.0 0.0 80 true 498 375 ifn 211 133 3 40 210 164 sweepfn_1 210 192 11 40 196 220 sweepamp_1 213 263 true -0.5 1.0 0.1 1.0 150 false 181 455 Vibratodepth 311 19 true 0.0 1.0 1.0 80 true 311 120 Vibratofreq 311 165 true 0.0 20.0 15.506059 80 true 316 260 fmrhode iampdev = p4 ifreqdev = p5 kamp = <Amplitude> kfreq = <Frequency> kc1 = <KC_1> kc2 = <KC_2> kvdepth = <Vibratodepth> kvrate = <Vibratofreq> ifn1 = <ifn_1> ifn2 = <ifn_2> ifn3 = <ifn_3> ifn4 = <ifn_4> ivfn = <ivfn_5> asig fmrhode kamp * iampdev, kfreq * ifreqdev, kc1, kc2, kvdepth, kvrate, ifn1, ifn2, ifn3, ifn4, ivfn outc asig Amplitude 68 97 true 0.0 1.0 0.1 0.6 300 true 63 436 Frequency 158 97 true 0.0 10000.0 1.0 5439.0 300 true 153 436 KC_1 256 97 true 0.0 10.0 0.1 6.1 300 true 264 436 KC_2 347 97 true 0.0 10.0 0.1 0.8 300 true 358 436 Vibratodepth 478 163 true 0.0 1.0 0.023920987 80 true 478 264 Vibratofreq 478 310 true 0.0 20.0 0.0 80 true 483 404 ifn_1 637 114 1 40 694 115 ifn_2 637 157 1 40 694 158 ifn_3 637 200 1 40 694 201 ifn_4 637 243 1 40 694 244 ivfn_5 637 287 1 40 694 288 Soundfile Granulator idopp = p4 ; import of factor for doppler effect from host instrument iamp = <amplitude> ; amplitude of grain ifn = <fn> ; function number to play ispeed = <speed> ; speed (pitch of function) ilps = <loopstart> ; loop start [0-1] ilpdur = <loopdur> ; loop length [0-1] ; CALCULATION OF SAMPLE LENGTH ilen = ftlen(ifn) / sr ; calculation of lenth of the used tabele [sec] ; CALCULATION OF LOOP LENGTH ilps = ilen * ilps * sr ; loop start [sec] ilpdur = ilen * ilpdur * sr - ilps ; loop length [sec] ; CALCULATION OF SAMPLE END ilpe = ilps + ilpdur ; calculation of loop end ; SAMPLE READ-OUT asig lposcil iamp, ispeed * idopp, ilps, ilpe, ifn; [, iphs] amplitude 72 62 true 0.0 32767.0 1.0 4369.0 150 true fn 185 83 100 100 72 254 185 112 speed 185 172 true 0.0 2.0 0.1 0.90000004 300 true 306 210 loopstart 72 343 true 0.0 1.0 0.1 0.0 150 true loopdur 335 343 true 0.0 1.0 0.1 0.0 150 true 118 381 402 381 Mode Filter kfreq = <freqfilter> kQ = <quality> keffmix = <modeeffmix> ; SIGNAL MODIFICATION aeff mode asig, kfreq, kQ ; mode filter asig = aeff * keffmix + asig * ( 1 - keffmix) ; mix of direct / effect signal freqfilter 76 77 true 20.0 5000.0 521.80914 60 true quality 216 78 true 0.0 1.0 0.1 0.4 250 true 77 161 202 378 modeeffmix 406 103 true 0.0 1.0 0.1 0.0 150 true 415 156 2 Modes Excitator iampdev = p4 ifreqdev = p5 kfreq_1 = <Frequency_0> kfreq_2 = <Frequency_1> kfreq_3 = <Frequency_2> kfreq_4 = <Frequency_3> kfreqfact = <FreqDev> * ifreqdev kfreq_1 = kfreq_1 * kfreqfact kfreq_2 = kfreq_2 * kfreqfact kfreq_3 = kfreq_3 * kfreqfact kfreq_4 = kfreq_4 * kfreqfact kQ_1 = <Quality_0> kQ_2 = <Quality_1> kQ_3 = <Quality_2> kQ_4 = <Quality_3> kampulse = <AmpImp> kampexc = <AmpExcite> kamp = <Amplitude> printk 1, kampulse printk 1, kampexc printk 1, kamp ; EXCITATOR ; to simulate the shock between the excitator and the resonator ashock mpulse kampulse, 0 aexc1 mode ashock, kfreq_1 ,kQ_1 aexc1 = aexc1 * kamp aexc2 mode ashock, kfreq_2 ,kQ_2 aexc2 = aexc2 * kamp aexc = ( aexc1 + aexc2 ) * 0.5 ;"Contact" condition : when aexc reaches 0, the excitator looses ;contact with the resonator, and stops "pushing it" aexc limit aexc, 0, kampexc * kamp ; RESONATOR ; 2modes resonator ares1 mode aexc,kfreq_3, kQ_3 ares2 mode aexc,kfreq_4, kQ_4 ares = (ares1 + ares2) * 0.5 asig = (aexc + ares) * iampdev outs asig, asig Frequency 0 11 true 20.0 10000.0 1.0 300 5 true 0 0 true 20.0 10000.0 1.0 5623.0 300 true 0 0 true 20.0 10000.0 1.0 1946.0 300 true 0 0 true 20.0 10000.0 1.0 4572.0 300 true 0 0 true 20.0 10000.0 1.0 6043.0 300 true Quality 295 11 true 0.0 500.0 1.0 300 5 true 0 0 true 0.0 500.0 1.0 160.0 300 true 0 0 true 0.0 500.0 1.0 256.0 300 true 0 0 true 0.0 500.0 1.0 167.0 300 true 0 0 true 0.0 500.0 1.0 230.0 300 true 7 359 62 359 113 358 170 358 300 358 355 358 410 358 465 358 FreqDev 611 30 true 0.0 2.0 0.9989284 80 true 587 131 765 358 853 358 938 357 AmpImp 778 11 true 0.0 10.0 0.1 7.2000003 300 true AmpExcite 863 11 true 0.0 10.0 0.1 7.6 300 true Amplitude 947 14 true 0.0 20.0 0.1 2.0 300 true Mode 6 - Percussion Description: 6 Mode instrument using mpulse as striking force Based on work by Scott Lindroth and Francois Blanc NOTE: Mode frequency multiplier should be carefully set so that sr/freq < pi (see documentation on for mode opcode) Author: Steven Yi [HISTORY] v1.0 - Initial Release iampdev = p4 ; Amplitude deviation passed over from the host instrument ifreqdev = p5 ; Frequency deviation passed over from the host instrument kamp = <Amp> ; Amplitude from interface of the instrument kfreq = <Freq> ; Frequency from interface of the instrument iQ = <baseQ> ktrig init 1 cycle: ; start of (re)init pass iamp = i(kamp) * iampdev ; conversion of amplitude and application of deviation ifreq = i(kfreq) * ifreqdev ; conversion of freqency and application of deviation ;INSERT SOUND GENERATION CODE HERE inummodes = <modeOn0> + <modeOn1> + <modeOn2> + <modeOn3> + <modeOn4> + <modeOn5> ; switch on and off the mode filters aexc mpulse inummodes, 0 if ktrig == 1 then ; at first k-cycle ... ktrig = 0 ; avoid repeating this every k-cycle reinit cycle ; start reinit-pass from label "cycle" endif print ifreq aout init 0 aout = 0 if (<modeOn0> == 1) then aout0 mode aexc * <gain0>, ifreq * <freqMultiply0>, iQ * <qMultiply0> aout sum aout, aout0 endif if (<modeOn1> == 1) then aout1 mode aexc * <gain1>, ifreq * <freqMultiply1>, iQ * <qMultiply1> aout sum aout, aout1 endif if (<modeOn2> == 1) then aout2 mode aexc * <gain2>, ifreq * <freqMultiply2>, iQ * <qMultiply2> aout sum aout, aout2 endif if (<modeOn3> == 1) then aout3 mode aexc * <gain3>, ifreq * <freqMultiply3>, iQ * <qMultiply3> aout sum aout, aout3 endif if (<modeOn4> == 1) then aout4 mode aexc * <gain4>, ifreq * <freqMultiply4>, iQ * <qMultiply4> aout sum aout, aout4 endif if (<modeOn5> == 1) then aout5 mode aexc * <gain5>, ifreq * <freqMultiply5>, iQ * <qMultiply5> aout sum aout, aout5 endif ;END SOUND GENERATION CODE aout = aout * iamp print iamp rireturn ; end of (re)init pass outc aout 11 11 32 384 baseQ 99 366 false 0.0 100.0 61.8957 60 true freqMultiply0 99 161 false 1.0 16.0 2.578528 60 true qMultiply0 100 240 false 0.0 1.0 0.40843627 60 true 19 181 36 260 123 57 freqMultiply1 168 161 false 1.0 16.0 3.245028 60 true qMultiply1 168 238 false 0.0 1.0 0.2880254 60 true freqMultiply2 237 161 false 1.0 16.0 1.975806 60 true qMultiply2 237 238 false 0.0 1.0 0.2051352 60 true freqMultiply3 306 161 false 1.0 16.0 2.10998 60 true qMultiply3 306 238 false 0.0 1.0 0.014398522 60 true freqMultiply4 375 161 false 1.0 16.0 3.211486 60 true qMultiply4 375 238 false 0.0 1.0 0.14396146 60 true 192 57 261 57 330 57 399 57 freqMultiply5 444 161 false 1.0 16.0 3.7927933 60 true qMultiply5 444 238 false 0.0 1.0 0.048642457 60 true 468 57 modeOn0 109 319 false true true modeOn1 180 319 false true true modeOn2 247 319 false true true modeOn3 316 319 false true true modeOn4 385 319 false true true modeOn5 454 319 false true true gain0 99 84 false 0.0 1.0 0.9665402 60 true 34 104 gain1 168 84 false 0.0 1.0 0.9247825 60 true gain2 237 84 false 0.0 1.0 0.9664831 60 true gain3 306 84 false 0.0 1.0 0.77283764 60 true gain4 375 84 false 0.0 1.0 0.85038245 60 true gain5 444 84 false 0.0 1.0 0.96542007 60 true Freq 581 55 true 20.0 10000.0 1.0 772.0 400 true 579 490 Amp 671 56 true 0.0 1000.0 0.1 220.8 400 true 669 490 ver2:0.099999994 ver2:37.0705451965 ver2:0.0145723308 ver2:0.0175071973 ver2:1 ver2:2 ver2:3 ver2:4 ver2:6 ver2:8 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 true true true true true false ver2:1 ver2:0.400000006 ver2:0.5 ver2:0.6000000238 ver2:0.3000000119 ver2:0.200000003 ver2:0.1461223066 ver2:0.896673739 ver2:0.099999994 ver2:11.485004425 ver2:0.0145723308 ver2:0.0175071973 ver2:1 ver2:2 ver2:3.0099999905 ver2:4.0100002289 ver2:4.6900000572 ver2:5.6300001144 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 true true true true true true ver2:1 ver2:0.400000006 ver2:0.5 ver2:0.6000000238 ver2:0.3000000119 ver2:0.3000000119 ver2:0.1461223066 ver2:0.896673739 ver2:0.099999994 ver2:33.1700668335 ver2:0.0145723308 ver2:0.0111588016 ver2:1 ver2:1.4700000286 ver2:2.0899999142 ver2:2.5599999428 ver2:4.6900000572 ver2:5.6300001144 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 true true true true false false ver2:1 ver2:1 ver2:0.2509221435 ver2:0.2812690735 ver2:0.3000000119 ver2:0.3000000119 ver2:0.1461223066 ver2:0.896673739 ver2:0.099999994 ver2:33.1700668335 ver2:0.0145723308 ver2:0.0111588016 ver2:1 ver2:1.4700000286 ver2:2.0899999142 ver2:2.5599999428 ver2:4.6900000572 ver2:5.6300001144 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 ver2:1 true true true true false false ver2:1 ver2:1 ver2:0.2509221435 ver2:0.2812690735 ver2:0.3000000119 ver2:0.3000000119 ver2:0.1461223066 ver2:0.896673739 getFrequency i i ipch xin iout = (ipch < 15 ? cpspch(ipch) : ipch) xout iout SPATIAL AED GRANULATOR (complex) ; COPYING UNIT icpydel = p18 ; delay of copy [s] imaxcnt = p19 ; maximum number of copies icnt = p20 ; count of number of copys, has to be "0" at the score icpyampatt init 1 ; initialisation of the variable responsible for attenuation of a copy icpyfreqshift init 1 ; initialisation of the variable responsible for shift of frequency of a copy if icnt != 0 goto endcopy ; skip creation of a copy if this instance of the instrument is already a copy or if no copies are requested if imaxcnt == 0 goto nocopy ; no creation of a copy if maximum number of copies = 0 copy: icnt = icnt + 1 ; count the number of copies if icnt > imaxcnt goto nocopy ; stop copying if the maximum number of copies is reached icpyampatt = i(<Copy_ampattenuation>) ^ icnt ; atennuate each copy by this factor icpyfreqshift = i(<Copy_frequencyshift>) ^ icnt ; shift the frequency of each copy by this factor icpydelay = icpydel * icnt ; shift the start time of each copy by the amount of icpydelay iA_cpydev = p21 * icnt ; shift the angle of each copy by the amount of iAcpydev iE_cpydev = p22 * icnt ; shift the elevation of each copy by the amount of iAcpydev iD_cpydev = p23 * icnt ; shift the distance of each copy by the amount of iAcpydev schedule p1, icpydelay, p3, p4, p5 * icpyampatt, p6* icpyfreqshift, p7, p8 + iA_cpydev, p9 + iE_cpydev, p10 + iD_cpydev, p11, p12, p13, p14, p15 , p16, p17, p18, p19, icnt, p21, p22, p23 ; generate the copy goto copy endcopy: nocopy: ; INSTRUMENT idur = p3 ; duration iinst = p4 ; instrument number of sound producing instrument iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ienvinst = p7 ; instrument number of envelope instrument iA_dev = p8 ; deviation of position of grain - angle [¡] (amount of schifting of copy included) iE_dev = p9 ; deviation of position of grain - elevation [¡] (amount of schifting of copy included) iD_dev = p10 ; deviation of position of grain - distance [unit] (amount of schifting of copy included) iA_move = p11 ; amount of movement of a single grain in regard to the cloud [¡] iE_move = p12 ; amount of movement of a single grain in regard to the cloud [¡] iD_move = p13 ; amount of movement of a single grain in regard to the cloud [unit] iA_range = p14 ; possible range of deviation of angle [¡] iE_range = p15 ; possible range of deviation of elevation [¡] iD_range = p16 ; possible range of deviation of distance [unit] icrtlfn = p17 ; control distribution fn kA_centre = <Angle> ; position (centre) of the cloud - angle [¡] kE_centre = <Elevation> ; position (centre) of the cloud - elevation [¡] kD_centre = <Distance> ; position (centre) of the cloud - distance [unit] iA_modctrl = i(<Angle_mod_ctrl>) ; angle modification controller [0 = no correlation; 1 = full correlation regarding angle] iE_modctrl = i(<Elevation_mod_ctrl>) ; elevation modification controller [0 = no correlation; 1 = full correlation regarding elevation] iD_modctrl = i(<Distance_mod_ctrl>) ; distance modification controller [0 = no correlation; 1 = full correlation regarding distance] ifreqctrl = i(<freqdevmixctrl>) ; ifreq dev mix controller [0= frequency as assigned, 1= frequency according to position] iampctrl = i(<ampdevmixctrl>) ; iamp dev mix controller [0= amplitude as assigned, 1= amplitude according to position] iADcorr = i(<Distance_CorrelationX>) ; angle-distance correllation factor [0 = no correlation; 1 = full correlation between angle and distance] iEDcorr = i(<Distance_CorrelationY>) ; elevation-distance correllation factor [0 = no correlation; 1 = full correlation between elevation and distance] ; INSTRUMENT PROLONGATION idurprolong = gidurprolong ; extra duration for reverb tail of local reverb p3 = p3 + idurprolong ; add extra duration to this instrument ; CALCULATION OF LOCATION kA_grain line iA_dev, idur, iA_dev + iA_move ; creation of a trajectory of the grain during note kE_grain line iE_dev, idur, iE_dev + iE_move ; creation of a trajectory of the grain during note kD_grain line iD_dev, idur, iD_dev + iD_move ; creation of a trajectory of the grain during note kA = kA_centre + kA_grain ; adding up movement of the cloud and movement of the grain kE = kE_centre + kE_grain ; adding up movement of the cloud and movement of the grain kD = kD_centre + kD_grain ; adding up movement of the cloud and movement of the grain kD = (kD < 0.3 ? 0.3 : kD ) ; limits kD to a minimum of 0.3 unit to prevent overflow kDrev = 1 / kD kDrev = (kD < 1 ? 1 : kDrev ) ; keeps 1/kD < 1 ; A/E/D - CORRELATION iDcorr_A = iADcorr * sin(iA_dev * 0.01745329252) ; correlation of angle and distance by sinus of the position of the sound (angle - converted in radians) iDcorr_E = iEDcorr * sin(iE_dev * 0.01745329252) ; correlation of angle and elevation by sinus of the position of the sound (elevation - converted in radians) kD = kD + iDcorr_A + iDcorr_E ; correlating distance with angle and/or elevation ; AMPLITUDE AND FREQUENCY MODIFICATION BY POSITION indx_A divz iA_dev * iA_modctrl, iA_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Anglemodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_E divz iE_dev * iE_modctrl, iE_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Elevationmodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_D divz iD_dev * iD_modctrl, iD_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Distancemodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_A = indx_A * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_A table abs(indx_A), icrtlfn, 1 ; reading out the control factor from the function-table regarding angle iampfreqmod_A = (indx_A < 0 ? 1- (iampfreqmod_A * 0.5) : iampfreqmod_A + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification indx_E = indx_E * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_E table abs(indx_E), icrtlfn, 1 ; reading out the control factor from the function-table regarding elevation iampfreqmod_E = (indx_E < 0 ? 1- (iampfreqmod_E * 0.5) : iampfreqmod_E + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification indx_D = indx_D * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_D table abs(indx_D), icrtlfn, 1 ; reading out the control factor from the function-table regarding distance iampfreqmod_D = (indx_D < 0 ? 1- (iampfreqmod_D * 0.5) : iampfreqmod_D + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification ;0,5-2 0,5 | 2 + 0,5 | 2 + 0,5 | 2 imodfact = (iampfreqmod_A + iampfreqmod_E + iampfreqmod_D) / 3; adding up angle, elevation and distance partial of modification and calculating the average of them iampdev = iampdev * (1 - iampctrl) + iampdev * imodfact^2 * iampctrl ; altering amplitude by ammount of A,E or D deviation ifreqdev = ifreqdev * (1 - ifreqctrl) + ifreqdev * imodfact^2 * ifreqctrl ; altering frequency by ammount of A,E or D deviation ; ****************************************************************************** ; SOUND PRODUCTION ; ****************************************************************************** adry subinstr iinst, iampdev, ifreqdev, idurprolong ; invocation of the sound generating instrument adry = adry * girescale ; scaling of signal ; ****************************************************************************** ; ENVELOPE ; ****************************************************************************** aenv subinstr ienvinst, idurprolong ; invocation of the the envelope generator asig = adry * aenv ; apply envelope to the signal ; APPLICATION OF DOPPLER EFFECT ; Note: giunit = distance from a listener in the middle to the unit sphere in meters asig doppler asig, kD * giunit, 0, 345, 6 ; application of doppler effect ; FILTERING UNIT [distance] afilt butterlp asig, 22000 * sqrt(kDrev) ; filtering according to distance asig balance afilt, asig ; DIFFUSE EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. diffref: if gidiffref == 0 goto specref ; skip (switch off) the diffuse reflections || kcontrol == 0 Diffuse_Early_Reflections_zak asig, kA, kE, kD ; read in UDO ; SPECULAR EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. specref: if gispecref == 0 goto scaling ; skip (switch off) the specular reflections || kcontrol == 0 Specular_Early_Reflections_zak asig, kA, kE, kD ; read in UDO scaling: ; SCALING AND DELAYING UNIT ; this unit is based upon the example in the Charles Dodge/Thomas Jerse book, Computer Music, page 320 ; attenuation according to distance and ratio of reverberation/direct signal according to distance is applied to the sound material of each track. ; SCALING ACCORDING TO DISTANCE FOR ATTENUATION AND LOCAL + GLOBAL REVERB -SEND arevsend = asig * sqrt(kDrev) * gireverbsend ; scaling for reverb according to distance and gaincontrol asig = asig * kDrev ; scaling of signal acording to distance irevdel = giunit * gifrontwall * 0.00293255132 ; caculation of time of a reflection (reverb) traveling from the wall to the center [s] arevsend delay arevsend, irevdel ; feeding a delayed signal to global reverbsend to simulate the size of the room ; by delaying the response of the room according to its size aglrevsend = arevsend * kDrev ; ratio between global and local reverb zaw aglrevsend, 0 ; global reverb send gets written to Zak-channel 0 ; LOCAL REVERB if gilocalrev = 0 goto encoding; no local reverb send if localreverb is switched off arevsig = arevsend * (1 - kDrev) ; ratio between global and local reverb aeffL, aeffR reverbsc arevsig, arevsig, girvbdecay, gicutofffreq, sr, girandpchmod, 1 ; apply local reverb arevsig = aeffL + aeffR asig = arevsig + asig print gilocalrev encoding: ; ENCODING + OUTPUT UNIT Encoding_2nd_3rd_Order_zak asig, kA, kE ; read in UDO end: Angle 62 77 true -360.0 360.0 1.0 1.0 300 true 131 383 Elevation 254 77 true -90.0 90.0 1.0 0.0 300 true 314 384 Distance 446 77 true 0.3 15.0 0.1 1.2 300 true 510 386 Angle_mod_ctrl 63 466 true -1.0 1.0 0.05 1.0 150 true 65 656 Elevation_mod_ctrl 257 466 true -1.0 1.0 0.05 -0.050000012 150 true 257 655 Distance_mod_ctrl 451 466 true -1.0 1.0 0.05 -0.050000012 150 true 450 656 Distance_Correlation 697 127 true 200 200 0.0 3.0 0.0 3.0 0.015 0.0 true freqdevmixctrl 54 757 true 0.0 1.0 0.1 0.0 200 true 56 789 ampdevmixctrl 385 757 true 0.0 1.0 0.1 1.0 200 true 384 789 654 211 904 210 769 92 764 341 740 361 678 228 791 320 905 227 793 111 Copy_ampattenuation 838 474 true 0.0 1.0 0.5508675 80 true Copy_frequencyshift 704 474 true 0.5 2.0 1.0179162 80 true 657 582 824 584 SPATIAL XYZ GRANULATOR (complex) ; COPYING UNIT icpydel = p18 ; delay of copy [s] imaxcnt = p19 ; maximum number of copies icnt = p20 ; count of number of copys, has to be "0" at the score icpyampatt init 1 ; initialisation of the variable responsible for attenuation of a copy icpyfreqshift init 1 ; initialisation of the variable responsible for shift of frequency of a copy if icnt != 0 goto endcopy ; skip creation of a copy if this instance of the instrument is already a copy or if no copies are requested if imaxcnt == 0 goto nocopy ; no creation of a copy if maximum number of copies = 0 copy: icnt = icnt + 1 ; count the number of copies if icnt > imaxcnt goto nocopy ; stop copying if the maximum number of copies is reached icpyampatt = i(<Copy_ampattenuation>) ^ icnt ; atennuate each copy by this factor icpyfreqshift = i(<Copy_frequencyshift>) ^ icnt ; shift the frequency of each copy by this factor icpydelay = icpydel * icnt ; shift the start time of each copy by the amount of icpydelay iXcpydev = p21 * icnt ; shift the angle of each copy by the amount of iAcpydev iYcpydev = p22 * icnt ; shift the elevation of each copy by the amount of iAcpydev iZcpydev = p23 * icnt ; shift the distance of each copy by the amount of iAcpydev schedule p1, icpydelay, p3, p4, p5 * icpyampatt, p6* icpyfreqshift, p7, p8 + iXcpydev, p9 + iYcpydev, p10 + iZcpydev, p11, p12, p13, p14, p15 , p16, p17, p18, p19, icnt, p21, p22, p23 ; generate the copy goto copy endcopy: nocopy: ; INSTRUMENT idur = p3 ; duration iinst = p4 ; instrument number of sound producing instrument iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ienvinst = p7 ; instrument number of envelope instrument iX_dev = p8 ; deviation of position of grain - angle [¡] (amount of schifting of copy included) iY_dev = p9 ; deviation of position of grain - elevation [¡] (amount of schifting of copy included) iZ_dev = p10 ; deviation of position of grain - distance [unit] (amount of schifting of copy included) iX_move = p11 ; amount of movement of a single grain in regard to the cloud [¡] iY_move = p12 ; amount of movement of a single grain in regard to the cloud [¡] iZ_move = p13 ; amount of movement of a single grain in regard to the cloud [unit] iX_range = p14 ; possible range of deviation of angle [¡] iY_range = p15 ; possible range of deviation of elevation [¡] iZ_range = p16 ; possible range of deviation of distance [unit] icrtlfn = p17 ; control distribution fn kX_centre = <X-position> ; position (centre) of the cloud at the X-axis [unit] kY_centre = <Y-position> ; position (centre) of the cloud at the Y-axis [unit] kZ_centre = <Z-position> ; position (centre) of the cloud at the Z-axis [unit] iA_modctrl = i(<Angle_mod_ctrl>) ; angle modification controller [0 = no correlation; 1 = full correlation regarding angle] iE_modctrl = i(<Elevation_mod_ctrl>) ; elevation modification controller [0 = no correlation; 1 = full correlation regarding elevation] iD_modctrl = i(<Distance_mod_ctrl>) ; distance modification controller [0 = no correlation; 1 = full correlation regarding distance] ifreqctrl = i(<freqdevmixctrl>) ; ifreq dev mix controller [0= frequency as assigned, 1= frequency according to position] iampctrl = i(<ampdevmixctrl>) ; iamp dev mix controller [0= amplitude as assigned, 1= amplitude according to position] iADcorr = i(<Distance_CorrelationX>) ; angle-distance correllation factor [0 = no correlation; 1 = full correlation between angle and distance] iEDcorr = i(<Distance_CorrelationY>) ; elevation-distance correllation factor [0 = no correlation; 1 = full correlation between elevation and distance] ; INSTRUMENT PROLONGATION idurprolong = gidurprolong ; extra duration for reverb tail of local reverb p3 = p3 + idurprolong ; add extra duration to this instrument ; CALCULATION OF LOCATION kX_move line 0, idur, iX_move ; creation of a trajectory of the grain during note kY_move line 0, idur, iY_move ; creation of a trajectory of the grain during note kZ_move line 0, idur, iZ_move ; creation of a trajectory of the grain during note kX = kX_centre + kX_move + iX_dev ; adding up movement of the cloud with deviation and movement of the grain kY = kY_centre + kY_move + iY_dev ; adding up movement of the cloud with deviation and movement of the grain kZ = kZ_centre + kZ_move + iZ_dev ; adding up movement of the cloud with deviation and movement of the grain ; CONVERSION OF X, Y, Z iX_centre = i(kX_centre) ; x-position of the clout at init-time iY_centre = i(kY_centre) ; Y-position of the clout at init-time iZ_centre = i(kZ_centre) ; z-position of the clout at init-time iX_range = iX_centre + iX_range ; adding the range in x-direction to the specific position of the cloud iY_range = iY_centre + iY_range ; adding the range in y-direction to the specific position of the cloud iZ_range = iZ_centre + iZ_range ; adding the range in z-direction to the specific position of the cloud iX_dev = iX_centre + iX_dev ; adding the deviation in x-direction to the specific position of the cloud iY_dev = iY_centre + iY_dev ; adding the deviation in y-direction to the specific position of the cloud iZ_dev = iZ_centre + iZ_dev ; adding the deviation in z-direction to the specific position of the cloud iA_centre, iE_centre, iD_centre XYZ_Conversion_i_time iX_centre, iY_centre, iZ_centre ;conversion of initial (centre) position of the cloud from carthesian to polar coordinates iA_range, iE_range, iD_range XYZ_Conversion_i_time iX_range, iY_range, iZ_range ;conversion of possible range of the postion of the sound from carthesian to polar coordinates iA_dev, iE_dev, iD_dev XYZ_Conversion_i_time iX_dev, iY_dev, iZ_dev ;conversion of deviation of the postion of the sound from carthesian to polar coordinates iA_range = abs(iA_centre - iA_range) ; calculation of the maximum range at the specific position of the cloud iE_range = abs(iE_centre - iE_range) ; calculation of the maximum range at the specific position of the cloud iD_range = abs(iD_centre - iD_range) ; calculation of the maximum range at the specific position of the cloud iA_dev = iA_dev - iA_centre ; calculation of the deviation at the specific position of the cloud iE_dev = iE_dev - iE_centre ; calculation of the deviation at the specific position of the cloud iD_dev = iD_dev - iD_centre ; calculation of the deviation at the specific position of the cloud kA, kE, kD XYZ_Conversion_k_time kX, kY, kZ ;conversion of the position of the cloud from carthesian to polar coordinates kD = (kD < 0.3 ? 0.3 : kD ) ; limits kD to a minimum of 0.3 unit to prevent overflow kDrev = 1 / kD kDrev = (kD < 1 ? 1 : kDrev ) ; keeps 1/kD < 1 ; A/E/D - CORRELATION iDcorr_A = iADcorr * sin(iA_dev * 0.01745329252) ; correlation of angle and distance by sinus of the position of the sound (angle - converted in radians) iDcorr_E = iEDcorr * sin(iE_dev * 0.01745329252) ; correlation of angle and elevation by sinus of the position of the sound (elevation - converted in radians) kD = kD + iDcorr_A + iDcorr_E ; correlating distance with angle and/or elevation ; AMPLITUDE AND FREQUENCY MODIFICATION BY POSITION indx_A divz iA_dev * iA_modctrl, iA_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Anglemodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_E divz iE_dev * iE_modctrl, iE_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Elevationmodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_D divz iD_dev * iD_modctrl, iD_range, 0.01 ; calculation of sound location within the "range" and controling the signal by an "Distancemodificationconrol" -slider. Negative values of the slider cause the deviation to be flipped indx_A = indx_A * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_A table abs(indx_A), icrtlfn, 1 ; reading out the control factor from the function-table regarding angle iampfreqmod_A = (indx_A < 0 ? 1- (iampfreqmod_A * 0.5) : iampfreqmod_A + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification indxE = indx_E * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_E table abs(indx_E), icrtlfn, 1 ; reading out the control factor from the function-table regarding elevation iampfreqmod_E = (indx_E < 0 ? 1- (iampfreqmod_E * 0.5) : iampfreqmod_E + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification indx_D = indx_D * 0.999999 ; reducing the index slightly to prevent "flipping over" iampfreqmod_D table abs(indx_D), icrtlfn, 1 ; reading out the control factor from the function-table regarding distance iampfreqmod_D = (indx_D < 0 ? 1- (iampfreqmod_D * 0.5) : iampfreqmod_D + 1) ; transformation of iampfreqctrl_A to range between 0.5 and 2 for amplitude and frequencymodification imodfact = (iampfreqmod_A + iampfreqmod_E + iampfreqmod_D) / 3; adding up angle, elevation and distance partial of modification and calculating the average of them iampdev = iampdev * (1 - iampctrl) + iampdev * imodfact^2 * iampctrl ; altering amplitude by ammount of A,E or D deviation ifreqdev = ifreqdev * (1 - ifreqctrl) + ifreqdev * imodfact^2 * ifreqctrl ; altering frequency by ammount of A,E or D deviation ; ****************************************************************************** ; SOUND PRODUCTION ; ****************************************************************************** adry subinstr iinst, iampdev, ifreqdev, idurprolong ; invocation of the sound generating instrument adry = adry * girescale ; scaling of signal ; ****************************************************************************** ; ENVELOPE ; ****************************************************************************** aenv subinstr ienvinst, idurprolong ; invocation of the the envelope generator asig = adry * aenv ; apply envelope to the signal ; APPLICATION OF DOPPLER EFFECT ; Note: giunit = distance from a listener in the middle to the unit sphere in meters asig doppler asig, kD * giunit, 0, 345, 6 ; application of doppler effect ; FILTERING UNIT [distance] afilt butterlp asig, 22000 * sqrt(kDrev) ; filtering according to distance asig balance afilt, asig ; DIFFUSE EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. diffref: if gidiffref == 0 goto specref ; skip (switch off) the diffuse reflections || kcontrol == 0 Diffuse_Early_Reflections_zak asig, kA, kE, kD ; read in UDO ; SPECULAR EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. specref: if gispecref == 0 goto scaling ; skip (switch off) the specular reflections || kcontrol == 0 Specular_Early_Reflections_zak asig, kA, kE, kD ; read in UDO scaling: ; SCALING AND DELAYING UNIT ; this unit is based upon the example in the Charles Dodge/Thomas Jerse book, Computer Music, page 320 ; attenuation according to distance and ratio of reverberation/direct signal according to distance is applied to the sound material of each track. ; SCALING ACCORDING TO DISTANCE FOR ATTENUATION AND LOCAL + GLOBAL REVERB -SEND arevsend = asig * sqrt(kDrev) * gireverbsend ; scaling for reverb according to distance and gaincontrol asig = asig * kDrev ; scaling of signal acording to distance irevdel = giunit * gifrontwall * 0.00293255132 ; caculation of time of a reflection (reverb) traveling from the wall to the center [s] arevsend delay arevsend, irevdel ; feeding a delayed signal to global reverbsend to simulate the size of the room ; by delaying the response of the room according to its size aglrevsend = arevsend * kDrev ; ratio between global and local reverb zaw aglrevsend, 0 ; global reverb send gets written to Zak-channel 0 ; LOCAL REVERB if gilocalrev = 0 goto encoding; no local reverb send if localreverb is switched off arevsig = arevsend * (1 - kDrev) ; ratio between global and local reverb aeffL, aeffR reverbsc arevsig, arevsig, girvbdecay, gicutofffreq, sr, girandpchmod, 1 ; apply local reverb arevsig = aeffL + aeffR asig = arevsig + asig print gilocalrev encoding: ; ENCODING + OUTPUT UNIT Encoding_2nd_3rd_Order_zak asig, kA, kE ; read in UDO end: X-position 63 45 true -20.0 20.0 0.2 0.80000114 300 true 138 357 Y-position 286 48 true -20.0 20.0 0.2 -0.19999886 300 true 358 356 Z-position 510 48 true -20.0 20.0 0.2 -0.19999886 300 true 586 359 Angle_mod_ctrl 65 439 true -1.0 1.0 0.05 1.0 150 true 70 628 Elevation_mod_ctrl 287 440 true -1.0 1.0 0.05 -0.050000012 150 true 290 628 Distance_mod_ctrl 510 440 true -1.0 1.0 0.05 -0.050000012 150 true 505 628 Distance_Correlation 791 97 true 200 200 0.0 3.0 0.0 3.0 0.0 0.0 false freqdevmixctrl 62 705 true 0.0 1.0 0.1 1.0 200 true 62 738 ampdevmixctrl 461 706 true 0.0 1.0 0.1 0.0 200 true 460 739 747 182 998 180 862 62 858 310 833 331 771 198 885 289 999 197 885 81 Copy_ampattenuation 909 434 true 0.0 1.0 0.5508675 80 true Copy_frequencyshift 784 433 true 0.5 2.0 1.0175618 80 true 741 540 903 540 SIMPLE SPATIAL AED-GRANULATOR idur = p3 ; duration iinst = p4 ; instrument number of sound producing instrument iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ienvinst = p7 ; instrument number of envelope instrument iA_dev = p8 ; deviation of position of grain - angle [¡] iE_dev = p9 ; deviation of position of grain - elevation [¡] iD_dev = p10 ; deviation of position of grain - distance [unit] iA_move = p11 ; amount of movement of a single grain in regard to the cloud [¡] iE_move = p12 ; amount of movement of a single grain in regard to the cloud [¡] iD_move = p13 ; amount of movement of a single grain in regard to the cloud [unit] kA_centre = <Angle> ; position (centre) of the cloud - angle [¡] kE_centre = <Elevation> ; position (centre) of the cloud - elevation [¡] kD_centre = <Distance> ; position (centre) of the cloud - distance [unit] ; INSTRUMENT PROLONGATION idurprolong = gidurprolong ; extra duration for reverb tail of local reverb p3 = p3 + idurprolong ; add extra duration to this instrument ; CALCULATION OF CHANGE OF POSITION DUE TO VELOCITY kA_grain line iA_dev, idur, iA_dev + iA_move ; creation of a trajectory of the grain during note kE_grain line iE_dev, idur, iE_dev + iE_move ; creation of a trajectory of the grain during note kD_grain line iD_dev, idur, iD_dev + iD_move ; creation of a trajectory of the grain during note kA = kA_centre + kA_grain ; adding up movement of the cloud and movement of the grain kE = kE_centre + kE_grain ; adding up movement of the cloud and movement of the grain kD = kD_centre + kD_grain ; adding up movement of the cloud and movement of the grain kD = (kD < 0.3 ? 0.3 : kD) ; limits kD to a minimum of 0.3 unit to prevent overflow kDrev = 1 / kD kDrev = (kD < 1 ? 1 : kDrev ) ; keeps 1/kD < 1 ; ****************************************************************************** ; SOUND PRODUCTION ; ****************************************************************************** adry subinstr iinst, iampdev, ifreqdev, idurprolong ; invocation of the sound generating instrument adry = adry * girescale ; scaling of signal ; ****************************************************************************** ; ENVELOPE ; ****************************************************************************** aenv subinstr ienvinst, idurprolong ; invocation of the the envelope generator asig = adry * aenv ; apply envelope to the signal ; APPLICATION OF DOPPLER EFFECT ; Note: giunit = distance from a listener in the middle to the unit sphere in meters asig doppler asig, kD * giunit, 0 ; application of doppler effect ; FILTERING UNIT [distance] afilt butterlp asig, 22000 * sqrt(kDrev) ; filtering according to distance asig balance afilt, asig ; DIFFUSE EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. diffref: if gidiffref == 0 goto specref ; skip (switch off) the diffuse reflections Diffuse_Early_Reflections_zak asig, kA, kE, kD ; read in UDO ; SPECULAR EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. specref: if gispecref == 0 goto scaling ; skip (switch off) the specular reflections Specular_Early_Reflections_zak asig, kA, kE, kD ; read in UDO scaling: ; SCALING AND DELAYING UNIT ; this unit is based upon the example in the Charles Dodge/Thomas Jerse book, Computer Music, page 320 ; attenuation according to distance and ratio of reverberation/direct signal according to distance is applied to the sound material of each track. ; SCALING ACCORDING TO DISTANCE FOR ATTENUATION AND LOCAL + GLOBAL REVERB -SEND arevsend = asig * sqrt(kDrev) * gireverbsend ; scaling for reverb according to distance and gaincontrol asig = asig * kDrev ; scaling of signal acording to distance irevdel = giunit * gifrontwall * 0.00293255132 ; caculation of time of a reflection (reverb) traveling from the wall to the center [s] arevsend delay arevsend, irevdel ; feeding a delayed signal to global reverbsend to simulate the size of the room ; by delaying the response of the room according to its size aglrevsend = arevsend * kDrev ; ratio between global and local reverb zaw aglrevsend, 0 ; global reverb send gets written to Zak-channel 0 ; LOCAL REVERB if gilocalrev = 0 goto encoding; no local reverb send if localreverb is switched off arevsig = arevsend * (1 - kDrev) ; ratio between global and local reverb aeffL, aeffR reverbsc arevsig, arevsig, girvbdecay, gicutofffreq, sr, girandpchmod, 1 ; apply local reverb arevsig = aeffL + aeffR asig = arevsig + asig print gilocalrev encoding: ; ENCODING + OUTPUT UNIT Encoding_2nd_3rd_Order_zak asig, kA, kE ; read in UDO end: Angle 54 49 true -360.0 360.0 1.0 1.0 300 true 128 356 Elevation 355 49 true -90.0 90.0 1.0 0.0 300 true 436 356 Distance 657 49 true 0.3 15.0 0.1 1.2 300 true 740 355 SIMPLE SPATIAL XYZ-GRANULATOR idur = p3 ; duration iinst = p4 ; instrument number of sound producing instrument iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ienvinst = p7 ; instrument number of envelope instrument iX_dev = p8 ; deviation of position of grain - angle [¡] iY_dev = p9 ; deviation of position of grain - elevation [¡] iZ_dev = p10 ; deviation of position of grain - distance [unit] iX_move = p11 ; ammount of movement of a single grain in regard to the cloud [unit] iY_move = p12 ; ammount of movement of a single grain in regard to the cloud [unit] iZ_move = p13 ; ammount of movement of a single grain in regard to the cloud [unit] kX_centre = <X-position> ; position (centre) of the cloud at the X-axis [unit] kY_centre = <Y-position> ; position (centre) of the cloud at the Y-axis [unit] kZ_centre = <Z-position> ; position (centre) of the cloud at the Z-axis [unit] ; INSTRUMENT PROLONGATION idurprolong = gidurprolong ; extra duration for reverb tail of local reverb p3 = p3 + idurprolong ; add extra duration to this instrument ; CALCULATION OF LOCATION kX_move line 0, idur, iX_move ; creation of a trajectory of the grain during note kY_move line 0, idur, iY_move ; creation of a trajectory of the grain during note kZ_move line 0, idur, iZ_move ; creation of a trajectory of the grain during note kX = kX_centre + kX_move + iX_dev ; adding up movement of the cloud with deviation and movement of the grain kY = kY_centre + kY_move + iY_dev ; adding up movement of the cloud with deviation and movement of the grain kZ = kZ_centre + kZ_move + iZ_dev ; adding up movement of the cloud with deviation and movement of the grain ; CONVERSION OF X, Y, Z kA, kE, kD XYZ_Conversion_k_time kX, kY, kZ ;conversion of the position of the cloud from carthesian to polar coordinates kD = (kD < 0.3 ? 0.3 : kD ) ; limits kD to a minimum of 0.3 unit to prevent overflow kDrev = 1 / kD kDrev = (kD < 1 ? 1 : kDrev ) ; keeps 1/kD < 1 ; ****************************************************************************** ; SOUND PRODUCTION ; ****************************************************************************** adry subinstr iinst, iampdev, ifreqdev, idurprolong ; invocation of the sound generating instrument adry = adry * girescale ; scaling of signal ; ****************************************************************************** ; ENVELOPE ; ****************************************************************************** aenv subinstr ienvinst, idurprolong ; invocation of the the envelope generator asig = adry * aenv ; apply envelope to the signal ; APPLICATION OF DOPPLER EFFECT ; Note: giunit = distance from a listener in the middle to the unit sphere in meters asig doppler asig, kD * giunit, 0, 345, 6 ; application of doppler effect ; FILTERING UNIT [distance] afilt butterlp asig, 22000 * sqrt(kDrev) ; filtering according to distance asig balance afilt, asig ; DIFFUSE EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. diffref: if gidiffref == 0 goto specref ; skip (switch off) the diffuse reflections || kcontrol == 0 Diffuse_Early_Reflections_zak asig, kA, kE, kD ; read in UDO ; SPECULAR EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. specref: if gispecref == 0 goto scaling ; skip (switch off) the specular reflections || kcontrol == 0 Specular_Early_Reflections_zak asig, kA, kE, kD ; read in UDO scaling: ; SCALING AND DELAYING UNIT ; this unit is based upon the example in the Charles Dodge/Thomas Jerse book, Computer Music, page 320 ; attenuation according to distance and ratio of reverberation/direct signal according to distance is applied to the sound material of each track. ; SCALING ACCORDING TO DISTANCE FOR ATTENUATION AND LOCAL + GLOBAL REVERB -SEND arevsend = asig * sqrt(kDrev) * gireverbsend ; scaling for reverb according to distance and gaincontrol asig = asig * kDrev ; scaling of signal acording to distance irevdel = giunit * gifrontwall * 0.00293255132 ; caculation of time of a reflection (reverb) traveling from the wall to the center [s] arevsend delay arevsend, irevdel ; feeding a delayed signal to global reverbsend to simulate the size of the room ; by delaying the response of the room according to its size aglrevsend = arevsend * kDrev ; ratio between global and local reverb zaw aglrevsend, 0 ; global reverb send gets written to Zak-channel 0 ; LOCAL REVERB if gilocalrev = 0 goto encoding; no local reverb send if localreverb is switched off arevsig = arevsend * (1 - kDrev) ; ratio between global and local reverb aeffL, aeffR reverbsc arevsig, arevsig, girvbdecay, gicutofffreq, sr, girandpchmod, 1 ; apply local reverb arevsig = aeffL + aeffR asig = arevsig + asig print gilocalrev encoding: ; ENCODING + OUTPUT UNIT Encoding_2nd_3rd_Order_zak asig, kA, kE ; read in UDO end: X-position 45 46 true -20.0 20.0 0.2 0.80000114 300 true 120 352 Y-position 346 48 true -20.0 20.0 0.2 -0.19999886 300 true 428 355 Z-position 648 49 true -20.0 20.0 0.2 -0.19999886 300 true 728 354 SIMPLE SPATIAL AED-PLAYER itime = p2 ; start time of grain idur = p3 ; duration iinst = p4 ; instrument number of sound producing instrument iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ienvinst = p7 ; instrument number of envelope instrument idurprolong = gidurprolong ; extra duration for reverb tail of local reverb p3 = p3 + idurprolong ; add extra duration to this instrument ; CALCULATION OF CHANGE OF POSITION DUE TO VELOCITY kA = <angle> kE = <elevation> kD = <distance> ; LIMITING PROXIMITY TO PREVENT OVERFLOW kD = (kD < 0.3 ? 0.3 : kD) ; limits kD to a minimum of 0.3 unit to prevent overflow kDrev = 1 / kD kDrev = (kD < 1 ? 1 : kDrev ) ; keeps 1/kD < 1 ; ****************************************************************************** ; SOUND PRODUCTION ; ****************************************************************************** adry subinstr iinst, iampdev, ifreqdev, idurprolong ; invocation of the sound generating instrument adry = adry * girescale ; scaling of signal ; ****************************************************************************** ; ENVELOPE ; ****************************************************************************** aenv subinstr ienvinst, idurprolong ; invocation of the the envelope generator asig = adry * aenv ; apply envelope to the signal ; FILTERING UNIT [distance] afilt butterlp asig, 22000 * sqrt(kDrev) ; filtering according to distance asig balance afilt, asig ; REFLECTIONS UNIT envfollow: acontrol follow2 asig, 0.0000001, 0.1 ; checks for periods of sound / silence to switch off the reflections kcontrol downsamp acontrol ; downsampling to k-rate ; DIFFUSE EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. diffref: if gidiffref == 0 || kcontrol == 0 goto specref ; skip (switch off) the diffuse reflections Diffuse_Early_Reflections_zak asig, kA, kE, kD ; read in UDO ; SPECULAR EARLY REFLECTIONS conceived and coded 1999-2001 by Jan Jacob Hofmann, using the Furse-Malham-Set (FMH) of encoding equations. specref: if gispecref == 0 || kcontrol == 0 goto scaling ; skip (switch off) the specular reflections Specular_Early_Reflections_zak asig, kA, kE, kD ; read in UDO scaling: ; SCALING AND DELAYING UNIT ; this unit is based upon the example in the Charles Dodge/Thomas Jerse book, Computer Music, page 320 ; attenuation according to distance and ratio of reverberation/direct signal according to distance is applied to the sound material of each track. ; SCALING ACCORDING TO DISTANCE FOR ATTENUATION AND LOCAL + GLOBAL REVERB -SEND arevsend = asig * sqrt(kDrev) * gireverbsend ; scaling for reverb according to distance and gaincontrol asig = asig * kDrev ; scaling of signal acording to distance irevdel = giunit * gifrontwall * 0.00293255132 ; caculation of time of a reflection (reverb) traveling from the wall to the center [s] arevsend delay arevsend, irevdel ; feeding a delayed signal to global reverbsend to simulate the size of the room ; by delaying the response of the room according to its size aglrevsend = arevsend * kDrev ; ratio between global and local reverb zaw aglrevsend, 0 ; global reverb send gets written to Zak-channel 0 ; LOCAL REVERB if gilocalrev = 0 || kcontrol == 0 goto encoding ; no local reverb send if localreverb is switched off arevsig = arevsend * (1 - kDrev) ; ratio between global and local reverb aeffL, aeffR reverbsc arevsig, arevsig, girvbdecay, gicutofffreq, sr, girandpchmod, 1 ; apply local reverb arevsig = aeffL + aeffR asig = arevsig + asig print gilocalrev encoding: ; ENCODING + OUTPUT UNIT Encoding_2nd_3rd_Order_zak asig, kA, kE ; read in UDO end: angle 73 137 true -360.0 360.0 1.0 206.67848 300 true 34 487 elevation 255 137 true -90.0 90.0 1.0 1.0 300 true 216 486 distance 461 141 true 0.3 10.0 0.1 2.3300982 300 true 422 490 SPATIAL GLOBAL REVERB conceived and coded 1999-2005 by Jan Jacob Hofmann #define GLOBALREVERBENCODING(W) # kchnlw = 0.707107 kchnlx = cos(iA$W.) * cos(iE$W.) kchnly = sin(iA$W.) * cos(iE$W.) kchnlz = sin(iE$W.) kchnlr = 1.5 * sin(iE$W.) * sin(iE$W.) -0.5 kchnls = cos(iA$W.) * sin(2 * iE$W.) kchnlt = sin(iA$W.) * sin(2 * iE$W.) kchnlu = cos(2 * iA$W.) * cos(iE$W.) * cos(iE$W.) kchnlv = sin(2 * iA$W.) * cos(iE$W.) * cos(iE$W.) aw = afilt$W. * kchnlw ;(A,E) ax = afilt$W. * kchnlx ;(A,E) ay = afilt$W. * kchnly ;(A,E) az = afilt$W. * kchnlz ;(A,E) ar = afilt$W. * kchnlr ;(A,E) as = afilt$W. * kchnls ;(A,E) at = afilt$W. * kchnlt ;(A,E) au = afilt$W. * kchnlu ;(A,E) av = afilt$W. * kchnlv ;(A,E) zawm aw, 1 ; rewrite and mix zak-location 1 with ambisonics w-channel output of spatial global reverb zawm ax, 2 ; rewrite and mix zak-location 2 with ambisonics x-channel output of spatial global reverb zawm ay, 3 ; rewrite and mix zak-location 3 with ambisonics y-channel output of spatial global reverb zawm az, 4 ; rewrite and mix zak-location 4 with ambisonics z-channel output of spatial global reverb zawm ar, 5 ; rewrite and mix zak-location 5 with ambisonics r-channel output of spatial global reverb zawm as, 6 ; rewrite and mix zak-location 6 with ambisonics s-channel output of spatial global reverb zawm at, 7 ; rewrite and mix zak-location 7 with ambisonics t-channel output of spatial global reverb zawm au, 8 ; rewrite and mix zak-location 8 with ambisonics u-channel output of spatial global reverb zawm av, 9 ; rewrite and mix zak-location 9 with ambisonics v-channel output of spatial global reverb # ; ****************************************************************************************************** ; using the Furse-Malham-Set (FMH) of encoding equations. ; ****************************************************************************************************** ;girvbdecay ; gain of reverb. Adjust empirically ; for desired reverb time. .6 gives ; a good small "live" room sound, .8 ; a small hall, .9 a large hall, ; .99 an enormous stone cavern. ;girandpchmod ; amount of random pitch modulation ; for the delay lines. 1 is the "normal" ; amount, but this may be too high for ; held pitches such as piano tones. ; Adjust to taste. ;gicutofffreq ; Cutoff frequency of lowpass filters ; in feedback loops of delay lines, ; in Hz. Lower cutoff frequencies results ; in a sound with more high-frequency ; damping. arevsig zar 0 ; reading global reverb send as written to Zak-channel 0 in instr. 50 afilt1, afilt2, afilt3, afilt4, afilt5, afilt6, afilt7, afilt8, afilt9, afilt10, afilt11, afilt12 Spatial_Global_Reverb arevsig, girvbdecay, girandpchmod, gicutofffreq ; iA1-iA12 are the angles pointing to the 12 corners of an ikosaeder ; iE1-iE12 are the elevations pointing to the 12 corners of an ikosaeder iA1 = 0 ; angle reverberant point 1 iA2 = 0.6238 ; angle reverberant point 2 iA3 = 1.2566 ; angle reverberant point 3 iA4 = 1.8849 ; angle reverberant point 4 iA5 = 2.5132 ; angle reverberant point 5 iA6 = 3.1415 ; angle reverberant point 6 iA7 = 3.7699 ; angle reverberant point 7 iA8 = 4.3982 ; angle reverberant point 8 iA9 = 5.0265 ; angle reverberant point 9 iA10 = 5.6548 ; angle reverberant point 10 iA11 = 0 ; angle reverberant point 11 iA12 = 0 ; angle reverberant point 12 iE1 = 0.463646 ; height reverberant point 1 ( 26.565¡) iE2 = -0.463646 ; height reverberant point 2 ( -26.565¡) iE3 = 0.463646 ; height reverberant point 3 ( 26.565¡) iE4 = -0.463646 ; height reverberant point 4 ( -26.565¡) iE5 = 0.463646 ; height reverberant point 5 ( 26.565¡) iE6 = -0.463646 ; height reverberant point 6 ( -26.565¡) iE7 = 0.463646 ; height reverberant point 7 ( 26.565¡) iE8 = -0.463646 ; height reverberant point 8 ( -26.565¡) iE9 = 0.463646 ; height reverberant point 9 ( 26.565¡) iE10 = -0.463646 ; height reverberant point 10 ( -26.565¡) iE11 = 1.570796 ; height reverberant point 11 ( 90¡) iE12 = -1.570796 ; height reverberant point 12 ( -90¡) $GLOBALREVERBENCODING(1) $GLOBALREVERBENCODING(2) $GLOBALREVERBENCODING(3) $GLOBALREVERBENCODING(4) $GLOBALREVERBENCODING(5) $GLOBALREVERBENCODING(6) $GLOBALREVERBENCODING(7) $GLOBALREVERBENCODING(8) $GLOBALREVERBENCODING(9) $GLOBALREVERBENCODING(10) $GLOBALREVERBENCODING(11) $GLOBALREVERBENCODING(12) #undef GLOBALREVERBENCODING(W) Spatial_Global_Reverb aaaaaaaaaaaa aiii ; 12 delay line FDN reverb, with feedback matrix based upon ; physical modeling scattering junction of 12 lossless waveguides ; of equal characteristic impedance. Based on Julius O. Smith III, ; "A New Approach to Digital Reverberation using Closed Waveguide ; Networks," Proceedings of the International Computer Music ; Conference 1985, p. 47-53 (also available as a seperate ; publication from CCRMA), as well as some more recent papers by ; Smith and others. ; ; Coded by Sean Costello, October 1999/ modified by Jan Jacob Hofmann August 2005 ; Note: arevsig is the global input to the reverb. setksmps 1 ; seting ksmps to 1 as feedback lines are used arevsig, irvbdecay, irandpchmod, icutofffreq xin afilt1 init 0 afilt2 init 0 afilt3 init 0 afilt4 init 0 afilt5 init 0 afilt6 init 0 afilt7 init 0 afilt8 init 0 afilt9 init 0 afilt10 init 0 afilt11 init 0 afilt12 init 0 ; Delay times chosen to be prime numbers. ; Works with sr=44100/ sr=48000 ONLY. If you wish to ; use a different delay time, find some new ; prime numbers that will give roughly the ; same delay times for the new sampling rate. ; Or adjust to taste. if sr = 48000 goto delaytime48000 ; delaytime chosen for sr=44100 idel1 = (1237.000/sr) idel2 = (1381.000/sr) idel3 = (1609.000/sr) idel4 = (1777.000/sr) idel5 = (1951.000/sr) idel6 = (2063.000/sr) idel7 = (1069.000/sr) idel8 = ( 967.000/sr) idel9 = (1889.000/sr) idel10 = (1693.000/sr) idel11 = (1453.000/sr) idel12 = (1291.000/sr) goto contin delaytime48000: ; delaytime for sr=48000 idel1 = (1361.000/sr) idel2 = (1499.000/sr) idel3 = (1753.000/sr) idel4 = (1933.000/sr) idel5 = (2129.000/sr) idel6 = (2243.000/sr) idel7 = (1163.000/sr) idel8 = (1051.000/sr) idel9 = (2053.000/sr) idel10 = (1693.000/sr) idel11 = (1847.000/sr) idel12 = (1409.000/sr) contin: igain = irvbdecay ; gain of reverb. Adjust empirically ; for desired reverb time. .6 gives ; a good small "live" room sound, .8 ; a small hall, .9 a large hall, ; .99 an enormous stone cavern. ipitchmod = irandpchmod ; amount of random pitch modulation ; for the delay lines. 1 is the "normal" ; amount, but this may be too high for ; held pitches such as piano tones. ; Adjust to taste. itone = icutofffreq ; Cutoff frequency of lowpass filters ; in feedback loops of delay lines, ; in Hz. Lower cutoff frequencies results ; in a sound with more high-frequency ; damping. ; k1-k8 are used to add random pitch modulation to the ; delay lines. Helps eliminate metallic overtones ; in the reverb sound. k1 randi .001, 3.1, .06 k2 randi .0011, 3.5, .9 k3 randi .0017, 1.11, .7 k4 randi .0006, 3.973, .3 k5 randi .001, 2.341, .63 k6 randi .0011, 1.897, .17 k7 randi .0017, 0.891, .19 k8 randi .0006, 3.221, .44 k9 randi .001, 1.891, .88 k10 randi .0011, 2.317, .95 k11 randi .0017, 1.091, .36 k12 randi .0006, 2.821, .41 ; apj is used to calculate "resultant junction pressure" for ; the scattering junction of e.g. 8 lossless waveguides ; of equal characteristic impedance. If you wish to ; add more delay lines, simply add them to the following ; equation, and replace the .25 by 2/N, where N is the ; number of delay lines. apj = .16666666667 * (afilt1 + afilt2 + afilt3 + afilt4 + afilt5 + afilt6 +afilt7 + afilt8 + afilt9 + afilt10 +afilt11 + afilt12) adum1 delayr 1 adel1 deltapi idel1 + k1 * ipitchmod delayw arevsig + apj - afilt1 adum2 delayr 1 adel2 deltapi idel2 + k2 * ipitchmod delayw arevsig + apj - afilt2 adum3 delayr 1 adel3 deltapi idel3 + k3 * ipitchmod delayw arevsig + apj - afilt3 adum4 delayr 1 adel4 deltapi idel4 + k4 * ipitchmod delayw arevsig + apj - afilt4 adum5 delayr 1 adel5 deltapi idel5 + k5 * ipitchmod delayw arevsig + apj - afilt5 adum6 delayr 1 adel6 deltapi idel6 + k6 * ipitchmod delayw arevsig + apj - afilt6 adum7 delayr 1 adel7 deltapi idel7 + k7 * ipitchmod delayw arevsig + apj - afilt7 adum8 delayr 1 adel8 deltapi idel8 + k8 * ipitchmod delayw arevsig + apj - afilt8 adum9 delayr 1 adel9 deltapi idel9 + k9 * ipitchmod delayw arevsig + apj - afilt9 adum10 delayr 1 adel10 deltapi idel10 + k10 * ipitchmod delayw arevsig + apj - afilt10 adum11 delayr 1 adel11 deltapi idel11 + k11 * ipitchmod delayw arevsig + apj - afilt11 adum12 delayr 1 adel12 deltapi idel12 + k12 * ipitchmod delayw arevsig + apj - afilt12 ; 1st order lowpass filters in feedback ; loops of delay lines. afilt1 tone adel1 * igain, itone afilt2 tone adel2 * igain, itone afilt3 tone adel3 * igain, itone afilt4 tone adel4 * igain, itone afilt5 tone adel5 * igain, itone afilt6 tone adel6 * igain, itone afilt7 tone adel7 * igain, itone afilt8 tone adel8 * igain, itone afilt9 tone adel9 * igain, itone afilt10 tone adel10 * igain, itone afilt11 tone adel11 * igain, itone afilt12 tone adel12 * igain, itone xout afilt1 , afilt2 , afilt3 , afilt4 , afilt5 , afilt6 , afilt7 , afilt8, afilt9 , afilt10 , afilt11 , afilt12 OUTPUT & DECODING UNIT, 3rd ORDER AMBISONICS coded 1999-2012 by Jan Jacob Hofmann. ; FURSE - MALHAM - SET OF EQUATIONS Thanks to Richard Furse and Dave Malham ; More sets of speaker- layouts may be discovered at ; http://www.muse.demon.co.uk/ref/speakers.html ; ***************************************************************************************************************** krelcoef = 1 ; 0-1 (0= Spherichal Harmonics; 1 = (Controlled Opposites) aw zar 1 ; zak ambisonics w-channel input ax zar 2 ; zak ambisonics x-channel input ay zar 3 ; zak ambisonics y-channel input az zar 4 ; zak ambisonics z-channel input ar zar 5 ; zak ambisonics s-channel input as zar 6 ; zak ambisonics t-channel input at zar 7 ; zak ambisonics u-channel input au zar 8 ; zak ambisonics v-channel input av zar 9 ; zak ambisonics w-channel input ak zar 10 ; zak ambisonics w-channel input al zar 11 ; zak ambisonics x-channel input am zar 12 ; zak ambisonics y-channel input an zar 13 ; zak ambisonics z-channel input ao zar 14 ; zak ambisonics s-channel input ap zar 15 ; zak ambisonics t-channel input aq zar 16 ; zak ambisonics t-channel input zacl 0, 16 ; clear all a-rate channels zkcl 0, 2 ; clear all k-rate channels idecchnls = int(gidecchnls) if idecchnls == 2 goto stereo ; goto 2chnl decode if idecchnls == 8 goto eight ; goto 8chnl decode ; UNIT FOR WRITING 9 2ND ORRDER / 16 3RD ORDER AMBISONIC ENCODED SOUNDFILES ; ************************************************************************************** kpeak1 peak aw kpeak2 peak ax kpeak3 peak ay kpeak4 peak az kpeak5 peak ar kpeak6 peak as kpeak7 peak at kpeak8 peak au kpeak9 peak av printk p3 - 2, kpeak1,0 printk p3 - 2, kpeak2,3 printk p3 - 2, kpeak3,6 printk p3 - 2, kpeak4,9 printk p3 - 2, kpeak5,12 printk p3 - 2, kpeak6,15 printk p3 - 2, kpeak7,18 printk p3 - 2, kpeak8,21 printk p3 - 2, kpeak9,24 fout "$FILE.w.$HEADER.", giformat,aw ; output of a soundfile with header as specified in the options fout "$FILE.x.$HEADER.", giformat,ax ; output of a soundfile with header as specified in the options fout "$FILE.y.$HEADER.", giformat,ay ; output of a soundfile with header as specified in the options fout "$FILE.z.$HEADER.", giformat,az ; output of a soundfile with header as specified in the options fout "$FILE.r.$HEADER.", giformat,ar ; output of a soundfile with header as specified in the options fout "$FILE.s.$HEADER.", giformat,as ; output of a soundfile with header as specified in the options fout "$FILE.t.$HEADER.", giformat,at ; output of a soundfile with header as specified in the options fout "$FILE.u.$HEADER.", giformat,au ; output of a soundfile with header as specified in the options fout "$FILE.v.$HEADER.", giformat,av ; output of a soundfile with header as specified in the options if giorder == 2 goto encodeend ; write files in 2nd order Ambisonic kpeak10 peak ak kpeak11 peak al kpeak12 peak am kpeak13 peak an kpeak14 peak ao kpeak15 peak ap kpeak16 peak aq printk p3 - 2, kpeak10,0 printk p3 - 2, kpeak11,3 printk p3 - 2, kpeak12,6 printk p3 - 2, kpeak13,9 printk p3 - 2, kpeak14,12 printk p3 - 2, kpeak15,15 printk p3 - 2, kpeak16,18 fout "$FILE.k.$HEADER.", giformat,ak ; output of a soundfile with header as specified in the options fout "$FILE.l.$HEADER.", giformat,al ; output of a soundfile with header as specified in the options fout "$FILE.m.$HEADER.", giformat,am ; output of a soundfile with header as specified in the options fout "$FILE.n.$HEADER.", giformat,an ; output of a soundfile with header as specified in the options fout "$FILE.o.$HEADER.", giformat,ao ; output of a soundfile with header as specified in the options fout "$FILE.p.$HEADER.", giformat,ap ; output of a soundfile with header as specified in the options fout "$FILE.q.$HEADER.", giformat,aq ; output of a soundfile with header as specified in the options encodeend: if gidecchnls == 9 || gidecchnls == 16 goto skipend ; just encode the sound -comment this out if encoded+decoded files are wanted ; ******************************************************************************************************** stereo: ; 2chnl (stereo ) decode, 2nd order Ambisonics (second order controlled opposites) output ; ******************************************************************************************************** if gidecchnls == 2.1 goto uhj ; goto 2chnl UHJ decode if gidecchnls == 2.2 goto binaural_2nd_order ; goto 2chnl Binaural 2nd order decode if gidecchnls == 2.3 goto binaural_3rd_order ; goto 2chnl Binaural 3rd order decode achnl_1, achnl_2 Stereo_Decode aw, ay goto peak_2 uhj: achnl_1, achnl_2 UHJ_Decode aw, ax, ay ;UHJ Stereo output goto peak_2 binaural_2nd_order: achnl_1, achnl_2 Binaural_Decode_2nd_order aw, ax, ay, az, ar, as, at, au, av, krelcoef ;binaural with height in 2nd order resolution goto peak_2 binaural_3rd_order: achnl_1, achnl_2 Binaural_Decode_3rd_order aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq ;binaural in a plane with 3rd order resolution peak_2: kpeak_1 peak achnl_1 kpeak_2 peak achnl_2 printk p3, kpeak_1, 0 printk p3, kpeak_2, 3 if idecchnls == 2 goto skipend ; stereo output ; ******************************************************************************************************** eight: ; 8chnl decode, 2nd/3rd order Ambisonics (controlled opposites) output ; ******************************************************************************************************** if gidecchnls == 8 goto cube ; goto 8chnl cube decode if gidecchnls == 8.1 goto octogon_1 ; goto 8chnl cube decode cube: achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 Cube_Decode_2nd_order aw, ax, ay, az, as, at, av goto peak_8 octogon_1: achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 Octogon1_Decode_3rd_order aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq peak_8: kpeak_1 peak achnl_1 kpeak_2 peak achnl_2 kpeak_3 peak achnl_3 kpeak_4 peak achnl_4 kpeak_5 peak achnl_5 kpeak_6 peak achnl_6 kpeak_7 peak achnl_7 kpeak_8 peak achnl_8 printk p3, kpeak_1,0 printk p3, kpeak_2,3 printk p3, kpeak_3,6 printk p3, kpeak_4,9 printk p3, kpeak_5,12 printk p3, kpeak_6,15 printk p3, kpeak_7,18 printk p3, kpeak_8,21 skipend: blueMixerOut achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 false 0.0 1 Master 0.0 false false 3 Master 0.0 false false 11 Master 0.0 false false 12 Master 0.0 false false 13 Master 0.0 false false 14 Master 0.0 false false 15 Master 0.0 false false 23 Master 0.0 false false 24 Master 0.0 false false 25 Master 0.0 false false 26 Master 0.0 false false 27 Master 0.0 false false 28 Master 0.0 false false 29 Master 0.0 false false 30 Master 0.0 false false 32 Master 0.0 false false 41 Master 0.0 false false 50 Master 0.0 false false 60 Master 0.0 false false 61 Master 0.0 false false 65 Master 0.0 false false 70 Master 0.0 false false 71 Master 0.0 false false 72 Master 0.0 false false 73 Master 0.0 false false 75 Master 0.0 false false 78 Master 0.0 false false 80 Master 0.0 false false Master Master -1.1 false false f1 0 8192 10 1 /* sine */ f3 0 8192 10 1 0.5 0.333 0.25 0.2 0.166 0.142 0.125 0.111 0.1 0.09 0.083 0.076 0.071 0.066 0.062 /* sawtooth */ f7 0 32768 14 1 1 0 1 0 0.6 0 0.4 0 0.1 /* hyperbolid */ f8 0 32769 19 0.5 0.5 270 0.5 /* sigmoid rising */ f9 0 8192 19 0.5 1 180 1 /* paraboloid */ f10 0 8192 20 2 1 /* hanning */ /*f11-f20=straight lines */ f11 0 4 7 0 4 0 f12 0 4 7 0.1 4 0.1 f13 0 4 7 0.2 4 0.2 f14 0 4 7 0.4 4 0.4 f15 0 4 7 0.5 4 0.5 f16 0 4 7 0.6 4 0.6 f17 0 4 7 0.8 4 0.8 f18 0 4 7 0.9 4 0.9 f19 0 4 7 1 4 1 f20 0 4 -7 10 4 10 /*f21-f30=slopes and linsegs*/ f21 0 8192 7 0 8192 1 /*slope up*/ f22 0 8192 7 0 8192 -1 f23 0 4 7 0 1 0 0 1 2 1 0 0 1 0 /* rectangle unipolar, symmetric*/ f24 0 4 7 1 2 1 0 -1 2 -1 /* rectangle bipolar*/ f25 0 1024 7 0 512 1 512 0 /* triangle unipolar*/ f26 0 4 7 0 2 0 0 1 2 1 /* rectangle unipolar*/ f27 0 1024 7 0 512 1 0 -1 512 0 /* sawtooth bipolar */ f28 0 1024 7 0 256 1 512 -1 256 0 /* tiangle bipolar */ f29 0 1024 7 0 100 1 824 1 100 0 /* enveloped 19*/ /*f31-f40=exponentials */ f31 0 65537 5 0.001 65537 1 f32 0 65537 5 1 65537 0.001 9.21875 0.0 Simple-AED-Granulator -12566464 0 ; iinst = p4 ; instrument number of sound producing instrument ; iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ; ifreqdev = p6 ; frequency deviation (0.5 = 50% frequency, 2 = 200% frequency deviation) ; ienvinst = p7 ; function number for envelope generating instrument ; ieff_1 = p8 ; attack [%] ; ieff_2 = p9 ; instrument number of effect instrument 1 ; ieff_3 = p10 ; instrument number of effect instrument 2 ; iA = p11 ; position - angle(start) ; iE = p12 ; position - elevation:(start) ; iD = p13 ; distance of grain (start) ; iAdiff = p14 ; proportion of movement of a single grain in regard to the cloud [%] ; iEdiff = p15 ; proportion of movement of a single grain in regard to the cloud [%] ; iDdiff = p16 ; proportion of movement of a single grain in regard to the cloud [%] ;p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 i52 0 2 25 1 1 33 0 0 0 0 0 0 0 0 0 zakinit 16, 2 ; isizea, isizek 0dbfs = 1 ; SOUNDFILE OUTPUT SETTINGS #define FILE #Spatial_Granulator-# ; insert filename for name of output file here (note that the extension is just for the ; generation of the filename, the header of the file is specified below. #define HEADER #aif# ; insert filetype for output file name here giformat = 8 ; 1 = 16 bit integers without header (binary PCM multichannel file) for "fout" ; 2 = 16-bit integers with a header. ; The header type depends on the render format. ; The default header type is the IRCAM format. ; If the user chooses the AIFF format (using the -A flag), ; the header format will be a AIFF type. If the user chooses the WAV ; format (using the -W flag), the header format will be a WAV type. ; 8 = 24 bit integer with header like specified in options . For "fout". giorder = 3 ; 2 = 2nd order encode ; 3 = 3rd order encode ; GLOBAL SCALING OF THE AMPLITUDE girescale = 1 ; no amplitude scaling for test decoding ;girescale = 1.6 ; amplitude scaling for 2chnl decoding ; girescale = 0.95 ; amplitude scaling for 16-chnl encoding ;LAYOUT OF SPEAKERS gidecchnls = 2 ; specifies the speaker setup: ; 2 = stereo speaker setup ; 8 = cube ; 8.1 = octogon1 ; 9 = encoding 2nd order ; 16 = encoding 3rd order ; OVERALL DURATION gidurprolong init 0.5 ; prolong duration of generated instrument to perserve reverberation of early reflections and local reverb ; UNITS ON/ OFF gilocalrev init 1 ; switch on/off local reverb [0=off, 1=on] gispecref init 1 ; switch on/off specular reflections [0=off, 1=on] and adjust gain of reflection (e.g.: 1= normal gain, 2= twice as loud, 0.5 = half as loud) gidiffref init 0 ; switch on/off diffuse reflections [0=off, 1=on] and adjust gain of reflection (e.g.: 1= normal gain, 2= twice as loud, 0.5 = half as loud) ; EARLY REFLECTIONS PARAMETERS gifrontwall = 1.6 ; position of frontwall at the x-axis [units] for calculation of early reflections gisidewall = 1.3 ; position of sidewall at the y-axis [units] for calculation of early reflections giceiling = 1.1 ; height of the ceiling measured from the zero-point of the coordinate-system [units] for calculation of early reflections gidamp = 0.1 ; damping factor of the reflecting surface (gain of reverb) gihighdamp = 15000 ; absorbtion characteristics of the wall in respect to high frequencies: frequencies above ihighdamp get filtered out gilfboost = 1 ; low frequency boost for sources near a wall giunit = 4 ; radius of the "unit- sphere" (distance of the speaker from the center- point [m]) ; LOCAL AND SPATIAL GLOBAL REVERB PARAMETERS gireverbsend init 0.2 ; amount of direct signal sent to local + global reverb girvbdecay init 0.5 ; gain of reverb. Adjust empirically ; for desired reverb time. .6 gives ; a good small "live" room sound, .8 ; a small hall, .9 a large hall, ; .99 an enormous stone cavern. girandpchmod init 1 ; amount of random pitch modulation ; for the delay lines. 1 is the "normal" ; amount, but this may be too high for ; held pitches such as piano tones. ; Adjust to taste. gicutofffreq init 8000 ; Cutoff frequency of lowpass filters ; in feedback loops of delay lines, ; in Hz. Lower cutoff frequencies results ; in a sound with more high-frequency ; damping. ; VELOCITY OF GRAIN giAmove init 0 ; initilal value for movement of a single grain to calculate velocity giEmove init 0 ; initilal value for movement of a single grain to calculate velocity giDmove init 0 ; initilal value for movement of a single grain to calculate velocity gitime init 0 ; initilal value for movement of a single grain to calculate velocity #define GLOBALREVERBENCODING(W) # kchnlw = 0.707107 kchnlx = cos(iA$W.) * cos(iE$W.) kchnly = sin(iA$W.) * cos(iE$W.) kchnlz = sin(iE$W.) kchnlr = 1.5 * sin(iE$W.) * sin(iE$W.) -0.5 kchnls = cos(iA$W.) * sin(2 * iE$W.) kchnlt = sin(iA$W.) * sin(2 * iE$W.) kchnlu = cos(2 * iA$W.) * cos(iE$W.) * cos(iE$W.) kchnlv = sin(2 * iA$W.) * cos(iE$W.) * cos(iE$W.) aw = afilt$W. * kchnlw ;(A,E) ax = afilt$W. * kchnlx ;(A,E) ay = afilt$W. * kchnly ;(A,E) az = afilt$W. * kchnlz ;(A,E) ar = afilt$W. * kchnlr ;(A,E) as = afilt$W. * kchnls ;(A,E) at = afilt$W. * kchnlt ;(A,E) au = afilt$W. * kchnlu ;(A,E) av = afilt$W. * kchnlv ;(A,E) zawm aw, 1 ; rewrite and mix zak-location 1 with ambisonics w-channel output of spatial global reverb zawm ax, 2 ; rewrite and mix zak-location 2 with ambisonics x-channel output of spatial global reverb zawm ay, 3 ; rewrite and mix zak-location 3 with ambisonics y-channel output of spatial global reverb zawm az, 4 ; rewrite and mix zak-location 4 with ambisonics z-channel output of spatial global reverb zawm ar, 5 ; rewrite and mix zak-location 5 with ambisonics r-channel output of spatial global reverb zawm as, 6 ; rewrite and mix zak-location 6 with ambisonics s-channel output of spatial global reverb zawm at, 7 ; rewrite and mix zak-location 7 with ambisonics t-channel output of spatial global reverb zawm au, 8 ; rewrite and mix zak-location 8 with ambisonics u-channel output of spatial global reverb zawm av, 9 ; rewrite and mix zak-location 9 with ambisonics v-channel output of spatial global reverb # i78 0 [<TOTAL_DUR> + 10] i80 0 [<TOTAL_DUR> + 10] XYZ_Conversion_k_time kkk kkk ; CONVERSION OF X, Y, Z, k-rate kx, ky, kz xin ; input kx = (kx < 0.01 && kx > -0.01 ? 0.01 : kx) ; fix for that strange y-axis noise ; Distance calculation kD = sqrt( kx^2 + ky^2 + kz^2) ; calculates the distance kx = kx / kD ; this operation generates a vector equivalent at the unit sphere ky = ky / kD ; this operation generates a vector equivalent at the unit sphere kz = kz / kD ; this operation generates a vector equivalent at the unit sphere ; Elevation calculation kE = cosinv ( sqrt( 1 - kz^2)) ; calculation of Elevation kE = ( kz < 0 ? -kE : kE) ; if z is negative make Elevation- vector negative too ; Angle calculation kA = sininv (ky / sqrt(kx^2 + ky^2)) - 6.2831 ; calculation of Angle kA = (kx >= 0 ? kA : 3.1415 - kA) ; distinction of positive and negative y kA = (ky <= 0 && kx >= 0 ? 6.2831 + kA : kA) ; distinction of positive and negative y and x kA = kA * 57.295779513 ; conversion from rad to deg kE = kE * 57.295779513 ; conversion from rad to deg xout kA, kE, kD ; output XYZ_Conversion_i_time iii iii ; CONVERSION OF X, Y, Z ix, iy, iz xin ; input ix = (ix < 0.01 && ix > -0.01 ? 0.01 : ix) ; fix for that strange y-axis noise ; Distance calculation iD = sqrt( ix^2 + iy^2 + iz^2) ; calculates the distance ix = ix / iD ; this operation generates a vector equivalent at the unit sphere iy = iy / iD ; this operation generates a vector equivalent at the unit sphere iz = iz / iD ; this operation generates a vector equivalent at the unit sphere ; Elevation calculation iE = cosinv ( sqrt( 1 - iz^2)) ; calculation of Elevation iE = ( iz < 0 ? -iE : iE) ; if z is negative make Elevation- vector negative too ; Angle calculation iA = sininv (iy / sqrt(ix^2 + iy^2)) - 6.2831 ; calculation of Angle iA = (ix >= 0 ? iA : 3.1415 - iA) ; distinction of positive and negative y iA = (iy <= 0 && ix >= 0 ? 6.2831 + iA : iA) ; distinction of positive and negative y and x iA = iA * 57.295779513 ; conversion from rad to deg iE = iE * 57.295779513 ; conversion from rad to deg xout iA, iE, iD ; output Doppler_Shift_Calculation k ki ; DOPPLER SHIFT CALCULATION ; calculation of velocity ; Note: giunit = distance from a listener in the middle to the unit sphere in meters kD, giunit xin kDdelayed delayk kD, 0.001,2 ; delay distance - amount for 1 ms kV = kDdelayed - kD ; calculate the difference of distances kV = (kV * giunit) * 1000 ; speed in m/s ; calculation of doppler kpitch = 345 / (345 - kV) xout kpitch Encoding_2nd_3rd_Order_zak 0 akk asig, kA, kE xin aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq bformenc1 asig, kA, kE ;3rd order Ambisonics encoding zawm aw, 1 ; rewrite and mix zak-location 1 with ambisonics w-channel output zawm ax, 2 ; rewrite and mix zak-location 2 with ambisonics x-channel output zawm ay, 3 ; rewrite and mix zak-location 3 with ambisonics y-channel output zawm az, 4 ; rewrite and mix zak-location 4 with ambisonics z-channel output zawm ar, 5 ; rewrite and mix zak-location 5 with ambisonics r-channel output zawm as, 6 ; rewrite and mix zak-location 6 with ambisonics s-channel output zawm at, 7 ; rewrite and mix zak-location 7 with ambisonics t-channel output zawm au, 8 ; rewrite and mix zak-location 8 with ambisonics u-channel output zawm av, 9 ; rewrite and mix zak-location 9 with ambisonics v-channel output if giorder == 2 goto skipend ; just encode the sound -comment this out if encoded+decoded files are wanted zawm ak, 10 ; rewrite and mix zak-location 10 with ambisonics k-channel output zawm al, 11 ; rewrite and mix zak-location 11 with ambisonics l-channel output zawm am, 12 ; rewrite and mix zak-location 12 with ambisonics m-channel output zawm an, 13 ; rewrite and mix zak-location 13 with ambisonics n-channel output zawm ao, 14 ; rewrite and mix zak-location 14 with ambisonics o-channel output zawm ap, 15 ; rewrite and mix zak-location 15 with ambisonics p-channel output zawm aq, 16 ; rewrite and mix zak-location 16 with ambisonics q-channel output skipend: Diffuse_Early_Reflections_zak 0 akkk #define DIFFREFLECTION(R)# icnt = $R. ; calculation of points of reflection ; frontwall= 1 ; backwall = 2 ; left sidewall =3 ; right sidewall = 4 ; ceiling = 5 ; floor = 6 krefx = ( icnt = 1 ? gifrontwall : kx) ; asigning a position of the reflection at the x-axis if icnt = 1 kgoto yrefcalc$R. krefx = ( icnt = 2 ? -gifrontwall : kx) ; asigning a position of the reflection at the x-axis yrefcalc$R.: krefy = ( icnt = 3 ? gisidewall : ky) ; asigning a position of the reflection at the y-axis if icnt = 3 kgoto zrefcalc$R. krefy = ( icnt = 4 ? -gisidewall : ky) ; asigning a position of the reflection at the y-axis zrefcalc$R.: krefz = ( icnt = 5 ? giceiling : kz) ; asigning a position of the reflection at the z-axis if icnt = 5 kgoto refout$R. krefz = ( icnt = 6 ? -giceiling : kz) ; asigning a position of the reflection at the z-axis refout$R.: ; A, E, D - calculation of the reflecting point kDref = sqrt(krefx^2 + krefy^2 + krefz^2) ; calculates the distance of the reflection kxref = krefx / kDref ; this operation generates a vector equivalent at the unit sphere kyref = krefy / kDref ; this operation generates a vector equivalent at the unit sphere kzref = krefz / kDref ; this operation generates a vector equivalent at the unit sphere ; Elevation calculation kEref = cosinv ( sqrt( 1- kzref^2)) ; calculation of elevation kEref = (kzref < 0 ? -kEref : kEref) ; if z is negative make Elevation- vector negative too ; Angle calculation kAref = sininv (kyref / sqrt(kxref^2 + kyref^2)) ; calculation of angle kAref = (kxref >= 0 ? kAref : 3.1415 - kAref) ; distinction of positive and negative y kAref = (kyref <= 0 && kxref >= 0 ? 6.2831 + kAref : kAref); distinction of positive and negative y and x ; calculation of distance- difference (m/s) and delaytime kDdiff = sqrt((kx - krefx)^2 + (ky-krefy)^2 + (kz - krefz)^2 ) ; calculation of the difference of kreflection and ksound kDist = kDdiff + kDref ; distance sourcesurface + distance surface listener kDmtr = kDist * giunit ; calculation of difference in meters kdel = kDmtr / 0.345 ; calculation of the delaytime [ms] ; reflection behind the source kAdist = abs(kA - kAref) kEdist = abs(kE - kEref) kAdist = (kAdist > 6.2831 ? kAdist - 6.2831 : kAdist) ; reduces the angle kAdist to values between 0 and 6,2831 kmute = kAdist + kEdist kmute = ( kmute < 1.5707 ? sin (kmute) : 1) ; if the reflection gets behind the source, it is muted ; calculation of attenuation (gain of delay) kgain = 1 / kDist * gidamp * kmute ; gain of early reflection according calculation of attenuation ; FILTERING UNIT kDdiff = ( kDdiff < 0.05 ? 0.05 : kDdiff) ; limit the distance source reflection klfboost = (sqrt(1 / kDdiff ) + kD) * gilfboost afilt tone asig, (sqrt(1 / kDist)) * sr ; filtering of high frequencies according to distance afilt pareq afilt, 174, klfboost, 0.7071, 1 ; boosting low frequencies for souces near the wall afilt balance afilt, asig ; balancing the output adel interp kdel asigref vdelay3 afilt, adel, 200 ; creating a reflection asigref = asigref * kgain ; assigning a gain ; ENCODING UNIT ; RADIANT - DEGREE CONVERSION kAref = kAref * 57.2958 ; convert angle from radiant to degree kEref = kEref * 57.2958 ; convert elevation from radiant to degree ; ENCODING 2nd/3rd ORDER + ZAK-WRITING UNIT Encoding_2nd_3rd_Order_zak asigref, kAref, kEref ; encoding the sound in 2nd order ambisonic if nchnls = 9 and 3rd order if nchnls = 16 # ; gifrontwall - position of frontwall at the x-axis ; gisidewall - position of sidewall at the y-axis ; giceiling - height of the ceiling measured from the zero-point of the coordinate-system ; giunit - radius of the unit- sphere[m] ; TRAJECTORY AND SIGNAL READ IN asig, kA, kE, kD xin ; DEGREE - RADIANT CONVERSION kA = kA * 0.01745329252 ; convert 0-360 degrees to radiant-expression kE = kE * 0.01745329252 ; convert 0-90 degrees to radiant-expression kA = (kA < 0 ? kA + 6.283185 : kA) ; prevent negative angle kA kA = (kA > 6.283185 ? kA - 6.283185 : kA) ; prevent angle kA > 360 ; Polar converter -source as cartesian representation kx = kD * cos(kA) * cos(kE) ; position of sound in kartesian coordinates ky = kD * sin(kA) * cos(kE) ; position of sound in kartesian coordinates kz = kD * sin(kE) ; position of sound in kartesian coordinates kx = (kx < 0.01 && kx > -0.01 ? 0.01 : kx) ; fix for that strange y-axis noise asig tone asig, gihighdamp ; filtering of high frequencies due to absorbtion characteristics of the wall $DIFFREFLECTION(1) $DIFFREFLECTION(2) $DIFFREFLECTION(3) $DIFFREFLECTION(4) $DIFFREFLECTION(5) $DIFFREFLECTION(6) #undef DIFFREFLECTION(R) Specular_Early_Reflections_zak 0 akkk #define SPECREFLECTION(R)# ; calculation of points of reflection icnt = $R. ksum$R. = abs(iwall$R. ) + abs(kdiff$R.) ; distance source wall listener (x,y,z-component) krefx = (kx/ ksum$R. ) * abs(iwall$R.) ; x- position of the reflection krefy = (ky/ ksum$R. ) * abs(iwall$R.) ; y- position of the reflection krefz = (kz/ ksum$R. ) * abs(iwall$R.) ; z- position of the reflection krefx = (icnt = 1 ? iwall1 : (kx/ ksum$R. ) * abs(iwall$R.)) ; x- position of the reflection krefx = (icnt = 2 ? -iwall1 : (kx/ ksum$R. ) * abs(iwall$R.)) ; x- position of the reflection krefy = (ky/ ksum$R. ) * abs(iwall$R.) ; y- position of the reflection krefz = (kz/ ksum$R. ) * abs(iwall$R.) ; z- position of the reflection ; assignment of x-,y-,z- component at the wall ; frontwall = 1 ; backwall = 2 ; left sidewall =3 ; right sidewall = 4 ; ceiling = 5 ; floor = 6 krefx = ( icnt = 1 ? iwall1 : krefx) ; asigning a position of the reflection at the x-axis if icnt = 1 igoto ycalc$R. krefx = ( icnt = 2 ? iwall2 : krefx) ; asigning a position of the reflection at the x-axis ycalc$R.: krefy = ( icnt = 3 ? iwall3 : krefy) ; asigning a position of the reflection at the y-axis if icnt = 3 igoto zcalc$R. krefy = ( icnt = 4 ? iwall4 : krefy) ; asigning a position of the reflection at the y-axis zcalc$R.: krefz = ( icnt = 5 ? iwall5 : krefz) ; asigning a position of the reflection at the z-axis if icnt = 5 igoto labelout$R. krefz = ( icnt = 6 ? iwall6 : krefz) ; asigning a position of the reflection at the z-axis labelout$R.: krefx = (krefx < 0.001 && krefx > -0.001 ? 0.001 : krefx) ; avoid zero to avoid division by zero error (NaN) later krefy = (krefy < 0.001 && krefy > -0.001 ? 0.001 : krefy) ; avoid zero to avoid division by zero error (NaN) later krefz = (krefz < 0.001 && krefz > -0.001 ? 0.001 : krefz) ; avoid zero to avoid division by zero error (NaN) later ; A, E, D - calculation of the reflecting point kDref = sqrt (krefx^2 + krefy^2 + krefz^2) ; calculates the distance of the reflection kxref = krefx / kDref ; this operation generates a vector equivalent at the unit sphere kyref = krefy / kDref ; this operation generates a vector equivalent at the unit sphere kzref = krefz / kDref ; this operation generates a vector equivalent at the unit sphere ; Elevation calculation kEref = cosinv ( sqrt( 1 - kzref^2)) ; calculation of elevation kEref = (kzref < 0 ? -kEref : kEref) ; if z is negative make elevation- vector negative too ; Angle calculation kAref = sininv (kyref / sqrt(kxref^2 + kyref^2)) ; calculation of angle kAref = (kxref >= 0 ? kAref : 3.1415 - kAref) ; distinction of positive and negative y kAref = (kyref <= 0 && kxref >= 0 ? 6.2831 + kAref : kAref); distinction of positive and negative y and x ; calculation of distance- difference (m/s) and delaytime kDdiff = sqrt((kx - krefx)^2 + (ky - krefy)^2 + (kz - krefz)^2 ) ; calculation of the difference of kreflection and ksound kDist = kDdiff + kDref ; distance sourcesurface + distance surface listener kDmtr = kDist * giunit ; calculation of difference in meters kdel = kDmtr / 0.345 ; calculation of the delaytime [ms] ; calculation of attenuation (gain of delay) kgain = 1 / kDist * gidamp ; gain of early reflection according calculation of attenuation ; reflection behind the source kAdist = abs(kA - kAref) ; distance of angle between source and reflection kEdist = abs(kE - kEref) ; distance of elevation between source and reflection kAdist = (kAdist > 6.2831 ? kAdist - 6.2831 : kAdist) ; reduces the angle kAdist to values between 0 and 6,2831 kmute = kAdist + kEdist kmute = (kmute < 1.5707 ? sin (kmute) : 1) ; if the reflection gets behind the source, it is muted ; filtering unit kDdiff = ( kDdiff < 0.05 ? 0.05 : kDdiff) ; limit the distance source reflection klfboost = sqrt(1 / kDdiff) * gilfboost afilt tone asig, (sqrt(1 / kDist)) * sr ; filtering of high frequencies due to absorbtion characteristics of the air ; according to distance afilt pareq afilt, 174, klfboost, 0.7071, 1 ; boosting low frequencies for souces near the wall afilt balance afilt, asig ; balancing the output adel interp kdel asigref vdelay3 afilt, adel, 200 ; creation of a reflection asigref = asigref * kgain * kmute ; assigning a gain ; ENCODING UNIT ; RADIANT - DEGREE CONVERSION kAref = kAref * 57.2958 ; convert angle from radiant to degree kEref = kEref * 57.2958 ; convert elevation from radiant to degree ;printk 1, kAref, 23 ;printk 1, kEref, 23 ; ENCODING 2nd/3rd ORDER + ZAK-WRITING UNIT Encoding_2nd_3rd_Order_zak asigref, kAref, kEref ; encoding the sound in 2nd order ambisonic if nchnls = 9 and 3rd order if nchnls = 16 end$R.: # ; gifrontwall - position of frontwall at the x-axis ; gisidewall - position of sidewall at the y-axis ; giceiling - height of the ceiling measured from the zero-point of the coordinate-system ; giunit - radius of the unit- sphere[m] asig, kA, kE, kD xin ; DEGREE - RADIANT CONVERSION kA = kA * 0.01745329252 ; convert 0-360 degrees to radiant-expression kE = kE * 0.01745329252 ; convert 0-90 degrees to radiant-expression kA = (kA < 0 ? kA + 6.283185 : kA) ; prevent negative angle kA kA = (kA > 6.283185 ? kA - 6.283185 : kA) ; prevent angle kA > 360 ; Polar converter -source as cartesian representation kx = kD * cos(kA) * cos(kE) ; convert polar to carthesian representation ky = kD * sin(kA) * cos(kE) ; convert polar to carthesian representation kz = kD * sin(kE) ; convert polar to carthesian representation kx = (kx < 0.01 && kx > -0.01 ? 0.01 :kx) ; fix for that strange y-axis noise iwall1 = gifrontwall ; assign distance of the wall iwall2 = -gifrontwall ; assign distance of the wall iwall3 = gisidewall ; assign distance of the wall iwall4 = -gisidewall ; assign distance of the wall iwall5 = giceiling ; assign distance of the wall iwall6 = -giceiling ; assign distance of the wall kdiff1 = iwall1 - kx ; distance of reflection to the frontwall kdiff2 = iwall2 - kx ; distance of reflection to the backwall kdiff3 = iwall3 - ky ; distance of reflection to the left sidewall kdiff4 = iwall4 - ky ; distance of reflection to the right sidewall kdiff5 = iwall5 - kz ; distance of reflection to the ceiling kdiff6 = iwall6 - kz ; distance of reflection to the floor asig tone asig, gihighdamp ; filtering of high frequencies due to absorbtion characteristics of the wall print gispecref $SPECREFLECTION(1) $SPECREFLECTION(2) $SPECREFLECTION(3) $SPECREFLECTION(4) $SPECREFLECTION(5) $SPECREFLECTION(6) #undef SPECREFLECTION(R) Stereo_Decode aa aa aw, ay xin ;input ;Rig `Controlled Opposites' Decode Matrix (second Order) ; w x y z r s t u v ; Speaker1 <0.0000,1.0000,0.0000> achnl1 sum aw * 0.7071, ay * 0.5000 ; Speaker2 <0.0000,-1.0000,0.0000> achnl2 sum aw * 0.7071, ay * -0.5000 xout achnl1, achnl2 ; output UHJ_Decode aa aaa aw, ax, ay xin ;input ajw1, ajw0 hilbert aw ajx1, ajx0 hilbert ax ajy1, ajy0 hilbert ay achnl1 = 0.0928 * ajx1 + 0.255 * ajx0 + 0.4699 * ajw1 - 0.171 * ajw0 + 0.3277 * ajy1 achnl2 = 0.0928 * ajx1 - 0.255 * ajx0 + 0.4699 * ajw1 + 0.171 * ajw0 - 0.3277 * ajy1 xout achnl1, achnl2 ; output Converts b-format ambisonics to uhj stereo. SYNTAX achnl1, achnel2 UHJ_Decode aW, aX, aY, aZ INITIALIZATION aw, ax, ay CREDITS Joseph Anderson and ma++, jan 2005 slightly modified by Jan Jacob Hofmann April 2009 Cube_Decode_2nd_order aaaaaaaa aaaaaaa ; 8chnl decode (cube),2nd order (second order controlled opposites), Furse-Malham Set Of Equations aw, ax, ay, az, as, at, av xin ; input ; Rig `Controlled Opposites' Decode Matrix (Second Order) ; w x y z r s t u v ; Speaker1 <0.5774,0.5774,-0.5774> front left lower achnl_co_1 sum aw * 0.1768, ax * 0.114, ay * 0.114, az * -0.114, as * -0.0369, at * -0.0369, av * 0.0369 ; Speaker2 <0.5774,-0.5774,-0.5774> front right lower achnl_co_2 sum aw * 0.1768, ax * 0.114, ay * -0.114, az * -0.114, as * -0.0369, at * 0.0369, av * -0.0369 ; Speaker3 <-0.5774,-0.5774,-0.5774> back right lower achnl_co_3 sum aw * 0.1768, ax * -0.114, ay * -0.114, az * -0.114, as * 0.0369, at * 0.0369, av * 0.0369 ; Speaker4 <-0.5774,0.5774,-0.5774> back left lower achnl_co_4 sum aw * 0.1768, ax * -0.114, ay * 0.114, az * -0.114, as * 0.0369, at * -0.0369, av * -0.0369 ; Speaker5 <0.5774,0.5774,0.5774> front left upper achnl_co_5 sum aw * 0.1768, ax * 0.114, ay * 0.114, az * 0.114, as * 0.0369, at * 0.0369, av * 0.0369 ; Speaker6 <0.5774,-0.5774,0.5774> front right upper achnl_co_6 sum aw * 0.1768, ax * 0.114, ay * -0.114, az * 0.114, as * 0.0369, at * -0.0369, av * -0.0369 ; Speaker7 <-0.5774,-0.5774,0.5774> back right upper achnl_co_7 sum aw * 0.1768, ax * -0.114, ay * -0.114, az * 0.114, as * -0.0369, at * -0.0369, av * 0.0369 ; Speaker8 <-0.5774,0.5774,0.5774> back left upper achnl_co_8 sum aw * 0.1768, ax * -0.114, ay * 0.114, az * 0.114, as * -0.0369, at * 0.0369, av * -0.0369 xout achnl_co_1, achnl_co_2, achnl_co_3, achnl_co_4, achnl_co_5, achnl_co_6, achnl_co_7, achnl_co_8 ; output Furse - Malham set of controlled opposites decoding equation CREDITS to Dave Malham and Richard Furse Octogon1_Decode_3rd_order aaaaaaaa aaaaaaaaaaaaaaaa aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq xin ; input achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 bformdec1 4, aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq xout achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 ; output ************************************************************************************** octagon1: ; 8chnl decode (octagon 1),3rd order (third order controlled opposites) ************************************************************************************** This rig configuration produces an `in-phase' response and each speaker will have only a single maximum given a moving virtual sound source. Speaker 1 <0.9239,0.3827,0.0000> Speaker 2 <0.3827,0.9239,0.0000> Speaker 3 <-0.3827,0.9239,0.0000> Speaker 4 <-0.9239,0.3827,0.0000> Speaker 5 <-0.9239,-0.3827,0.0000> Speaker 6 <-0.3827,-0.9239,0.0000> Speaker 7 <0.3827,-0.9239,0.0000> Speaker 8 <0.9239,-0.3827,0.0000> CREDITS to Dave Malham, Richard Furse and Fons Adriaensen Binaural_Decode_2nd_order aa aaaaaaaaak aw, ax, ay, az, ar, as, at, au, av, krelcoef xin ; decode 2ns order ambisonic for 12 channel dodecahedron1 loudspeaker setup ; ************************************************************************************************************ ; dodecahedron1 to binaural ;Rig `Controlled Opposites' Decode Matrix (Second Order) to binaural ; ************************************************************************************************************ ;This rig configuration produces an 'in-phase' response and each speaker will have only a single maximum given a moving virtual sound source. ; w x y z r s t u v ; Speaker 1 <0.0000,0.0000,1.0000> centre top achnl_co_1 sum aw * 0.1179, az * 0.1316, ar * 0.0491 ; Speaker 2 <0.0000,0.0000,-1.0000> centre bottom achnl_co_2 sum aw * 0.1179, az * -0.1316, ar * 0.0491 ; Speaker 3 <0.7236,0.5257,0.4472> achnl_co_3 sum aw * 0.1179, ax * 0.0952, ay * 0.0692, az * 0.0589, ar * -0.0098, as * 0.0238, at * 0.0173, au * 0.0091, av * 0.0280 ; Speaker 4 <-0.7236,-0.5257,-0.4472> achnl_co_4 sum aw * 0.1179, ax * -0.0952, ay * -0.0692, az * -0.0589, ar * -0.0098, as * 0.0238, at * 0.0173, au * 0.0091, av * 0.0280 ; Speaker 5 <0.7236,-0.5257,0.4472> achnl_co_5 sum aw * 0.1179, ax * 0.0952, ay * -0.0692, az * 0.0589, ar * -0.0098, as * 0.0238, at * -0.0173, au * 0.0091, av * -0.0280 ; Speaker 6 <-0.7236,0.5257,-0.4472> achnl_co_6 sum aw * 0.1179, ax * -0.0952, ay * 0.0692, az * -0.0589, ar * -0.0098, as * 0.0238, at * -0.0173, au * 0.0091, av * -0.0280 ; Speaker 7 <-0.2764,0.8507,0.4472> achnl_co_7 sum aw * 0.1179, ax * -0.0364, ay * 0.1119, az * 0.0589, ar * -0.0098, as * -0.0091, at * 0.0280, au * -0.0238, av * -0.0173 ; Speaker 8 <0.2764,-0.8507,-0.4472> achnl_co_8 sum aw * 0.1179, ax * 0.0364, ay * -0.1119, az * -0.0589, ar * -0.0098, as * -0.0091, at * 0.0280, au * -0.0238, av * -0.0173 ; Speaker 9 <-0.2764,-0.8507,0.4472> achnl_co_9 sum aw * 0.1179, ax * -0.0364, ay * -0.1119, az * 0.0589, ar * -0.0098, as * -0.0091, at * -0.0280, au * -0.0238, av * 0.0173 ; Speaker 10 <0.2764,0.8507,-0.4472> achnl_co_10 sum aw * 0.1179, ax * 0.0364, ay * 0.1119, az * -0.0589, ar * -0.0098, as * -0.0091, at * -0.0280, au * -0.0238, av * 0.0173 ; Speaker 11 <-0.8944,0.0000,0.4472> achnl_co_11 sum aw * 0.1179, ax * -0.1177, az * 0.0589, ar * -0.0098, as * -0.0295, au * 0.0295 ; Speaker 12 <0.8944,0.0000,-0.4472> achnl_co_12 sum aw * 0.1179, ax * 0.1177, az * -0.0589, ar * -0.0098, as * -0.0295, au * 0.0295 ; Rig Decode Matrix to Reproduce Spherical Harmonics (Second Order) ; This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations. Generally this type of configuration produces a relatively small stable listening area. ; w x y z r s t u v ; Speaker 1 <0.0000,0.0000,1.0000> centre top achnl_sh_1 sum aw * 0.1179, az * 0.2500, ar * 0.4167 ; Speaker 2 <0.0000,0.0000,-1.0000> centre bottom achnl_sh_2 sum aw * 0.1179, az * -0.2500, ar * 0.4167 ; Speaker 3 <0.7236,0.5257,0.4472> achnl_sh_3 sum aw * 0.1179, ax * 0.1809, ay * 0.1314, az * 0.1118, ar * -0.0833, as * 0.2023, at * 0.1469, au * 0.0773, av * 0.2378 ; Speaker 4 <-0.7236,-0.5257,-0.4472> achnl_sh_4 sum aw * 0.1179, ax * -0.1809, ay * -0.1314, az * -0.1118, ar * -0.0833, as * 0.2023, at * 0.1469, au * 0.0773, av * 0.2378 ; Speaker 5 <0.7236,-0.5257,0.4472> achnl_sh_5 sum aw * 0.1179, ax * 0.1809, ay * -0.1314, az * 0.1118, ar * -0.0833, as * 0.2023, at * -0.1469, au * 0.0773, av * -0.2378 ; Speaker 6 <-0.7236,0.5257,-0.4472> achnl_sh_6 sum aw * 0.1179, ax * -0.1809, ay * 0.1314, az * -0.1118, ar * -0.0833, as * 0.2023, at * -0.1469, au * 0.0773, av * -0.2378 ; Speaker 7 <-0.2764,0.8507,0.4472> achnl_sh_7 sum aw * 0.1179, ax * -0.0691, ay * 0.2127, az * 0.1118, ar * -0.0833, as * -0.0773, at * 0.2378, au * -0.2023, av * -0.1469 ; Speaker 8 <0.2764,-0.8507,-0.4472> achnl_sh_8 sum aw * 0.1179, ax * 0.0691, ay * -0.2127, az * -0.1118, ar * -0.0833, as * -0.0773, at * 0.2378, au * -0.2023, av * -0.1469 ; Speaker 9 <-0.2764,-0.8507,0.4472> achnl_sh_9 sum aw * 0.1179, ax * -0.0691, ay * -0.2127, az * 0.1118, ar * -0.0833, as * -0.0773, at * -0.2378, au * -0.2023, av * 0.1469 ; Speaker 10 <0.2764,0.8507,-0.4472> achnl_sh_10 sum aw * 0.1179, ax * 0.0691, ay * 0.2127, az * -0.1118, ar * -0.0833, as * -0.0773, at * -0.2378, au * -0.2023, av * 0.1469 ; Speaker 11 <-0.8944,0.0000,0.4472> achnl_sh_11 sum aw * 0.1179, ax * -0.2236, az * 0.1118, ar * -0.0833, as * -0.2500, au * 0.2500 ; Speaker 12 <0.8944,0.0000,-0.4472> achnl_sh_12 sum aw * 0.1179, ax * 0.2236, az * -0.1118, ar * -0.0833, as * -0.2500, au * 0.2500 achnl_1 = achnl_co_1 * krelcoef + achnl_sh_1 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_2 = achnl_co_2 * krelcoef + achnl_sh_2 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_3 = achnl_co_3 * krelcoef + achnl_sh_3 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_4 = achnl_co_4 * krelcoef + achnl_sh_4 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_5 = achnl_co_5 * krelcoef + achnl_sh_5 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_6 = achnl_co_6 * krelcoef + achnl_sh_6 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_7 = achnl_co_7 * krelcoef + achnl_sh_7 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_8 = achnl_co_8 * krelcoef + achnl_sh_8 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_9 = achnl_co_9 * krelcoef + achnl_sh_9 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_10 = achnl_co_10 * krelcoef + achnl_sh_10 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_11 = achnl_co_11 * krelcoef + achnl_sh_11 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients achnl_12 = achnl_co_12 * krelcoef + achnl_sh_12 * (1 - krelcoef) ; ratio between controlled opposites and spherical harmonic coefficients if sr != 44100 goto sr48000 ; skip to different sr ; Processing with Head Related Transfer Function ; (hrtf phase truncation...) aleft_1, aright1 hrtfstat achnl_1, 1, 89.99, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_2, aright2 hrtfstat achnl_2, -1, -89.99, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_3, aright_3 hrtfstat achnl_3, -36, 26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_4, aright_4 hrtfstat achnl_4, 144, -26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_5, aright_5 hrtfstat achnl_5, 36, 26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_6, aright_6 hrtfstat achnl_6, -144, -26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_7, aright_7 hrtfstat achnl_7, -108, 26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_8, aright_8 hrtfstat achnl_8, 72, -26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_9, aright_9 hrtfstat achnl_9, 108, 26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_10, aright_10 hrtfstat achnl_10, -72, -26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_11, aright_11 hrtfstat achnl_11, 180, 26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" aleft_12, aright_12 hrtfstat achnl_12, 0, -26.565, "hrtf-44100-left.dat", "hrtf-44100-right.dat" goto output sr48000: if sr = 96000 goto sr96000 ; skip to sr =96000 aleft_1, aright_1 hrtfstat achnl_1, 1, 89.99, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_2, aright_2 hrtfstat achnl_2, -1, -89.99, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_3, aright_3 hrtfstat achnl_3, -36, 26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_4, aright_4 hrtfstat achnl_4, 144, -26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_5, aright_5 hrtfstat achnl_5, 36, 26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_6, aright_6 hrtfstat achnl_6, -144, -26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_7, aright_7 hrtfstat achnl_7, -108, 26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_8, aright_8 hrtfstat achnl_8, 72, -26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_9, aright_9 hrtfstat achnl_9, 108, 26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_10, aright_10 hrtfstat achnl_10, -72, -26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_11, aright_11 hrtfstat achnl_11, 180, 26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" aleft_12, aright_12 hrtfstat achnl_12, 0, -26.565, "hrtf-48000-left.dat", "hrtf-48000-right.dat" goto output sr96000: aleft_1, aright_1 hrtfstat achnl_1, 1, 89.99, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_2, aright_2 hrtfstat achnl_2, -1, -89.99, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_3, aright_3 hrtfstat achnl_3, -36, 26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_4, aright_4 hrtfstat achnl_4, 144, -26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_5, aright_5 hrtfstat achnl_5, 36, 26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_6, aright_6 hrtfstat achnl_6, -144, -26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_7, aright_7 hrtfstat achnl_7, -108, 26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_8, aright_8 hrtfstat achnl_8, 72, -26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_9, aright_9 hrtfstat achnl_9, 108, 26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_10, aright_10 hrtfstat achnl_10, -72, -26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_11, aright_11 hrtfstat achnl_11, 180, 26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" aleft_12, aright_12 hrtfstat achnl_12, 0, -26.565, "hrtf-96000-left.dat", "hrtf-96000-right.dat" output: ; Adding Inter Aural Time Delay ITD aleft_1 delay aleft_1, 0.00028986 aleft_2 delay aleft_2, 0.00028986 aleft_3 delay aleft_3, 0.00020974 aleft_4 delay aleft_4, 0.00036997 aleft_5 delay aleft_5, 0.00036997 aleft_6 delay aleft_6, 0.00020974 aleft_7 delay aleft_7, 0.00008011 aleft_8 delay aleft_8, 0.00049960 aleft_9 delay aleft_9, 0.00049960 aleft_10 delay aleft_10, 0.00008011 aleft_11 delay aleft_11, 0.00028986 aleft_12 delay aleft_12, 0.00028986 aright_1 delay aright_1, 0.00028986 aright_2 delay aright_2, 0.00028986 aright_3 delay aright_3, 0.00036997 aright_4 delay aright_4, 0.00020974 aright_5 delay aright_5, 0.00020974 aright_6 delay aright_6, 0.00036997 aright_7 delay aright_7, 0.000499597 aright_8 delay aright_8, 0.00008011 aright_9 delay aright_9, 0.00008011 aright_10 delay aright_10, 0.000499597 aright_11 delay aright_11, 0.00028986 aright_12 delay aright_12, 0.00028986 ; mixing all spacial signals together aright sum aright_1, aright_2, aright_3, aright_4, aright_5, aright_6, aright_7, aright_8, aright_9, aright_10, aright_11, aright_12 aleft sum aleft_1, aleft_2, aleft_3, aleft_4, aleft_5, aleft_6, aleft_7, aleft_8, aleft_9, aleft_10, aleft_11, aleft_12 outs aleft, aright ; output of the binaural mix Note: The files "HRTFcompact" should reside in the same folder as the soundfiles to be read in. Make sure the Directory points there. Else there will be an instant crash of Csound without a warning message. ************************************************************************************************************************** ; 2nd ORDER AMBISONICS TO BINAURAL DECODER- coded 1999-2009 by Jan Jacob Hofmann. ; FURSE - MALHAM - SET OF EQUATIONS Version 2.0 April. 12th 2009 ; This decodes 2nd Order Ambisonic to Binaural http://www.sonicarchitecture.de ; by using 12 virtual speakers Thanks to Richard Furse, Dave Malham and Bruce Wiggins ************************************************************************************************************************** Binaural_Decode_3rd_order aa aaaaaaaaaaaaaaaa aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq xin ; decode B format for 8 channel circle loudspeaker setup a1, a2, a3, a4, a5, a6, a7, a8 bformdec1 4, aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq ;FFL(22.5),FLL(67.5),BLL(112.5),BBL(157.5),BBR(-157.5),BRR(-112.5),FRR(-67.5),FFR(-22.5) if sr != 44100 goto sr48000 ; skip to different sr ; binaural_ly encode each channel ; (hrtf phase truncation...) al_1, ar_1 hrtfstat a1, 22.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_2, ar_2 hrtfstat a2, 67.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_3, ar_3 hrtfstat a3, 112.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_4, ar_4 hrtfstat a4, 157.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_5, ar_5 hrtfstat a5, 202.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_6, ar_6 hrtfstat a6, 247.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_7, ar_7 hrtfstat a7, 292.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" al_8, ar_8 hrtfstat a8, 337.5, 0, "hrtf-44100-left.dat", "hrtf-44100-right.dat" goto output sr48000: if sr = 96000 goto sr96000 ; skip to sr =96000 ; binaural_ly encode each channel ; (hrtf phase truncation...) al_1, ar_1 hrtfstat a1, 22.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_2, ar_2 hrtfstat a2, 67.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_3, ar_3 hrtfstat a3, 112.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_4, ar_4 hrtfstat a4, 157.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_5, ar_5 hrtfstat a5, 202.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_6, ar_6 hrtfstat a6, 247.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_7, ar_7 hrtfstat a7, 292.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" al_8, ar_8 hrtfstat a8, 337.5, 0, "hrtf-48000-left.dat", "hrtf-48000-right.dat" goto output sr96000: ; binaural_ly encode each channel ; (hrtf phase truncation...) al_1, ar_1 hrtfstat a1, 22.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_2, ar_2 hrtfstat a2, 67.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_3, ar_3 hrtfstat a3, 112.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_4, ar_4 hrtfstat a4, 157.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_5, ar_5 hrtfstat a5, 202.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_6, ar_6 hrtfstat a6, 247.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_7, ar_7 hrtfstat a7, 292.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" al_8, ar_8 hrtfstat a8, 337.5, 0, "hrtf-96000-left.dat", "hrtf-96000-right.dat" output: ; Adding Inter Aural_ Time Delay ITD al_1 delay al_1, 0.00028986 al_2 delay al_2, 0.00028986 al_3 delay al_3, 0.00020974 al_4 delay al_4, 0.00036997 al_5 delay al_5, 0.00036997 al_6 delay al_6, 0.00020974 al_7 delay al_7, 0.00008011 al_8 delay al_8, 0.00049960 ar_1 delay ar_1, 0.00028986 ar_2 delay ar_2, 0.00028986 ar_3 delay ar_3, 0.00036997 ar_4 delay ar_4, 0.00020974 ar_5 delay ar_5, 0.00020974 ar_6 delay ar_6, 0.00036997 ar_7 delay ar_7, 0.000499597 ar_8 delay ar_8, 0.00008011 aleft sum al_1, al_2, al_3, al_4, al_5, al_6, al_7, al_8 aright sum ar_1, ar_2, ar_3, ar_4, ar_5, ar_6, ar_7, ar_8 xout aleft, aright ; write binaural audio out Note: The "HRTF" -files should reside in the same folder as the soundfiles to be read in. Make sure the Directory points there. Else there will be an instant crash of Csound without a warning message. ************************************************************************************************************************** 2nd ORDER AMBISONICS TO BINAURAL DECODER- coded 1999-2009 by Jan Jacob Hofmann. FURSE - MALHAM - SET OF EQUATIONS Version 2.0 April 12th 2009 This decodes 3rd Order Ambisonic to Binaural http://www.sonicarchitecture.de by using 8 virtual speakers Thanks to Richard Furse, Dave Malham and Bruce Wiggins ************************************************************************************************************************** csound -Wdo devaudio -L stdin false false 2.0 0.0 root -10066279 0 true 48 3 false 1.0 0 5 10.125 0.0 Complex AED-Granulator -12566464 2 ; iinst = p4 ; instrument number of sound producing instrument ; iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ; ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ; ENVELOPES ; ienvinst = p7 ; instrument number of envelope generating instrument ; POSITION AND MOVEMENT ; iAdev = p8 ; deviation of position of grain - angle [¡] ; iEdev = p9 ; deviation of position of grain - elevation [¡] ; iDdev = p10 ; deviation of position of grain - distance [unit] ; iAmove = p11 ; A - amount of movement of a single grain in regard to the cloud [¡] ; iEmove = p12 ; E - amount of movement of a single grain in regard to the cloud [¡] ; iDmove = p13 ; D - amount of movement of a single grain in regard to the cloud [unit] ; iArange = p14 ; maximum possible range of deviation of angle [¡] ; iErange = p15 ; maximum possible range of deviation of elevation [¡] ; iDrange = p16 ; maximum possible range of deviation of distance [unit] ; CONTROL DISTRIBUTION FN ; icrtlfn = p17 ; control distribution fn [21/31] ; COPIES ; icpydel = p18 ; delay time of copy [s] ; imaxcnt = p19 ; density of copy (number of instances) ; icnt = p20 ; count of copies (= initial count of original instrument: must always be 0 here) ; iAcpydev = p21 ; angle deviation (shift) of each copy [¡] ; iEcpydev = p22 ; elevation deviation (shift) of each copy [¡] ; iDcpydev = p23 ; distance deviation (shift) of each copy [unit] ; ***************************************************************************************************************************************************** f 0 10.00 p1 const 70 p2 const 10 prec 2 ; density of grains p3 const 0.1 prec 2 ; duration of grains ; SOUND PRODUCTION ; Instrument for sound generation p4 const 32 ; instrument number of sound producing instrument p5 const 1 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation 1 = no deviation) p6 const 1 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation 1 = no deviation) ; Envelopes p7 const 11 ; instrument number of envelope generating instrument p8 const 0 ; deviation of position - angle [degrees] (start) p9 const 0 ; deviation of position - elevation [degrees](start) p10 const 0 ; deviation of position - distance (start) ; MOVEMENT OF GRAIN p11 const 0 ; A: amount of movement of a single grain in regard to the cloud [¡] p12 const 0 ; E: amount of movement of a single grain in regard to the cloud [¡] p13 const 0 ; D: amount of movement of a single grain in regard to the cloud [¡] ; MAXIMUM RANGE OF LOCATION DEVIATION p14 const 90 ; A: maximum angle deviation [¡] p15 const 0 ; E: maximum elevation deviation [¡] p16 const 0 ; D: maximum distance deviation [¡] ; CONTROL DISTRIBUTION FN p17 const 21 ; control distribution fn ; CORRELATED COPY DEVICE p18 const 1 ; delay time of copy [s] p19 const 8 ; number of copies p20 const 0 ; count of copies (= initial count of original instrument: must always be 0) p21 const 10 ; angle deviation (shift) of each copy [¡] p22 const 0 ; elevation deviation (shift) of each copy [¡] p23 const 0 ; distance deviation (shift) of each copy [unit] /usr/local/bin/cmask $infile $outfile Python 10.125 0.0 Complex XYZ-Granulator -12566464 2 ; iinst = p4 ; instrument number of sound producing instrument ; iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ; ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ; ENVELOPES ; ienvinst = p7 ; instrument number of envelope generating instrument ; POSITION AND MOVEMENT ; iXdev = p8 ; deviation of position of grain - X-coordinate [unit] ; iYdev = p9 ; deviation of position of grain - Y-coordinate [unit] ; iZdev = p10 ; deviation of position of grain - Z-coordinate [unit] ; iXmove = p11 ; X amount of movement of a single grain in regard to the cloud [unit] ; iYmove = p12 ; Y amount of movement of a single grain in regard to the cloud [unit] ; iZmove = p13 ; Z amount of movement of a single grain in regard to the cloud [unit] ; iXrange = p14 ; possible range of deviation of Y - coordinate [unit] ; iYrange = p15 ; possible range of deviation of X - coordinate [unit] ; iZrange = p16 ; possible range of deviation of Z - coordinate [unit] ; CONTROL DISTRIBUTION FN ; icrtlfn = p17 ; control distribution fn [21/31] ; COPIES ; icpydel = p18 ; delay time of copy [s] ; imaxcnt = p19 ; density of copy (number of instances) ; icnt = p20 ; count of copies (= initial count of original instrument: must always be 0 here) ; iXcpydev = p21 ; X - deviation (shift) of each copy [unit] ; iYcpydev = p22 ; Y - deviation (shift) of each copy [unit] ; iZcpydev = p23 ; Z - deviation (shift) of each copy [unit] ; ***************************************************************************************************************************************************** f 0 10.00 p1 const 71 p2 const 10 prec 2 ; density of grains p3 const 0.1 prec 2 ; duration of grains ; SOUND PRODUCTION ; Instrument for sound generation p4 const 30 ; instrument number of sound producing instrument p5 const 1 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation 1 = no deviation) p6 const 1 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation 1 = no deviation) ; Envelopes p7 const 11 ; instrument number of envelope generating instrument ; DEVIATION OF POSITION p8 const 0 ; deviation of position - X with carthesian coordinate invocation [unit] p9 const 0 ; deviation of position - Y with carthesian coordinate invocation [unit] p10 const 0 ; deviation of position - Z with carthesian coordinate invocation [unit] ; MOVEMENT OF GRAIN p11 const 0 ; X: amount of movement of a single grain in regard to the cloud [unit] p12 const 0 ; Y: amount of movement of a single grain in regard to the cloud [unit] p13 const 0 ; Z: amount of movement of a single grain in regard to the cloud [unit] ; FULL RANGE OF LOCATION DEVIATION p14 const 8 ; X-range: maximum angle deviation with carthesian coordinate invocation [units] p15 const 0 ; Y-range of elevation deviation [¡] / Y-dev with carthesian coordinate invocation [units] p16 const 0 ; Z-range of distance deviation [¡] / Z-dev with carthesian coordinate invocation [units] ; CONTROL DISTRIBUTION FN p17 const 21 ; control distribution fn ; CORRELATED COPY DEVICE p18 const 1 ; delay time of copy [s] p19 const 8 ; number of copies p20 const 0 ; count of copies (= initial count of original instrument: must always be 0) p21 const 1 ; X deviation (shift) of each copy with carthesian coordinate invocation [unit] p22 const 0 ; Y deviation (shift) of each copy with carthesian coordinate invocation [unit] p23 const 0 ; Z deviation (shift) of each copy with carthesian coordinate invocation [unit] /usr/local/bin/cmask $infile $outfile Python 10.125 0.0 Simple AED-Granulator -12566464 2 ; iinst = p4 ; instrument number of sound producing instrument ; iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ; ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ; ENVELOPES ; ienvinst = p7 ; instrument number of envelope generating instrument ; POSITION AND MOVEMENT ; iAdev = p8 ; deviation of position of grain - angle [¡] ; iEdev = p9 ; deviation of position of grain - elevation [¡] ; iDdev = p10 ; deviation of position of grain - distance [unit] ; iAmove = p11 ; A - amount of movement of a single grain in regard to the cloud [¡] ; iEmove = p12 ; E - amount of movement of a single grain in regard to the cloud [¡] ; iDmove = p13 ; D - amount of movement of a single grain in regard to the cloud [unit] ; ***************************************************************************************************************************************************** f 0 10.00 p1 const 72 p2 const 10 prec 2 ; density of grains p3 const 0.1 prec 2 ; duration of grains ; SOUND PRODUCTION ; Instrument for sound generation p4 const 30 ; instrument number of sound producing instrument p5 const 1 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation 1 = no deviation) p6 const 1 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation 1 = no deviation) ; Envelopes p7 const 11 ; instrument number of envelope generating instrument p8 const 0 ; deviation of position - angle [degrees] (start) p9 const 0 ; deviation of position - elevation [degrees](start) p10 const 0 ; deviation of position - distance (start) ; MOVEMENT OF GRAIN p11 const 0 ; A: amount of movement of a single grain in regard to the cloud [¡] p12 const 0 ; E: amount of movement of a single grain in regard to the cloud [¡] p13 const 0 ; D: amount of movement of a single grain in regard to the cloud [¡] /usr/local/bin/cmask $infile $outfile Python 10.125 0.0 Simple XYZ-Granulator -12566464 2 ; iinst = p4 ; instrument number of sound producing instrument ; iampdev = p5 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation) ; ifreqdev = p6 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation) ; ENVELOPES ; ienvinst = p7 ; instrument number of envelope generating instrument ; POSITION AND MOVEMENT ; iXdev = p8 ; deviation of position of grain - X-coordinate [unit] ; iYdev = p9 ; deviation of position of grain - Y-coordinate [unit] ; iZdev = p10 ; deviation of position of grain - Z-coordinate [unit] ; iXmove = p11 ; X amount of movement of a single grain in regard to the cloud [unit] ; iYmove = p12 ; Y amount of movement of a single grain in regard to the cloud [unit] ; iZmove = p13 ; Z amount of movement of a single grain in regard to the cloud [unit] ; ***************************************************************************************************************************************************** f 0 10.00 p1 const 73 p2 const 10 prec 2 ; density of grains p3 const 0.1 prec 2 ; duration of grains ; SOUND PRODUCTION ; Instrument for sound generation p4 const 30 ; instrument number of sound producing instrument p5 const 1 ; amplitude deviation factor (0.5 = 50% amplitude, 2 = 200% amplitude deviation 1 = no deviation) p6 const 1 ; frequency deviation factor (0.5 = 50% frequency, 2 = 200% frequency deviation 1 = no deviation) ; Envelopes p7 const 11 ; instrument number of envelope generating instrument ; DEVIATION OF POSITION p8 const 0 ; deviation of position - X with carthesian coordinate invocation [unit] p9 const 0 ; deviation of position - Y with carthesian coordinate invocation [unit] p10 const 0 ; deviation of position - Z with carthesian coordinate invocation [unit] ; MOVEMENT OF GRAIN p11 const 0 ; X: amount of movement of a single grain in regard to the cloud [unit] p12 const 0 ; Y: amount of movement of a single grain in regard to the cloud [unit] p13 const 0 ; Z: amount of movement of a single grain in regard to the cloud [unit] /usr/local/bin/cmask $infile $outfile Python 2.0 0.0 GenericScore -12566464 0 i66 0 2 90 2000 true Version 3 - setksmps 1 in GLOBALREVERB UDO - Extension to 3rd order in the encoding-UDO - Extension to 3rd order in the soundfile wrting orc instr 80 - Reorder of Zak a-Rate channels in initialisation, the global code section, instr 78 (spatial global reverb) and in instr 80 - Reorder of global init section Version 6 - Reorder of k-rate zak-channels - Instr. 53: bugfix - p 13-15 translated to x,y,z - effect added in instr. 12 and 54 Version 7 Bugfix: Channel y and z were merged in versions 3-6 Version 8 UDO opcode UHJ_Decode added Binaural_Decode_2nd_order added Binaural_Decode_3rd_order added Version 9 Import of Stevens instr.2 Version 10 final version to present at the LAC Version 11 alligning of code renaming of XYZ Conversion UDO and Encoding UDO Version 12 Moved definition of Diffreflection and Specrflection from global orc to UDO Version 13 Changed all instruments to degree instead of pi Version 14 Version 15 Reorganisation of Instruments: Subinstruments get inroduced Version 16 Zak-Patch to Subinstr Version 17 Duration control ajustment: zak patch does not work for several instances, adressing different dur of subinstr only with schedule-opcode sound: short (= p3) effect: longer (+ reverbtime) spatialisation : even longer (+giprolong) Version 18 introduction of lnleta and connect opcodes Version 19 Separation of instr. 52 into 2 parts: before and after effects due to source-sink restrictions. Version 20 Rewireing of the signal flow. if then else-modifications. Failed to introdiuce of different durartions for the effects. Version 21 Envelope 1 * 2 to effects. Different durations and prolongation now work. Version 22 Added Simple xyz spatializer Version23 Reordering of parameter Complex AED Granulator Version 24 : Test Version 25: changed schedule to alwayson in most cases amplitude discontinuety + feedback resolved iskip = 1 on reverbsc Version 26 additive synth introduced Version 51 k rate automatisation-line for AED Granulator, siple and complex. Copy device changed. BUGS Command z does not work in scratchpad Blue Manual does not start up [] and || do not work in orchestra - window, sound object editor 0.0 -1.0 false false false PCH MIDI 12TET 261.62558 2.0 1.0 1.0594631 1.122462 1.1892071 1.2599211 1.3348398 1.4142135 1.4983071 1.587401 1.6817929 1.7817974 1.8877486