| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-Ma |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
sr = 44100 |
| 8 |
ksmps = 64 |
| 9 |
nchnls = 2 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
; By Joachim Heintz 2010 |
| 13 |
; This csd allows triggering multiple csound instruments from a single MIDI note. |
| 14 |
|
| 15 |
massign 0, 1; assign all incoming midi to instr 1 |
| 16 |
giInstrs ftgen 0, 0, -5, -2, 2, 3, 4, 10, 100; instruments to be triggered |
| 17 |
|
| 18 |
opcode MidiTrig, 0, io |
| 19 |
;triggers the first inum instruments in the function table ifn by a midi event, with fractional numbers containing channel and note number information |
| 20 |
ifn, inum xin; if inum=0 or not given, all instrument numbers in ifn are triggered |
| 21 |
inum = (inum == 0 ? ftlen(ifn) : inum) |
| 22 |
inote notnum |
| 23 |
ichn midichn |
| 24 |
iturnon = 0 |
| 25 |
turnon: |
| 26 |
iinstrnum tab_i iturnon, ifn |
| 27 |
if iinstrnum > 0 then |
| 28 |
ifracnum = iinstrnum + ichn/100 + inote/100000 |
| 29 |
event_i "i", ifracnum, 0, -1 |
| 30 |
endif |
| 31 |
loop_lt iturnon, 1, inum, turnon |
| 32 |
|
| 33 |
kend release |
| 34 |
if kend == 1 then |
| 35 |
kturnoff = 0 |
| 36 |
turnoff: |
| 37 |
kinstrnum tab kturnoff, ifn |
| 38 |
if kinstrnum > 0 then |
| 39 |
kfracnum = kinstrnum + ichn/100 + inote/100000 |
| 40 |
event "i", -kfracnum, 0, 1 |
| 41 |
loop_lt kturnoff, 1, inum, turnoff |
| 42 |
endif |
| 43 |
endif |
| 44 |
endop |
| 45 |
|
| 46 |
instr 1; global midi instrument |
| 47 |
MidiTrig giInstrs, 2; triggers the first two instruments in the giInstrs table |
| 48 |
endin |
| 49 |
|
| 50 |
instr 2 |
| 51 |
ichn = int(frac(p1)*100) |
| 52 |
inote = round(frac(frac(p1)*100)*1000) |
| 53 |
prints "instr %f: ichn = %f, inote = %f%n", p1, ichn, inote |
| 54 |
printks "instr %f playing!%n", 1, p1 |
| 55 |
endin |
| 56 |
|
| 57 |
instr 3 |
| 58 |
ichn = int(frac(p1)*100) |
| 59 |
inote = round(frac(frac(p1)*100)*1000) |
| 60 |
prints "instr %f: ichn = %f, inote = %f%n", p1, ichn, inote |
| 61 |
printks "instr %f playing!%n", 1, p1 |
| 62 |
endin |
| 63 |
|
| 64 |
|
| 65 |
</CsInstruments> |
| 66 |
<CsScore> |
| 67 |
f 0 36000 |
| 68 |
e |
| 69 |
</CsScore> |
| 70 |
</CsoundSynthesizer><bsbPanel> |
| 71 |
<label>Widgets</label> |
| 72 |
<objectName/> |
| 73 |
<x>757</x> |
| 74 |
<y>268</y> |
| 75 |
<width>253</width> |
| 76 |
<height>152</height> |
| 77 |
<visible>true</visible> |
| 78 |
<uuid/> |
| 79 |
<bgcolor mode="background"> |
| 80 |
<r>0</r> |
| 81 |
<g>0</g> |
| 82 |
<b>0</b> |
| 83 |
</bgcolor> |
| 84 |
<bsbObject version="2" type="BSBLabel"> |
| 85 |
<objectName/> |
| 86 |
<x>27</x> |
| 87 |
<y>12</y> |
| 88 |
<width>202</width> |
| 89 |
<height>127</height> |
| 90 |
<uuid>{4b805386-0c5c-4b8f-beb9-6464db5856f3}</uuid> |
| 91 |
<visible>true</visible> |
| 92 |
<midichan>0</midichan> |
| 93 |
<midicc>-3</midicc> |
| 94 |
<label>This csd shows how to layer csound instruments triggered by a single MIDI note.</label> |
| 95 |
<alignment>center</alignment> |
| 96 |
<font>Times New Roman</font> |
| 97 |
<fontsize>20</fontsize> |
| 98 |
<precision>3</precision> |
| 99 |
<color> |
| 100 |
<r>255</r> |
| 101 |
<g>255</g> |
| 102 |
<b>255</b> |
| 103 |
</color> |
| 104 |
<bgcolor mode="nobackground"> |
| 105 |
<r>255</r> |
| 106 |
<g>255</g> |
| 107 |
<b>255</b> |
| 108 |
</bgcolor> |
| 109 |
<bordermode>noborder</bordermode> |
| 110 |
<borderradius>1</borderradius> |
| 111 |
<borderwidth>1</borderwidth> |
| 112 |
</bsbObject> |
| 113 |
</bsbPanel> |
| 114 |
<bsbPresets> |
| 115 |
</bsbPresets> |
| 116 |
<MacGUI> |
| 117 |
ioView background {0, 0, 0} |
| 118 |
ioText {23, 24} {184, 78} label 0.000000 0.00100 "" center "Times New Roman" 20 {65280, 65280, 65280} {63232, 62720, 61952} nobackground noborder This csd shows how to layer csound instruments triggered by a single MIDI note. |
| 119 |
</MacGUI> |