| 1 |
;Writen by Iain McCurdy, 2006 |
| 2 |
|
| 3 |
; Modified for QuteCsound by René, February 2011 |
| 4 |
; Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817 |
| 5 |
|
| 6 |
;Notes on modifications from original csd: |
| 7 |
; Number of MIDI activated instrument display |
| 8 |
|
| 9 |
;my flags on Ubuntu: -dm0 -odac -+rtaudio=alsa -b1024 -B2048 -+rtmidi=alsa -Ma |
| 10 |
<CsoundSynthesizer> |
| 11 |
<CsOptions> |
| 12 |
|
| 13 |
</CsOptions> |
| 14 |
<CsInstruments> |
| 15 |
sr = 44100 ;SAMPLE RATE |
| 16 |
ksmps = 128 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 17 |
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) |
| 18 |
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH |
| 19 |
|
| 20 |
|
| 21 |
instr 1 ; SIMPLE BEEP INSTRUMENT - CAN BE ACTIVATED VIA A CONNECTED MIDI KEYBOARD |
| 22 |
turnon 2 |
| 23 |
;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE |
| 24 |
asig oscili 0.2, 440, 1 |
| 25 |
|
| 26 |
outs asig, asig ;SEND AUDIO OUTPUT OF OSCILLATOR TO THE SPEAKERS |
| 27 |
endin |
| 28 |
|
| 29 |
instr 2 ;show Active instr |
| 30 |
kinstr active 1 |
| 31 |
|
| 32 |
Sinstr sprintfk "%01d", kinstr |
| 33 |
outvalue "Active", Sinstr |
| 34 |
endin |
| 35 |
</CsInstruments> |
| 36 |
<CsScore> |
| 37 |
f 1 0 1024 10 1 ; SINE WAVE |
| 38 |
f 0 600 ; THIS LINE FUNCTIONS AS A DUMMY SCORE EVENT AND ALLOWS REALTIME MIDI PLAYING FOR 10 MINUTES |
| 39 |
</CsScore> |
| 40 |
</CsoundSynthesizer> |
| 41 |
<bsbPanel> |
| 42 |
<label>Widgets</label> |
| 43 |
<objectName/> |
| 44 |
<x>645</x> |
| 45 |
<y>352</y> |
| 46 |
<width>580</width> |
| 47 |
<height>353</height> |
| 48 |
<visible>true</visible> |
| 49 |
<uuid/> |
| 50 |
<bgcolor mode="nobackground"> |
| 51 |
<r>170</r> |
| 52 |
<g>170</g> |
| 53 |
<b>170</b> |
| 54 |
</bgcolor> |
| 55 |
<bsbObject version="2" type="BSBLabel"> |
| 56 |
<objectName/> |
| 57 |
<x>2</x> |
| 58 |
<y>2</y> |
| 59 |
<width>574</width> |
| 60 |
<height>347</height> |
| 61 |
<uuid>{c37e13f6-7642-465f-9b2a-f059eef7bce8}</uuid> |
| 62 |
<visible>true</visible> |
| 63 |
<midichan>0</midichan> |
| 64 |
<midicc>0</midicc> |
| 65 |
<label> Activating an Instrument Through Realtime MIDI Control </label> |
| 66 |
<alignment>center</alignment> |
| 67 |
<font>Liberation Sans</font> |
| 68 |
<fontsize>18</fontsize> |
| 69 |
<precision>3</precision> |
| 70 |
<color> |
| 71 |
<r>0</r> |
| 72 |
<g>0</g> |
| 73 |
<b>0</b> |
| 74 |
</color> |
| 75 |
<bgcolor mode="background"> |
| 76 |
<r>244</r> |
| 77 |
<g>248</g> |
| 78 |
<b>200</b> |
| 79 |
</bgcolor> |
| 80 |
<bordermode>border</bordermode> |
| 81 |
<borderradius>5</borderradius> |
| 82 |
<borderwidth>2</borderwidth> |
| 83 |
</bsbObject> |
| 84 |
<bsbObject version="2" type="BSBLabel"> |
| 85 |
<objectName/> |
| 86 |
<x>5</x> |
| 87 |
<y>27</y> |
| 88 |
<width>567</width> |
| 89 |
<height>268</height> |
| 90 |
<uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid> |
| 91 |
<visible>true</visible> |
| 92 |
<midichan>0</midichan> |
| 93 |
<midicc>0</midicc> |
| 94 |
<label>------------------------------------------------------------------------------------------------------------------------------------------- |
| 95 |
Basic activation of csound instruments through the use of a connected MIDI keyboard is transparent to the user. The only requirement is that a Csound flag for live MIDI input is given so that Csound knows to expect MIDI information. |
| 96 |
For that, QuteCsound Configuration have to be settled to activate realtime MIDI. |
| 97 |
The number after the M flag selects which of your computer's MIDI input devices to use. |
| 98 |
If you are not sure use the 'all available devices' value 'a'. This example is very basic and merely produces a beep each time a note is played on your MIDI keyboard. Note duration corresponds with how long you hold the note for. Csound regards MIDI notes as held notes so there is no point in trying to use 'p3' in, for example envelopes, in the instrument code for a MIDI activated instrument. Polyphony is possible although it is rather difficult to hear in this example as all beeps are the same pitch. If an orchestra contains more that one instrument, MIDI notes on MIDI channel 1 will be directed to instrument 1, channel 2 will be directed to instrument 2 and so on. Modification to this default arrangement is possible using the 'massign' opcode.</label> |
| 99 |
<alignment>left</alignment> |
| 100 |
<font>Liberation Sans</font> |
| 101 |
<fontsize>14</fontsize> |
| 102 |
<precision>3</precision> |
| 103 |
<color> |
| 104 |
<r>0</r> |
| 105 |
<g>0</g> |
| 106 |
<b>0</b> |
| 107 |
</color> |
| 108 |
<bgcolor mode="nobackground"> |
| 109 |
<r>255</r> |
| 110 |
<g>255</g> |
| 111 |
<b>255</b> |
| 112 |
</bgcolor> |
| 113 |
<bordermode>noborder</bordermode> |
| 114 |
<borderradius>1</borderradius> |
| 115 |
<borderwidth>1</borderwidth> |
| 116 |
</bsbObject> |
| 117 |
<bsbObject version="2" type="BSBLabel"> |
| 118 |
<objectName/> |
| 119 |
<x>34</x> |
| 120 |
<y>292</y> |
| 121 |
<width>336</width> |
| 122 |
<height>49</height> |
| 123 |
<uuid>{b143f42f-2cbc-4532-8df7-4ba643c60b37}</uuid> |
| 124 |
<visible>true</visible> |
| 125 |
<midichan>0</midichan> |
| 126 |
<midicc>0</midicc> |
| 127 |
<label/> |
| 128 |
<alignment>left</alignment> |
| 129 |
<font>Liberation Sans</font> |
| 130 |
<fontsize>10</fontsize> |
| 131 |
<precision>3</precision> |
| 132 |
<color> |
| 133 |
<r>0</r> |
| 134 |
<g>0</g> |
| 135 |
<b>0</b> |
| 136 |
</color> |
| 137 |
<bgcolor mode="nobackground"> |
| 138 |
<r>255</r> |
| 139 |
<g>255</g> |
| 140 |
<b>255</b> |
| 141 |
</bgcolor> |
| 142 |
<bordermode>border</bordermode> |
| 143 |
<borderradius>5</borderradius> |
| 144 |
<borderwidth>2</borderwidth> |
| 145 |
</bsbObject> |
| 146 |
<bsbObject version="2" type="BSBDisplay"> |
| 147 |
<objectName>Active</objectName> |
| 148 |
<x>301</x> |
| 149 |
<y>299</y> |
| 150 |
<width>57</width> |
| 151 |
<height>33</height> |
| 152 |
<uuid>{c187dde0-d186-4ba8-a859-d88073b31b19}</uuid> |
| 153 |
<visible>true</visible> |
| 154 |
<midichan>0</midichan> |
| 155 |
<midicc>0</midicc> |
| 156 |
<label>0</label> |
| 157 |
<alignment>left</alignment> |
| 158 |
<font>Liberation Sans</font> |
| 159 |
<fontsize>18</fontsize> |
| 160 |
<precision>3</precision> |
| 161 |
<color> |
| 162 |
<r>255</r> |
| 163 |
<g>0</g> |
| 164 |
<b>0</b> |
| 165 |
</color> |
| 166 |
<bgcolor mode="nobackground"> |
| 167 |
<r>255</r> |
| 168 |
<g>255</g> |
| 169 |
<b>255</b> |
| 170 |
</bgcolor> |
| 171 |
<bordermode>noborder</bordermode> |
| 172 |
<borderradius>1</borderradius> |
| 173 |
<borderwidth>1</borderwidth> |
| 174 |
</bsbObject> |
| 175 |
<bsbObject version="2" type="BSBLabel"> |
| 176 |
<objectName/> |
| 177 |
<x>36</x> |
| 178 |
<y>300</y> |
| 179 |
<width>262</width> |
| 180 |
<height>31</height> |
| 181 |
<uuid>{a1ec3ab8-544e-4940-abf9-3c6fa212e12a}</uuid> |
| 182 |
<visible>true</visible> |
| 183 |
<midichan>0</midichan> |
| 184 |
<midicc>0</midicc> |
| 185 |
<label>Number of Midi activated instrument:</label> |
| 186 |
<alignment>right</alignment> |
| 187 |
<font>Liberation Sans</font> |
| 188 |
<fontsize>14</fontsize> |
| 189 |
<precision>3</precision> |
| 190 |
<color> |
| 191 |
<r>255</r> |
| 192 |
<g>0</g> |
| 193 |
<b>0</b> |
| 194 |
</color> |
| 195 |
<bgcolor mode="nobackground"> |
| 196 |
<r>255</r> |
| 197 |
<g>255</g> |
| 198 |
<b>255</b> |
| 199 |
</bgcolor> |
| 200 |
<bordermode>noborder</bordermode> |
| 201 |
<borderradius>1</borderradius> |
| 202 |
<borderwidth>1</borderwidth> |
| 203 |
</bsbObject> |
| 204 |
</bsbPanel> |
| 205 |
<bsbPresets> |
| 206 |
</bsbPresets> |