/*Getting started.. Realtime Interaction: MIDI Controller 01 (Modulation)
The quickest way to control instruments with MIDI control-data (Modulation, Aftertouch, etc.) can be set up, by using 'ctrl7' opcode. It can be used directly in an instrument definition, and outputs the desired k-rate data.
..
kMidiCC ctrl7 1, 1, 10, 5000 ; read 7-bit MIDI CC data from Ch.1, CC 01, and map to a range between 10-5000
aSrc oscili 0.8, kMidiCC, 1 ; now CC 01 controlls the frequency of this oscillator
..
The disadvantage of that method would be, that you have no communication with the Widget-GUI.
In the example below, a separate instrument (instr 100) is built to receive the MIDI CC 01 (Modulation) constantly and send its values on channel "filter_freq".
In Instrument 101 the data from this channel is read and mapped to the filters frequency input.
By sending MIDI-Control-Data 01 on Channel 1 (CC 01 - with your keyboards modualtion wheel, or any other MIDI faderbox) you see the Widget-fader moving and can hear the filter adjustments in realtime, when playing a note. Adjusting the fader with the mouse is also still possible.
*/
--midi-key-cps=4 --midi-velocity=5
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
massign 1, 101 ; send notes on MIDI Ch.1 to instr 101
gaOut init 0.0
instr 100 ; MIDI Controller Receive Instrument
kFilterCC1 ctrl7 1, 1, 10, 5000 ; read 7-bit MIDI CC data from Ch.1, CC1, and map to a range between 10-5000
printk2 kFilterCC1 ; print the value to the console
kChanged changed kFilterCC1 ; check if new values are incoming
if kChanged == 1 then ; so if, update the chanel..
outvalue "filter_freq", kFilterCC1 ; send the value to the widgetpanel
endif
endin
instr 101 ; Sawthooth Oscillator triggered by notes on MIDI CH: 1
icps = p4
iamp = p5/127
kFfreq invalue "filter_freq"
kFfreq port kFfreq, 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
kDryWet invalue "d_w_delay"
kDelTime invalue "time_delay"
kFeedback invalue "feedb_delay"
kDelTime port kDelTime, 0.05
aDelTime = a(kDelTime)
aDelay delayr 1
aWet deltapi aDelTime
delayw gaOut+(aWet*kFeedback)
gaOut = (1-kDryWet) * gaOut + (kDryWet * aWet)
endin
instr 103 ; Global Reverb
kroomsize init 0.4
khfdamp init 0.8
kDryWet invalue "d_w_reverb"
aWetL, aWetR freeverb gaOut, gaOut, kroomsize, khfdamp
aOutL = (1-kDryWet) * gaOut + (kDryWet * aWetL)
aOutR = (1-kDryWet) * gaOut + (kDryWet * 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 CC 01will become received for one hour
i 102 0 3600 ; the delay runs for one hour
i 103 0 3600 ; the reverb runs for one hour
e
; written by Alex Hofmann (Dec. 2009) - Incontri HMT-Hannover
00599453true1821090d_w_reverb2245831138{a933ecca-4f6f-4c37-8612-e80ccaeab1ff}true0-30.000000001.000000000.24437300lincontinuous-1.00000000false2242113135{8c2bf2d5-2f2a-4aa8-95f5-fd459644d3b3}true0-3left
Lucida Grande
183000255255255noborder11d_w_delay2227731138{252c3435-b659-4c63-a7eb-6d8ba725081a}true0-30.000000001.000000000.25723500lincontinuous-1.00000000false2224013135{b2a47e2f-a70f-4ac8-afd0-89ebec44cf27}true0-3left
Lucida Grande
183000255255255noborder11time_delay24414720100{9eda359f-2e35-416a-9486-75e2b8609bac}true0-30.050000001.000000000.40150000lincontinuous-1.00000000falsefeedb_delay31314820100{9b9faa01-b3b1-42b6-b3ea-942190c61015}true0-30.050000001.000000000.31600000lincontinuous-1.00000000false2351214523{a34714d9-8caa-4e71-993d-adc95b6d4ef6}true0-3left
Lucida Grande
103000255255255noborder112941215723{38d17cf1-8311-44a5-bbcd-e89f2a0a341e}true0-3left
Lucida Grande
103000255255255noborder112211618435{00c81148-ef01-44bb-af39-743e7597a9a3}true0-3left
Lucida Grande
223000255255255border11213138025{ff2f6506-d383-4b73-8cc8-325a13c76301}true0-3left
Lucida Grande
103000255255255noborder112943153727{deb507a6-bbc9-4875-ab32-b98d0fd9ca21}true0-3left
Lucida Grande
103000255255255noborder11224948025{1a2bb9cb-d541-4c5f-8c71-07b4c279ed43}true0-3left
Lucida Grande
103000255255255noborder112964943725{c0a097a0-f5e0-4041-a760-cb8edbe42625}true0-3left
Lucida Grande
103000255255255noborder112038118435{6a214d2b-c15f-4749-81a6-00a359668d41}true0-3left
Lucida Grande
223000255255255border112232506924{c6be046b-6565-487b-82aa-7153da5ce460}true0-3left
Lucida Grande
103000255255255noborder113002516924{9dcc5341-ac6e-4568-b661-9a08ffa7bafd}true0-3left
Lucida Grande
103000255255255noborder11194427325{5f7f6f96-32f1-47ba-a896-ca4f6e4eaf11}true0-3left
Lucida Grande
103000255255255noborder11201018435{2f8d8395-c26a-4531-a1a5-d94df807fac9}true0-3left
Lucida Grande
223000255255255border11filter_freq186831138{e0262b2c-5f78-4d11-9b16-1fd70b8bbefd}true0-310.000000005000.000000002288.39228300lincontinuous-1.00000000false