Page  144 ï~~Csound GM: Designing Real-Time Instruments with Csound's New MIDI Opcodes Richard Boulanger, Berklee College of Music, rboulanger@it.berklee.edu Scott Vercoe, Analog Devices, Inc., scott.vercoe@analog.com Extended Csound presents composers and sound designers with many new opcodes and performance enhancements, particularly in the domain of MIDI control. This presentation illustrates many of Extended Csound's musical possibilities. macro NOTE;----- - -- >DEFINE a Macro (16) knot cpsmidib 2;------->CONVERT MIDI note with Pitchbend (2) ivel ampmidi 8000, givmp;---> SCALE and Map Kbd Velocity (2) veloffs;--------.....>SCALE Releases by NoteOff Velocity (11) endm macro VIBRATO kdpth midictrl 1, 0,.03;MODWHEEL controls vibrato depth kvibf midictrl 2, 1, 8;CONTROLLER 2 sets vibrato speed kvib oscil kdpth, kvibf, gisin;LFO with variable depth & speed cpsb = knot + (knot * kvib);ADD LFO to note endm macro CONTROLLERS kcutpls midictrl 3,.5, 1 kdetune midictrl 4, 1, 10 kwidpls midictrl 5,.1, 1 kswirl midictrl 6, 1, 6;MAPS and scales parameters;Ctl3-PulseWave Lowpass Cutoff;Ctl4-Coscil Detune Ratio;Ctl5-Width of Variable Pulse;Ctl6-Noise BandPass CntrFreq endm macro MIX kmstv midictrl 7, 0, 1 MASTER Volume Control ksmp midictrl 8, 0, 1 SAMPLE Layer Mix Control knois midictrl 9, 0, 1 NOISE Layer Mix Control kpuls midictrl 10, 0, 1 PULSE Layer Mix Control kchor midictrl11, 0,1;CHORUS Layer Mix Control amix = asmp * ksmp + anois * knois + apuls * kpuls + achor * kchor asig = amix * kmstv endm macro OUTPUTS kpan oscil.5,.25, gisin OSCILLATING Pan Function panouts asig, kpan +.5;------>PANNING Stereo Outs (13) gar,gac,gaf maddin asig,.4,.9,1;-->SCALE, Mix and Send (12) endm sr = 32000 kr = 100 ksmps = 320 nchnls= 2 gac init 0 INITIALIZE Global Send turnon 130;------ --------- >TURN on Chorus Instrument (1) gisin ftgen 1, 0, 8192, 10,1;-->GENERATE Functions (3) givmp ftgen 2, 0, 16, 5, 5, 16, 50 iapnol ftload "01F3.aif";----.> LOAD Samples (4) iapno2 ftload "01D#4.aif" iapno3 ftload "01C#5.aifr iapno4 ftload "01F#5.aifr iapno5 ftload "01B5.air iepnol ftload "06C4.air iepno2 ftload "06C5.aif';-----> SET Keyboard Splits and Sample-specific Parameter Values (5);Label Opcode Size Split Sample Basfrq Looptime Dec Rel iapnosplt ftsplit 5,6, 0, iapnol, 174.6, ftlptim(iapnol),.6,.02,\ 58, iapno2, 311.1, ftlptim(iapno2),.7,.02,\ 69, iapno3, 554.4, ftlptim(iapno3),.8,.025,\ 77, iapno4, 740, ftlptim(iapno4),.8,.025,\ 82, iapno5, 987.8, ftlptim(iapno5),.8,.025 iepnosplt ftsplit 2,6, 0, iepnol, 261.6, ftlptim(iepnol),.3,.007,\ 67, iepno2, 523.2, ftlptim(iepno2),.3,. 007;------- ---> MAP Samples to Program Change Messages (7) pgminit 1, iapnosplt;READ Acou. Piano Samples with MIDI Programl pgminit 2, iapnosplt;MIDI Program2 pgminit 3, iepnosplt;READ Elec. Piano Samples with MIDI Program3 pgminit 4, iepnosplt;MIDI program4;- > SET Initial Controller Values (8) pctrlinit 1, 1,5,2,84,3,96,4,50,5,100,6,64,7,100,8,100,9,10,10,20,11,19 pctrlinit 2, 1,45,2,94,3,76,4,90,5,90,6,84,7,100,8,80,9,60,10,40,11,59 pctrlinit 3, 1,5,2,84,3,86,4,60,5,100,6,64,7,100,8,120,9,9,10,11,11,6 pctrlinit 4,1,65,2,34,3,66,4,30,5,80,6,74,7,100,8,100,9,39,10,79,11,109 instr 1 vprogs 1, 2, 3, 4;INSTRUMENT mapped to specific program changes (9) clkon 1;SWITCH on clock to measure DSP load (15) NOTE VIBRATO CONTROLLERS;WAVETABLE Layer ift,ibsfreq,idel,idec,irel mtsplit vi;READ fisplit Data (from above) (6) kpre dexponr ivel, idel, idec, irel;Loop-Sensitive Sample envelope asmp loscil kpre, knot, ift, ibsfreq;SAMPLE oscillator; -......-> SWIRLING Noise Layer a2p rand 8000 kswsh oscil 15,.25, gisin a2 butterbp a2p, knot * kswirl, kswsh * 10 anois linenr a2,.6,.001;--------------- --- > (10) - --- > VARIABLE Pulse Layer k3v linsegr 0,.3, ivel,.3, ivel *.3,.02,.1;------- - > (10) k3ndx expsegr.0001,.1,.08,.8,.3,.3,.001;------>(10) a3p poscil k3v, kcpsb, k3ndx * kwidpls;- - -> (17) kswp linsegr 20, 2, 10000,.002, 100 apuls butterlp a3p, kswp * kcutpls S --- > CHORUSING Sine Wave Layer k4v adsr ivel, 0,.001, 2,.02,.8,.002, 0;---------------> (10) k4pch linsegr 4,.001, 1 achor coscil k4v, knot * k4pch, 7 * kdetune, gisin;----> (18) MIX OUTPUTS clkoff 1;------ -> (15) endin instr 130;----------> CHORUS Instrument achr chorusl gac,.5,.71,.93,.001,.002,.003,.03, 1,.3, gisin;-> (19) outsl2 achr;-- --- >(14) gac = 0 endin Extended Csound can be run from the orchestra alone. Instruments can be started using turnon (1) or played by a MIDI controller (2) or file. From within the orchestra, functions can be generated using figen (3) and samples loaded with fiload (4). Multisampled keyboard zones, and sample-specific paramater data are defined by ftsplit (5) and are called in the instrument by mtsplit (6). Program change messages can be used to associate an instrument with a set of sample data using pgminit (7), and to set initial controller values with pctrlinit (8). Furthermore, vprogs (9) allow a single instrument to respond to multiple program change messages, each with a unique set of sample and parameters. A new set of envelope generators adjust their release time in response to note-off messages(10); and with veloffs (11) these same unit generators will respond proportionally to release velocity. A virtual effects buss is supported by maddin (12). Mono audio signals are more effeciently routed thorugh panouts (13) and outsl2 (14). In fact, the efficiency of the sound design algorithm can be measured with cikon and cikoff (15), while macros (16) facilitate a more streamlined approach to instrument layout and design. Finally, new signal generators such as the variable pulse-width poscil (17), and the chorusing coscil (1 8) and signal processors such as chorus l (19) expand Csound's rich palate of sonic resources. Boulanger & Vercoe 144 ICMC Proceedings 1996