/*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
00612448true1821090d_w_reverb2255531138{c076d729-6955-41f6-ac73-629c2cab5f0d}true0-30.000000001.000000000.00000000lincontinuous-1.00000000false2251813135{0cea1de3-74da-4524-a540-23addd966011}true0-3left
Lucida Grande
183000255255255noborder11d_w_delay2237431138{922a0a2a-8eed-4e80-91e5-3aadcb71a060}true0-30.000000001.000000000.37007874lincontinuous-1.00000000false2233713135{3ff84f21-e00d-4675-ab60-662f75bd60c1}true0-3left
Lucida Grande
183000255255255noborder11time_delay24424420100{3d18f824-aa11-4227-b986-1e2c8e12b0b8}true0-30.050000001.000000000.51377953lincontinuous-1.00000000falsefeedb_delay31324520100{392d91e1-4001-4d09-b521-3467c922dbe2}true0-30.050000001.000000000.69330709lincontinuous-1.00000000false2352184523{106d943f-998f-4d9e-a300-9f3c91b38e30}true0-3left
Lucida Grande
103000255255255noborder112942185723{f871526f-50dd-46ec-852a-01f39b0692a9}true0-3left
Lucida Grande
103000255255255noborder112221318435{d56458a9-29ed-45b4-816f-2db8b87ffdf7}true0-3left
Lucida Grande
223000255255255border11214108025{0fd32071-b415-4c8d-a9b7-455744370f58}true0-3left
Lucida Grande
103000255255255noborder112944123727{257153de-9a52-48ae-8aab-4f0fb204a66b}true0-3left
Lucida Grande
103000255255255noborder11225918025{d5652849-5d18-495b-bc7a-a81d2f15316d}true0-3left
Lucida Grande
103000255255255noborder112965913725{120e4e24-568b-4bbe-a3a7-43ed34089d17}true0-3left
Lucida Grande
103000255255255noborder112047818435{f566b738-ccc0-4283-8287-be91e3b9a351}true0-3left
Lucida Grande
223000255255255border112233476924{9d25d798-954f-4549-9d48-e10369807683}true0-3left
Lucida Grande
103000255255255noborder113003486924{3ee1d5a4-b581-4319-a8de-26fabbe95d40}true0-3left
Lucida Grande
103000255255255noborder111914127325{b2f8fd33-54ec-4ff9-8803-dcb89ec05e3c}true0-3left
Lucida Grande
103000255255255noborder112010718435{172b8328-7006-487e-87da-27b3695a1a45}true0-3left
Lucida Grande
223000255255255border11filter_freq1816531138{574b3b76-4995-4fb1-b9e1-31ad77c029d2}true0-310.000000005000.000000002799.68503937lincontinuous-1.00000000false38210731964{d18ce470-11ed-434a-bbd8-98477e376bd9}true0-3center
Lucida Grande
223000255255255border11ctrl#filt_freq5131785427{8d5f2d0a-0776-4d15-9eea-69841987be31}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false133316916935{4c09e980-3cfb-47df-a7e5-ed4952f1eb6e}true0-3center
Lucida Grande
223000255255255noborder11ctrl#_time_delay5132575427{de29e58d-a982-423b-8c5a-f2aa46523c0f}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false227825222136{5bb15b6f-9d48-4021-9771-8353d6e1b3e3}true0-3center
Lucida Grande
223000255255255noborder11ctrl#_feedb_delay5133125427{08b9db07-a9c2-4719-a643-ebd0aadb87eb}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false334230416239{7e4a0c4a-3301-4dca-89d2-b51ab69d96db}true0-3center
Lucida Grande
223000255255255noborder11ctrl#_d_w_delay5133855427{97d48604-93d4-45b3-abaa-f75e27f5f6a0}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false433837616935{e7548a16-df22-4177-ab2e-e892cd84e95f}true0-3center
Lucida Grande
223000255255255noborder11ctrl#_d_w_reverb5135655427{2e8f79eb-a3f8-42c6-8b25-4a37e47cdac9}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false633955616935{de76f066-3e92-479d-9be3-c263c8e042f7}true0-3center
Lucida Grande
223000255255255noborder11404626764{77d50ce2-bf4f-44b5-94ba-39526c642042}true0-3center
Lucida Grande
223000255255255border1117730464{a65a4b68-8a30-4af3-92bd-4eacbe852b09}true0-3center
Lucida Grande
223000255255255border11#midichn_slider511765427{384ec463-4788-4797-8e68-7878f406121e}true0-3right
Lucida Grande
100002552552551.00000000-1e+121e+12false147041025{b7d7027d-fa3d-4b6b-b631-f3cf5d65cfbc}true0-3left
Lucida Grande
123000255255255noborder11