| 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 Semitone Bend Range widget |
| 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 = 100 ;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 SINE TONE SYNTHESIZER WITH PITCH BEND |
| 23 |
ioct octmidi |
| 24 |
iamp ampmidi 0.2 |
| 25 |
|
| 26 |
;PITCH BEND INFORMATION IS READ |
| 27 |
kSemitoneBendRange invalue "BendRange" ;PITCH BEND RANGE IN SEMITONES (WILL BE DEFINED FURTHER LATER) |
| 28 |
imin = 0 ;EQUILIBRIUM POSITION |
| 29 |
imax = i(kSemitoneBendRange) * .0833333 ;MAX PITCH DISPLACEMENT (IN oct FORMAT) |
| 30 |
kbend pchbend imin, imax ;PITCH BEND VARIABLE (IN oct FORMAT) |
| 31 |
|
| 32 |
; INITIAL_LEVEL | ATTACK_TIME | ATTACK_LEVEL | DECAY_TIME | SUSTAIN_LEVEL | RELEASE_TIME | RELEASE_LEVEL |
| 33 |
aenv linsegr 0, (.01), 1, (.1), .5, (.2), 0 |
| 34 |
|
| 35 |
;OUTPUT OPCODE AMPLITUDE | FREQUENCY | FUNCTION_TABLE |
| 36 |
asig oscili iamp*aenv, cpsoct(ioct+kbend), 1 |
| 37 |
outs asig, asig ;SEND AUDIO OUTPUT OF OSCILLATOR TO THE SPEAKERS |
| 38 |
endin |
| 39 |
</CsInstruments> |
| 40 |
<CsScore> |
| 41 |
f 1 0 129 10 1 ;SINE WAVE |
| 42 |
f 0 600 ;THIS LINE FUNCTIONS AS A DUMMY SCORE EVENT AND ALLOWS REALTIME MIDI PLAYING FOR 10 MINUTES |
| 43 |
</CsScore> |
| 44 |
</CsoundSynthesizer> |
| 45 |
<bsbPanel> |
| 46 |
<label>Widgets</label> |
| 47 |
<objectName/> |
| 48 |
<x>848</x> |
| 49 |
<y>238</y> |
| 50 |
<width>584</width> |
| 51 |
<height>374</height> |
| 52 |
<visible>true</visible> |
| 53 |
<uuid/> |
| 54 |
<bgcolor mode="nobackground"> |
| 55 |
<r>170</r> |
| 56 |
<g>170</g> |
| 57 |
<b>170</b> |
| 58 |
</bgcolor> |
| 59 |
<bsbObject version="2" type="BSBLabel"> |
| 60 |
<objectName/> |
| 61 |
<x>2</x> |
| 62 |
<y>2</y> |
| 63 |
<width>578</width> |
| 64 |
<height>368</height> |
| 65 |
<uuid>{c37e13f6-7642-465f-9b2a-f059eef7bce8}</uuid> |
| 66 |
<visible>true</visible> |
| 67 |
<midichan>0</midichan> |
| 68 |
<midicc>0</midicc> |
| 69 |
<label>pchbend - Scanning MIDI Pitch Bend </label> |
| 70 |
<alignment>center</alignment> |
| 71 |
<font>Liberation Sans</font> |
| 72 |
<fontsize>18</fontsize> |
| 73 |
<precision>3</precision> |
| 74 |
<color> |
| 75 |
<r>0</r> |
| 76 |
<g>0</g> |
| 77 |
<b>0</b> |
| 78 |
</color> |
| 79 |
<bgcolor mode="background"> |
| 80 |
<r>244</r> |
| 81 |
<g>248</g> |
| 82 |
<b>200</b> |
| 83 |
</bgcolor> |
| 84 |
<bordermode>border</bordermode> |
| 85 |
<borderradius>5</borderradius> |
| 86 |
<borderwidth>2</borderwidth> |
| 87 |
</bsbObject> |
| 88 |
<bsbObject version="2" type="BSBLabel"> |
| 89 |
<objectName/> |
| 90 |
<x>6</x> |
| 91 |
<y>28</y> |
| 92 |
<width>569</width> |
| 93 |
<height>291</height> |
| 94 |
<uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid> |
| 95 |
<visible>true</visible> |
| 96 |
<midichan>0</midichan> |
| 97 |
<midicc>0</midicc> |
| 98 |
<label>-------------------------------------------------------------------------------------------------------------------------------------------- |
| 99 |
This example demonstrates how to scan the MIDI pitch bend wheel/joystick of a connected MIDI keyboard and to use the incoming data to implement the traditional pitch bend functionality. |
| 100 |
Building upon the simple sine tone synthesizer of previous examples the opcode 'pchbend' is employed to allow the player to bend the pitch up or down by semitones. |
| 101 |
Some additional mathematics and use of 'oct' format pitches are employed in the implementation of pitch bend in this example but I would recommend that you study the code for further information. |
| 102 |
There is nothing to say that the pitch bend wheel must be used to drive the pitch of something in Csound - it could also be used to control panning, sample playback speed and many other parameters in Csound. The crucial element in the design of the pitch bend wheel is in its used of a central spring loaded equilibrium position and ideally this feature should be capitalised upon when it is used in Csound.</label> |
| 103 |
<alignment>left</alignment> |
| 104 |
<font>Liberation Sans</font> |
| 105 |
<fontsize>14</fontsize> |
| 106 |
<precision>3</precision> |
| 107 |
<color> |
| 108 |
<r>0</r> |
| 109 |
<g>0</g> |
| 110 |
<b>0</b> |
| 111 |
</color> |
| 112 |
<bgcolor mode="nobackground"> |
| 113 |
<r>255</r> |
| 114 |
<g>255</g> |
| 115 |
<b>255</b> |
| 116 |
</bgcolor> |
| 117 |
<bordermode>noborder</bordermode> |
| 118 |
<borderradius>1</borderradius> |
| 119 |
<borderwidth>1</borderwidth> |
| 120 |
</bsbObject> |
| 121 |
<bsbObject version="2" type="BSBLabel"> |
| 122 |
<objectName/> |
| 123 |
<x>6</x> |
| 124 |
<y>315</y> |
| 125 |
<width>216</width> |
| 126 |
<height>50</height> |
| 127 |
<uuid>{b143f42f-2cbc-4532-8df7-4ba643c60b37}</uuid> |
| 128 |
<visible>true</visible> |
| 129 |
<midichan>0</midichan> |
| 130 |
<midicc>0</midicc> |
| 131 |
<label/> |
| 132 |
<alignment>left</alignment> |
| 133 |
<font>Liberation Sans</font> |
| 134 |
<fontsize>10</fontsize> |
| 135 |
<precision>3</precision> |
| 136 |
<color> |
| 137 |
<r>0</r> |
| 138 |
<g>0</g> |
| 139 |
<b>0</b> |
| 140 |
</color> |
| 141 |
<bgcolor mode="nobackground"> |
| 142 |
<r>255</r> |
| 143 |
<g>255</g> |
| 144 |
<b>255</b> |
| 145 |
</bgcolor> |
| 146 |
<bordermode>border</bordermode> |
| 147 |
<borderradius>5</borderradius> |
| 148 |
<borderwidth>2</borderwidth> |
| 149 |
</bsbObject> |
| 150 |
<bsbObject version="2" type="BSBLabel"> |
| 151 |
<objectName/> |
| 152 |
<x>10</x> |
| 153 |
<y>326</y> |
| 154 |
<width>158</width> |
| 155 |
<height>35</height> |
| 156 |
<uuid>{4dc3e62f-8cd7-48cb-8f7f-25878ba3b97e}</uuid> |
| 157 |
<visible>true</visible> |
| 158 |
<midichan>0</midichan> |
| 159 |
<midicc>0</midicc> |
| 160 |
<label>Semitone Bend Range:</label> |
| 161 |
<alignment>right</alignment> |
| 162 |
<font>Liberation Sans</font> |
| 163 |
<fontsize>14</fontsize> |
| 164 |
<precision>3</precision> |
| 165 |
<color> |
| 166 |
<r>0</r> |
| 167 |
<g>0</g> |
| 168 |
<b>0</b> |
| 169 |
</color> |
| 170 |
<bgcolor mode="nobackground"> |
| 171 |
<r>255</r> |
| 172 |
<g>255</g> |
| 173 |
<b>255</b> |
| 174 |
</bgcolor> |
| 175 |
<bordermode>noborder</bordermode> |
| 176 |
<borderradius>1</borderradius> |
| 177 |
<borderwidth>1</borderwidth> |
| 178 |
</bsbObject> |
| 179 |
<bsbObject version="2" type="BSBSpinBox"> |
| 180 |
<objectName>BendRange</objectName> |
| 181 |
<x>169</x> |
| 182 |
<y>322</y> |
| 183 |
<width>46</width> |
| 184 |
<height>35</height> |
| 185 |
<uuid>{ab5f68dc-b46a-4605-884c-0d87dcdb2801}</uuid> |
| 186 |
<visible>true</visible> |
| 187 |
<midichan>0</midichan> |
| 188 |
<midicc>0</midicc> |
| 189 |
<alignment>center</alignment> |
| 190 |
<font>Liberation Sans</font> |
| 191 |
<fontsize>16</fontsize> |
| 192 |
<color> |
| 193 |
<r>0</r> |
| 194 |
<g>0</g> |
| 195 |
<b>0</b> |
| 196 |
</color> |
| 197 |
<bgcolor mode="nobackground"> |
| 198 |
<r>255</r> |
| 199 |
<g>255</g> |
| 200 |
<b>255</b> |
| 201 |
</bgcolor> |
| 202 |
<resolution>1.00000000</resolution> |
| 203 |
<minimum>1</minimum> |
| 204 |
<maximum>24</maximum> |
| 205 |
<randomizable group="0">false</randomizable> |
| 206 |
<value>12</value> |
| 207 |
</bsbObject> |
| 208 |
</bsbPanel> |
| 209 |
<bsbPresets> |
| 210 |
</bsbPresets> |