/*Getting started.. Realtime Interaction: MIDI Assign Controllers In the example below, instrument 100 (which is "always on") receives the MIDI control data and sends it as global k-variables (gk...). You can choose the MIDI channel number and the controller numbers via the spinboxes in the widget panel. You can even change these numbers during the performance. As they are i-values, the opcodes 'reinit' and 'rireturn' are used to put the changes into force (for another examples, see Examples->Reinit_Example). In comparison to the example before, the sliders are not 'invalue'-ed to the instruments, so the only way to control the synth is via MIDI-CC's. The GUI is just for displaying, so 'outvalue' is used to send the CC-values to the Widget GUI. All the note-on-/note-off-messages must be sent on MIDI channel 1 (or you have to change the massign statement in the orchestra header). The statement massign 1, 101 sends all these messages to instrument 101. Each note here is added to the global audio variable -gaOut-. Instrument 102 adds the global feedback delay and the reverb, and finally zeros the -gaOut- variable for the next k-cycle. */ --midi-key-cps=4 --midi-velocity=5 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 gaOut init 0.0 massign 1, 101 ; assign all incoming midi from midi-chn 1 (= keyboard) to instr 101 (Sawthooth Oscillator) instr 100; MIDI CONTROLLER RECEIVE INSTRUMENT ; Get information for MIDI Channel and Controller Numbers from the Widget Panel kMidiChn_slider invalue "#midichn_slider" ; receive midi channel for the sliders kCtrlNo_filt_freq invalue "ctrl#filt_freq" ; receive controller number for filter frequency kCtrlNo_DelTime invalue "ctrl#_time_delay" ; receive controller number for delay time kCtrlNo_Feedback invalue "ctrl#_feedb_delay" ; receive controller number for delay time kCtrlNo_d_w_delay invalue "ctrl#_d_w_delay" ; receive controller number for delay wet-dry-mix kCtrlNo_d_w_reverb invalue "ctrl#_d_w_reverb" ; receive controller number for reverb wet-dry-mix ; Receive Values from the MIDI Sliders as global k-Variables midivalues: ;begin of a possible reinit section gkFilterCC1 ctrl7 i(kMidiChn_slider), i(kCtrlNo_filt_freq), 10, 5000 ; read 7-bit MIDI CC data and map to a range between 10-5000 gkDelTime ctrl7 i(kMidiChn_slider), i(kCtrlNo_DelTime), 0.05, 1 gkFeedback ctrl7 i(kMidiChn_slider), i(kCtrlNo_Feedback), 0.05, 1 gkDryWetDelay ctrl7 i(kMidiChn_slider), i(kCtrlNo_d_w_delay), 0, 1 gkDryWetReverb ctrl7 i(kMidiChn_slider), i(kCtrlNo_d_w_reverb), 0, 1 rireturn; end of a possible reinit section ; Reinit the label "midivalues" only, when a MIDI Channel or any of the CC Number assignments have changed kchanged changed kMidiChn_slider, kCtrlNo_filt_freq, kCtrlNo_DelTime, kCtrlNo_Feedback, kCtrlNo_d_w_delay, kCtrlNo_d_w_reverb if kchanged == 1 then reinit midivalues endif ; Send the MIDI-Values to the Widget Panel outvalue "filter_freq", gkFilterCC1 outvalue "feedb_delay", gkFeedback outvalue "d_w_delay", gkDryWetDelay outvalue "time_delay", gkDelTime outvalue "d_w_reverb", gkDryWetReverb endin instr 101 ; Sawthooth Oscillator triggered with notes on MIDI CH: 1 icps = p4 iamp = p5/127 kFfreq port gkFilterCC1, 0.05 aSrc oscili iamp, icps, 1 aFiltered moogvcf aSrc, kFfreq, 0.1 aEnv madsr 0.01, 0.1, 0.9, 0.01 gaOut = gaOut + aFiltered*aEnv endin instr 102; Global Feedback Delay and Reverb ; DELAY Section kDelTime port gkDelTime, 0.05 aDelTime = a(kDelTime) aDelay delayr 1 aWet deltapi aDelTime delayw gaOut+(aWet*gkFeedback) gaOut = (1-gkDryWetDelay) * gaOut + (gkDryWetDelay * aWet) ; REVERB Section kroomsize init 0.4 khfdamp init 0.8 aWetL, aWetR freeverb gaOut, gaOut, kroomsize, khfdamp aOutL = (1-gkDryWetReverb) * gaOut + (gkDryWetReverb * aWetL) aOutR = (1-gkDryWetReverb) * gaOut + (gkDryWetReverb * aWetR) outs aOutL, aOutR gaOut = 0.0 endin f 1 0 256 7 0 128 1 0 -1 128 0 i 100 0 3600 ; the MIDI CCs will be received for one hour i 102 0 3600 ; feedback-delay and reverb run for one hour e ; written by Joachim Heintz & Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover 0 0 612 448 true 182 109 0 d_w_reverb 22 555 311 38 {c076d729-6955-41f6-ac73-629c2cab5f0d} true 0 -3 0.00000000 1.00000000 0.00000000 lin continuous -1.00000000 false 22 518 131 35 {0cea1de3-74da-4524-a540-23addd966011} true 0 -3 left Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 d_w_delay 22 374 311 38 {922a0a2a-8eed-4e80-91e5-3aadcb71a060} true 0 -3 0.00000000 1.00000000 0.37007874 lin continuous -1.00000000 false 22 337 131 35 {3ff84f21-e00d-4675-ab60-662f75bd60c1} true 0 -3 left Lucida Grande 18 3 0 0 0 255 255 255 noborder 1 1 time_delay 244 244 20 100 {3d18f824-aa11-4227-b986-1e2c8e12b0b8} true 0 -3 0.05000000 1.00000000 0.51377953 lin continuous -1.00000000 false feedb_delay 313 245 20 100 {392d91e1-4001-4d09-b521-3467c922dbe2} true 0 -3 0.05000000 1.00000000 0.69330709 lin continuous -1.00000000 false 235 218 45 23 {106d943f-998f-4d9e-a300-9f3c91b38e30} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 294 218 57 23 {f871526f-50dd-46ec-852a-01f39b0692a9} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 22 213 184 35 {d56458a9-29ed-45b4-816f-2db8b87ffdf7} true 0 -3 left Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 21 410 80 25 {0fd32071-b415-4c8d-a9b7-455744370f58} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 294 412 37 27 {257153de-9a52-48ae-8aab-4f0fb204a66b} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 22 591 80 25 {d5652849-5d18-495b-bc7a-a81d2f15316d} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 296 591 37 25 {120e4e24-568b-4bbe-a3a7-43ed34089d17} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 20 478 184 35 {f566b738-ccc0-4283-8287-be91e3b9a351} true 0 -3 left Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 223 347 69 24 {9d25d798-954f-4549-9d48-e10369807683} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 300 348 69 24 {3ee1d5a4-b581-4319-a8de-26fabbe95d40} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 19 141 273 25 {b2f8fd33-54ec-4ff9-8803-dcb89ec05e3c} true 0 -3 left Lucida Grande 10 3 0 0 0 255 255 255 noborder 1 1 20 107 184 35 {172b8328-7006-487e-87da-27b3695a1a45} true 0 -3 left Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 filter_freq 18 165 311 38 {574b3b76-4995-4fb1-b9e1-31ad77c029d2} true 0 -3 10.00000000 5000.00000000 2799.68503937 lin continuous -1.00000000 false 382 107 319 64 {d18ce470-11ed-434a-bbd8-98477e376bd9} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 ctrl#filt_freq 513 178 54 27 {8d5f2d0a-0776-4d15-9eea-69841987be31} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 1 333 169 169 35 {4c09e980-3cfb-47df-a7e5-ed4952f1eb6e} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1 ctrl#_time_delay 513 257 54 27 {de29e58d-a982-423b-8c5a-f2aa46523c0f} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 2 278 252 221 36 {5bb15b6f-9d48-4021-9771-8353d6e1b3e3} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1 ctrl#_feedb_delay 513 312 54 27 {08b9db07-a9c2-4719-a643-ebd0aadb87eb} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 3 342 304 162 39 {7e4a0c4a-3301-4dca-89d2-b51ab69d96db} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1 ctrl#_d_w_delay 513 385 54 27 {97d48604-93d4-45b3-abaa-f75e27f5f6a0} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 4 338 376 169 35 {e7548a16-df22-4177-ab2e-e892cd84e95f} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1 ctrl#_d_w_reverb 513 565 54 27 {2e8f79eb-a3f8-42c6-8b25-4a37e47cdac9} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 6 339 556 169 35 {de76f066-3e92-479d-9be3-c263c8e042f7} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 noborder 1 1 404 6 267 64 {77d50ce2-bf4f-44b5-94ba-39526c642042} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 17 7 304 64 {a65a4b68-8a30-4af3-92bd-4eacbe852b09} true 0 -3 center Lucida Grande 22 3 0 0 0 255 255 255 border 1 1 #midichn_slider 511 76 54 27 {384ec463-4788-4797-8e68-7878f406121e} true 0 -3 right Lucida Grande 10 0 0 0 255 255 255 1.00000000 -1e+12 1e+12 false 1 4 70 410 25 {b7d7027d-fa3d-4b6b-b631-f3cf5d65cfbc} true 0 -3 left Lucida Grande 12 3 0 0 0 255 255 255 noborder 1 1