/*Getting started.. Realtime Interaction: MIDI Notes / MIDI Synth Generating the frequency for one voice, has to become computed individually for each midi note. So a new instance of instr 1 is started for every key pressed on the keyboard. Instruments 101 (Feedback Delay) and 102 (Reverb) are global effects, which are not necessary to compute for each individual voice independently. So started once from the score, one instance each runs constantly whether a note is played or not. The Widget Panel, gives access to some of their parameters. You can add more.. */ --midi-key-cps=4 --midi-velocity=5 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 gaOut init 0.0 ; a global audio variable is initialised, this can be seen as an "global audio Bus" (g.a.Bus), where audiodata can be send and read from, but first it is NULL instr 1 ; Sawthooth Oscillator triggered with notes on MIDI CH: 1 icps = p4 iamp = p5/127 ; MIDI received velocity (from 0-127), becomes devided by 127 -> amplitude-range is now 0-1 kFfreq invalue "filter_freq" kFfreq port kFfreq, 0.05 aSrc oscili iamp, icps, 1 ; reads form f-table 1, containing a sawthooth waveform aFiltered moogvcf aSrc, kFfreq, 0.1 ; the source signal becomes low pass filtered aEnv madsr 0.01, 0.1, 0.9, 0.01 ; defining the envelope gaOut = (aFiltered*aEnv) + gaOut ; the signal becomes scaled by the envelope and is added to the "g.a.Bus" ; that no information (from other sources, or simultaneous voices) which already exists on the global variable will be lost, itself needs to become added as well endin instr 2 ; Sine Oscillator triggered with notes on MIDI CH: 2 icps = p4 iamp = p5/127 aSrc oscili iamp, icps, 2 ; this instrument reads from f-table 2, containing a sinus waveform aEnv madsr 0.01, 0.1, 0.9, 0.01 ; defining the envelope gaOut = (aSrc*aEnv) + gaOut endin instr 101 ; Global Feedback Delay kDryWet invalue "d_w_delay" ; receive values from the Widget Panel kDelTime invalue "time_delay" kFeedback invalue "feedb_delay" aDelay delayr 1 ; a delayline, with 1 second maximum delay-time is initialised aWet deltapi kDelTime ; data at a flexible position is read from the delayline delayw gaOut+(aWet*kFeedback) ; the "g.a.Bus" is written to the delayline, - to get a feedbackdelay, the delaysignal (aWet) is also added, but scaled by kFeedback gaOut = (1-kDryWet) * gaOut + (kDryWet * aWet) ; the amount of pure-signal and delayed-signal is mixed, and written to the "g.a.Bus" endin instr 102 ; Global Reverb kroomsize init 0.4 ; fixed values for reverb-roomsize and damp, but you can add knobs or faders on the Widget Panel and invalue the data here... khfdamp init 0.8 kDryWet invalue "d_w_reverb" aWetL, aWetR freeverb gaOut, gaOut, kroomsize, khfdamp ; the freeverb opcode works with stereo input, so we read twice the "g.a.Bus" aOutL = (1-kDryWet) * gaOut + (kDryWet * aWetL) ; the amount of pure-signal (g.a.Bus) and reverbed-signal for the left side is mixed, and written to a local variable aOutR = (1-kDryWet) * gaOut + (kDryWet * aWetR) outs aOutL, aOutR ; main output of the final signal gaOut = 0.0 ; clear the global audio channel for the next k-loop endin f 1 0 1024 7 0 512 1 0 -1 512 0 f 2 0 1024 10 1 i 101 0 3600 ; the delay runs for one hour i 102 0 3600 ; the reverb runs for one hour e ; written by Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover 1013 279 563 397 true 182 109 0 d_w_reverb 22 458 311 38 {965ddedd-20e0-4abd-859a-dfd4ff860060} true 0 -3 0.00000000 1.00000000 0.18971100 lin continuous -1.00000000 false 22 421 131 35 {26d8fbb2-0a09-4332-9b18-5cc0250b8cf2} true 0 -3 left top Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 0 d_w_delay 22 277 311 38 {b8bc48f2-c2b1-4687-85e7-1066b06a33c7} true 0 -3 0.00000000 1.00000000 0.07074000 lin continuous -1.00000000 false 22 240 131 35 {1c5ee867-4ad1-434f-a5e0-6ea3dafd89b3} true 0 -3 left top Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 0 time_delay 244 147 20 100 {8dbbbd5a-8e3f-48ad-9b17-4d4ec077d56f} true 0 -3 0.05000000 1.00000000 0.35400000 lin continuous -1.00000000 false feedb_delay 313 148 20 100 {60c2bf77-6001-4508-98c7-9b589819aee1} true 0 -3 0.05000000 1.00000000 0.47750000 lin continuous -1.00000000 false 235 121 45 23 {db1823ae-b35e-452a-9d18-71821c7feb40} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 294 121 57 23 {d7b1bce9-3493-4b44-81cb-6fe3917d3e79} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 22 116 184 35 {bff2f5ef-9393-4a63-be7d-f9ba7f9e6ed9} true 0 -3 left top Noto Sans 18 3 0 0 0 255 255 255 true 1 1 21 313 80 25 {f1ea1508-3b35-40d8-8a18-b3866212a5cd} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 294 315 37 27 {8e7b41c0-8c87-4bea-ad04-4b8cf886cd69} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 22 494 80 25 {0e2fb652-9ae9-43f4-b61e-b22ab50a5607} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 296 494 37 25 {6dbb3852-766d-478f-a270-db1249eca234} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 20 381 184 35 {2c94e6b7-a8b7-4a2c-a420-a95fc5a7fd7a} true 0 -3 left top Noto Sans 18 3 0 0 0 255 255 255 true 1 1 223 250 69 24 {71d02974-0a9e-46d9-9bf5-13f597e24907} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 300 251 69 24 {9805b83f-cbfb-4f90-bc8a-4fb9d0cf4bc4} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 19 44 273 25 {93d0d968-20d9-4e1a-b1c0-224bf6a4f360} true 0 -3 left top Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 0 19 9 184 35 {f8582472-2877-4113-8834-13da608069b8} true 0 -3 left top Noto Sans 18 3 0 0 0 255 255 255 true 1 1 filter_freq 18 68 311 38 {b868baaf-46dd-40eb-8b7b-f7afa7925c6a} true 0 -3 10.00000000 5000.00000000 1919.35691300 lin continuous -1.00000000 false