| 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 |
; Add kvolume display |
| 8 |
|
| 9 |
|
| 10 |
;my flags on Ubuntu: -dm0 -odac -+rtaudio=alsa -b1024 -B2048 -+rtmidi=alsa -Ma |
| 11 |
<CsoundSynthesizer> |
| 12 |
<CsOptions> |
| 13 |
|
| 14 |
</CsOptions> |
| 15 |
<CsInstruments> |
| 16 |
sr = 44100 ;SAMPLE RATE |
| 17 |
ksmps = 2 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 18 |
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) |
| 19 |
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH |
| 20 |
|
| 21 |
|
| 22 |
instr 1 ; SIMPLE BEEP INSTRUMENT - CAN BE ACTIVATED VIA A CONNECTED MIDI KEYBOARD |
| 23 |
icps cpsmidi |
| 24 |
iamp ampmidi 0.2 |
| 25 |
|
| 26 |
;OUTPUT OPCODE CHANNEL | CTRLNUMBER | MINIMUM | MAXIMUM |
| 27 |
kvolume ctrl7 1, 1, 0, 1 ;READ CONTROLLER INFORMATION FROM CONTINUOUS CONTROLLER NUMBER 1 ON MIDI CHANNEL 1 AND RESCALE TO BE WITHIN THE RANGE 0 - 1 |
| 28 |
|
| 29 |
outvalue "ctrl1", kvolume |
| 30 |
|
| 31 |
; INITIAL_LEVEL | ATTACK_TIME | ATTACK_LEVEL | DECAY_TIME | SUSTAIN_LEVEL | RELEASE_TIME | RELEASE_LEVEL |
| 32 |
aenv linsegr 0, (.01), 1, (.1), .7, (.05), 0 |
| 33 |
|
| 34 |
asig oscili iamp,icps, 1 |
| 35 |
outs asig * aenv * kvolume, asig * aenv * kvolume |
| 36 |
endin |
| 37 |
</CsInstruments> |
| 38 |
<CsScore> |
| 39 |
f 1 0 1024 10 1 ; SINE WAVE |
| 40 |
f 0 600 ; THIS LINE FUNCTIONS AS A DUMMY SCORE EVENT AND ALLOWS REALTIME MIDI PLAYING FOR 10 MINUTES |
| 41 |
</CsScore> |
| 42 |
</CsoundSynthesizer> |
| 43 |
<bsbPanel> |
| 44 |
<label>Widgets</label> |
| 45 |
<objectName/> |
| 46 |
<x>617</x> |
| 47 |
<y>498</y> |
| 48 |
<width>766</width> |
| 49 |
<height>375</height> |
| 50 |
<visible>true</visible> |
| 51 |
<uuid/> |
| 52 |
<bgcolor mode="nobackground"> |
| 53 |
<r>170</r> |
| 54 |
<g>170</g> |
| 55 |
<b>170</b> |
| 56 |
</bgcolor> |
| 57 |
<bsbObject version="2" type="BSBLabel"> |
| 58 |
<objectName/> |
| 59 |
<x>2</x> |
| 60 |
<y>2</y> |
| 61 |
<width>760</width> |
| 62 |
<height>369</height> |
| 63 |
<uuid>{c37e13f6-7642-465f-9b2a-f059eef7bce8}</uuid> |
| 64 |
<visible>true</visible> |
| 65 |
<midichan>0</midichan> |
| 66 |
<midicc>0</midicc> |
| 67 |
<label>ctrl7 - Reading Continuous Controller Data into Csound</label> |
| 68 |
<alignment>center</alignment> |
| 69 |
<font>Liberation Sans</font> |
| 70 |
<fontsize>18</fontsize> |
| 71 |
<precision>3</precision> |
| 72 |
<color> |
| 73 |
<r>0</r> |
| 74 |
<g>0</g> |
| 75 |
<b>0</b> |
| 76 |
</color> |
| 77 |
<bgcolor mode="background"> |
| 78 |
<r>244</r> |
| 79 |
<g>248</g> |
| 80 |
<b>200</b> |
| 81 |
</bgcolor> |
| 82 |
<bordermode>border</bordermode> |
| 83 |
<borderradius>5</borderradius> |
| 84 |
<borderwidth>2</borderwidth> |
| 85 |
</bsbObject> |
| 86 |
<bsbObject version="2" type="BSBLabel"> |
| 87 |
<objectName/> |
| 88 |
<x>6</x> |
| 89 |
<y>28</y> |
| 90 |
<width>750</width> |
| 91 |
<height>289</height> |
| 92 |
<uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid> |
| 93 |
<visible>true</visible> |
| 94 |
<midichan>0</midichan> |
| 95 |
<midicc>0</midicc> |
| 96 |
<label>----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 97 |
Ctrl7 is the best opcode to use for reading continuous controller data into csound for use as k-rate variables. Ctrl7 allows the user to specify the MIDI channel (1-16) and the controller number (0-127) associated with the controller. Therefore with 128 controllers on 16 different MIDI channels we have the possibility of using 2048 different MIDI controls! 7 bit MIDI controllers normally output integers within the range 0-127 but with ctrl7 we can rescale this by specifying a different output range. In this example MIDI controller 1 on MIDI channel 1 is used to implement a volume control on the simple synthesizer that has been built up over last few examples. (The modulation wheel on MIDI keyboards is also MIDI controller 1) The first thing that is noticed is that this example is silent until you move controller 1. This is because a controller always defaults to its minimum value until the controller is moved. The next example demonstrates how this can be initialised to a value other than the minimum. Another thing that you may notice is that when moving the controller is that a clicking noise (sometimes referred to as 'zipper' noise) can be heard, particularly when the controller is moved quickly. What is happening is that the k-rate output of ctrl7 is changing in large steps rather than in a continuously smooth line. If the control rate (kr) is low then this can aggrevate the problem. Another factor is that the resolution of 7 bit controllers is quite low (128 possible values). One solution is to use a 14 bit controller and the ctrl14 opcode but there are very few MIDI controller devices that provide adequate 14 bit controller support. Another possibility is to interpolate ctrl7's output up to a-rate (ctrl7 can only output at k-rate). Applying portamento to the output variable can help - this method is demonstrated in subsequent examples.</label> |
| 98 |
<alignment>left</alignment> |
| 99 |
<font>Liberation Sans</font> |
| 100 |
<fontsize>14</fontsize> |
| 101 |
<precision>3</precision> |
| 102 |
<color> |
| 103 |
<r>0</r> |
| 104 |
<g>0</g> |
| 105 |
<b>0</b> |
| 106 |
</color> |
| 107 |
<bgcolor mode="nobackground"> |
| 108 |
<r>255</r> |
| 109 |
<g>255</g> |
| 110 |
<b>255</b> |
| 111 |
</bgcolor> |
| 112 |
<bordermode>noborder</bordermode> |
| 113 |
<borderradius>1</borderradius> |
| 114 |
<borderwidth>1</borderwidth> |
| 115 |
</bsbObject> |
| 116 |
<bsbObject version="2" type="BSBLabel"> |
| 117 |
<objectName/> |
| 118 |
<x>6</x> |
| 119 |
<y>315</y> |
| 120 |
<width>188</width> |
| 121 |
<height>50</height> |
| 122 |
<uuid>{b143f42f-2cbc-4532-8df7-4ba643c60b37}</uuid> |
| 123 |
<visible>true</visible> |
| 124 |
<midichan>0</midichan> |
| 125 |
<midicc>0</midicc> |
| 126 |
<label/> |
| 127 |
<alignment>left</alignment> |
| 128 |
<font>Liberation Sans</font> |
| 129 |
<fontsize>10</fontsize> |
| 130 |
<precision>3</precision> |
| 131 |
<color> |
| 132 |
<r>0</r> |
| 133 |
<g>0</g> |
| 134 |
<b>0</b> |
| 135 |
</color> |
| 136 |
<bgcolor mode="nobackground"> |
| 137 |
<r>255</r> |
| 138 |
<g>255</g> |
| 139 |
<b>255</b> |
| 140 |
</bgcolor> |
| 141 |
<bordermode>border</bordermode> |
| 142 |
<borderradius>5</borderradius> |
| 143 |
<borderwidth>2</borderwidth> |
| 144 |
</bsbObject> |
| 145 |
<bsbObject version="2" type="BSBDisplay"> |
| 146 |
<objectName>ctrl1</objectName> |
| 147 |
<x>91</x> |
| 148 |
<y>327</y> |
| 149 |
<width>80</width> |
| 150 |
<height>25</height> |
| 151 |
<uuid>{f8119d82-f052-4a86-8790-440c42c5d41d}</uuid> |
| 152 |
<visible>true</visible> |
| 153 |
<midichan>0</midichan> |
| 154 |
<midicc>0</midicc> |
| 155 |
<label>0.087</label> |
| 156 |
<alignment>left</alignment> |
| 157 |
<font>Liberation Sans</font> |
| 158 |
<fontsize>12</fontsize> |
| 159 |
<precision>3</precision> |
| 160 |
<color> |
| 161 |
<r>255</r> |
| 162 |
<g>0</g> |
| 163 |
<b>0</b> |
| 164 |
</color> |
| 165 |
<bgcolor mode="nobackground"> |
| 166 |
<r>255</r> |
| 167 |
<g>255</g> |
| 168 |
<b>255</b> |
| 169 |
</bgcolor> |
| 170 |
<bordermode>noborder</bordermode> |
| 171 |
<borderradius>1</borderradius> |
| 172 |
<borderwidth>1</borderwidth> |
| 173 |
</bsbObject> |
| 174 |
<bsbObject version="2" type="BSBLabel"> |
| 175 |
<objectName/> |
| 176 |
<x>19</x> |
| 177 |
<y>324</y> |
| 178 |
<width>73</width> |
| 179 |
<height>31</height> |
| 180 |
<uuid>{4dc3e62f-8cd7-48cb-8f7f-25878ba3b97e}</uuid> |
| 181 |
<visible>true</visible> |
| 182 |
<midichan>0</midichan> |
| 183 |
<midicc>0</midicc> |
| 184 |
<label>kvolume:</label> |
| 185 |
<alignment>right</alignment> |
| 186 |
<font>Liberation Sans</font> |
| 187 |
<fontsize>14</fontsize> |
| 188 |
<precision>3</precision> |
| 189 |
<color> |
| 190 |
<r>255</r> |
| 191 |
<g>0</g> |
| 192 |
<b>0</b> |
| 193 |
</color> |
| 194 |
<bgcolor mode="nobackground"> |
| 195 |
<r>255</r> |
| 196 |
<g>255</g> |
| 197 |
<b>255</b> |
| 198 |
</bgcolor> |
| 199 |
<bordermode>noborder</bordermode> |
| 200 |
<borderradius>1</borderradius> |
| 201 |
<borderwidth>1</borderwidth> |
| 202 |
</bsbObject> |
| 203 |
</bsbPanel> |
| 204 |
<bsbPresets> |
| 205 |
</bsbPresets> |