| 1 |
;Written by Iain McCurdy, 2011 |
| 2 |
|
| 3 |
;Modified for QuteCsound by René, March 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 Tempo SpinBox widget |
| 8 |
|
| 9 |
|
| 10 |
;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0 |
| 11 |
<CsoundSynthesizer> |
| 12 |
<CsOptions> |
| 13 |
|
| 14 |
</CsOptions> |
| 15 |
<CsInstruments> |
| 16 |
sr = 44100 ;SAMPLE RATE |
| 17 |
ksmps = 10 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 18 |
nchnls = 1 ;NUMBER OF CHANNELS (2=STEREO) |
| 19 |
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH |
| 20 |
|
| 21 |
|
| 22 |
; 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16 |
| 23 |
gi1 ftgen 0,0,16,2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0 ;BASS DRUM |
| 24 |
gi2 ftgen 0,0,16,2, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1 ;KALIMBA |
| 25 |
gi3 ftgen 0,0,16,2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0 ;SNARE |
| 26 |
gi4 ftgen 0,0,16,2, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 ;CLOSED HI-HAT |
| 27 |
gi5 ftgen 0,0,16,2, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1 ;OPEN HI-HAT |
| 28 |
gi6 ftgen 0,0,16,2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ;TAMBOURINE |
| 29 |
gisine ftgen 0,0,4096,10,1 ;SINE |
| 30 |
|
| 31 |
gindx init 0 |
| 32 |
|
| 33 |
|
| 34 |
instr 1 |
| 35 |
ktempo invalue "Tempo" |
| 36 |
ktick metro (ktempo*4)/60 |
| 37 |
schedkwhen ktick, 0, 0, 2, 0, 0.001, 0 |
| 38 |
endin |
| 39 |
|
| 40 |
instr 2 |
| 41 |
#define VOICE(N) |
| 42 |
# |
| 43 |
iOnOff$N table gindx, gi$N |
| 44 |
schedkwhen iOnOff$N, 0, 0, p1+$N, 0, 0.2 |
| 45 |
# |
| 46 |
$VOICE(1) |
| 47 |
$VOICE(2) |
| 48 |
$VOICE(3) |
| 49 |
$VOICE(4) |
| 50 |
$VOICE(5) |
| 51 |
$VOICE(6) |
| 52 |
gindx wrap gindx+1, 0, 16 |
| 53 |
turnoff |
| 54 |
endin |
| 55 |
|
| 56 |
instr 3 ;SOUND 1 - BASS DRUM |
| 57 |
p3 = 0.2 ;DEFINE DURATION FOR THIS SOUND |
| 58 |
aenv expon rnd(0.5)+0.5,p3,0.001 ;AMPLITUDE ENVELOPE - PERCUSSIVE DECAY |
| 59 |
kcps expon 200,p3,20 ;PITCH GLISSANDO |
| 60 |
asig oscil aenv*0.5, kcps, gisine ;OSCILLATOR |
| 61 |
out asig ;SEND AUDIO TO OUTPUTS |
| 62 |
endin |
| 63 |
|
| 64 |
instr 4 ;SOUND 2 - KALIMBA (BAR MODEL) |
| 65 |
p3 = 2.6 ;DEFINE DURATION FOR THIS SOUND |
| 66 |
asig barmodel 1, 1, 80, 1, 0, 2.6, 0.5, 6000, 0.07 ;KALIMBA SOUND CREATED USING barmodel OPCODE (SEE CSOUND MANUAL FOR MORE INFO.) |
| 67 |
out asig*(rnd(0.5)+0.5)*0.1 ;SEND AUDIO TO OUTPUTS AND ATTENUATE USING GAIN CONTROLS |
| 68 |
endin |
| 69 |
|
| 70 |
instr 5 ;SOUND 3 - SNARE |
| 71 |
p3 = 0.15 ;DEFINE DURATION FOR THIS SOUND |
| 72 |
aenv expon rnd(0.5)+0.5,p3,0.001 ;AMPLITUDE ENVELOPE - PERCUSSIVE DECAY |
| 73 |
anse noise 1, 0 ;CREATE NOISE COMPONENT FOR SNARE DRUM SOUND |
| 74 |
kcps expon 400,p3,20 ;CREATE TONE COMPONENT FREQUENCY GLISSANDO FOR SNARE DRUM SOUND |
| 75 |
ajit randomi 0.2,1.8,10000 ;JITTER ON FREQUENCY FOR TONE COMPONENT |
| 76 |
atne oscil aenv,kcps*ajit,gisine ;CREATE TONE COMPONENT |
| 77 |
asig sum anse*0.5, atne*5 ;MIX NOISE AND TONE SOUND COMPONENTS |
| 78 |
ares comb asig, 0.02, 0.0035 ;PASS SIGNAL THROUGH A COMB FILTER TO CREATE STATIC HARMONIC RESONANCE |
| 79 |
out ares*aenv*0.1 ;SEND AUDIO TO OUTPUTS, APPLY ENVELOPE AND ATTENTUATE USING GAIN CONTROLS |
| 80 |
endin |
| 81 |
|
| 82 |
instr 6 ;SOUND 4 - CLOSED HI-HAT |
| 83 |
turnoff2 7,0,0 ;TURN OFF ALL INSTANCES OF instr 7 (OPEN HI-HAT) |
| 84 |
p3 = 0.1 ;DEFINE DURATION FOR THIS SOUND |
| 85 |
aenv expon rnd(0.5)+0.5,p3,0.001 ;AMPLITUDE ENVELOPE - PERCUSSIVE DECAY |
| 86 |
asig noise aenv*0.3, 0 ;CREATE SOUND FOR CLOSED HI-HAT |
| 87 |
asig buthp asig, 7000 ;HIGHPASS FILTER SOUND |
| 88 |
out asig ;SEND AUDIO TO OUTPUTS |
| 89 |
endin |
| 90 |
|
| 91 |
instr 7 ;SOUND 5 - OPEN HI-HAT |
| 92 |
p3 = 1 ;DEFINE DURATION FOR THIS SOUND |
| 93 |
aenv expon rnd(0.5)+0.5,p3,0.001 ;AMPLITUDE ENVELOPE - PERCUSSIVE DECAY |
| 94 |
asig noise aenv*0.3, 0 ;CREATE SOUND FOR CLOSED HI-HAT |
| 95 |
asig buthp asig, 7000 ;HIGHPASS FILTER SOUND |
| 96 |
out asig ;SEND AUDIO TO OUTPUTS |
| 97 |
endin |
| 98 |
|
| 99 |
instr 8 ;SOUND 6 - TAMBOURINE |
| 100 |
p3 = 0.5 ;DEFINE DURATION FOR THIS SOUND |
| 101 |
asig tambourine 0.1,0.01 ,32, 0.47, 0, 2300 , 5600, 8000 ;TAMBOURINE SOUND CREATED USING tambourine PHYSICAL MODELLING OPCODE (SEE CSOUND MANUAL FOR MORE INFO.) |
| 102 |
out asig*(rnd(0.5)+0.5) ;SEND AUDIO TO OUTPUTS |
| 103 |
endin |
| 104 |
</CsInstruments> |
| 105 |
<CsScore> |
| 106 |
i 1 0 300 |
| 107 |
</CsScore> |
| 108 |
</CsoundSynthesizer> |
| 109 |
<bsbPanel> |
| 110 |
<label>Widgets</label> |
| 111 |
<objectName/> |
| 112 |
<x>1030</x> |
| 113 |
<y>237</y> |
| 114 |
<width>515</width> |
| 115 |
<height>284</height> |
| 116 |
<visible>true</visible> |
| 117 |
<uuid/> |
| 118 |
<bgcolor mode="background"> |
| 119 |
<r>241</r> |
| 120 |
<g>226</g> |
| 121 |
<b>185</b> |
| 122 |
</bgcolor> |
| 123 |
<bsbObject version="2" type="BSBLabel"> |
| 124 |
<objectName/> |
| 125 |
<x>2</x> |
| 126 |
<y>2</y> |
| 127 |
<width>508</width> |
| 128 |
<height>280</height> |
| 129 |
<uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid> |
| 130 |
<visible>true</visible> |
| 131 |
<midichan>0</midichan> |
| 132 |
<midicc>0</midicc> |
| 133 |
<label>Simple Loop Sequencer</label> |
| 134 |
<alignment>center</alignment> |
| 135 |
<font>Liberation Sans</font> |
| 136 |
<fontsize>18</fontsize> |
| 137 |
<precision>3</precision> |
| 138 |
<color> |
| 139 |
<r>0</r> |
| 140 |
<g>0</g> |
| 141 |
<b>0</b> |
| 142 |
</color> |
| 143 |
<bgcolor mode="background"> |
| 144 |
<r>244</r> |
| 145 |
<g>248</g> |
| 146 |
<b>200</b> |
| 147 |
</bgcolor> |
| 148 |
<bordermode>border</bordermode> |
| 149 |
<borderradius>5</borderradius> |
| 150 |
<borderwidth>2</borderwidth> |
| 151 |
</bsbObject> |
| 152 |
<bsbObject version="2" type="BSBLabel"> |
| 153 |
<objectName/> |
| 154 |
<x>6</x> |
| 155 |
<y>84</y> |
| 156 |
<width>499</width> |
| 157 |
<height>195</height> |
| 158 |
<uuid>{d4bdb5ce-87d8-4c8c-9c64-40ec2eed6f5a}</uuid> |
| 159 |
<visible>true</visible> |
| 160 |
<midichan>0</midichan> |
| 161 |
<midicc>0</midicc> |
| 162 |
<label>-------------------------------------------------------------------------------------------------------------------------- |
| 163 |
This example demonstrates a simple method for creating a looping step sequencer that doesn't used the 'timedseq' opcode. |
| 164 |
Note triggers for each instrument are stored in GEN 2 function table, 1 meaning play a note, 0 meaning don't. |
| 165 |
This example can easily be expanded to create more elaborate pattern but I have kept it simple so far to provide a basic starting point. |
| 166 |
|
| 167 |
This method is less flexible than the method using timedseq but for simple rhythmical patterns will probably be adequate.</label> |
| 168 |
<alignment>left</alignment> |
| 169 |
<font>Liberation Sans</font> |
| 170 |
<fontsize>14</fontsize> |
| 171 |
<precision>3</precision> |
| 172 |
<color> |
| 173 |
<r>0</r> |
| 174 |
<g>0</g> |
| 175 |
<b>0</b> |
| 176 |
</color> |
| 177 |
<bgcolor mode="nobackground"> |
| 178 |
<r>255</r> |
| 179 |
<g>255</g> |
| 180 |
<b>255</b> |
| 181 |
</bgcolor> |
| 182 |
<bordermode>noborder</bordermode> |
| 183 |
<borderradius>1</borderradius> |
| 184 |
<borderwidth>1</borderwidth> |
| 185 |
</bsbObject> |
| 186 |
<bsbObject version="2" type="BSBLabel"> |
| 187 |
<objectName/> |
| 188 |
<x>16</x> |
| 189 |
<y>52</y> |
| 190 |
<width>80</width> |
| 191 |
<height>30</height> |
| 192 |
<uuid>{ab2263b1-0628-47c5-9db6-34777794227c}</uuid> |
| 193 |
<visible>true</visible> |
| 194 |
<midichan>0</midichan> |
| 195 |
<midicc>0</midicc> |
| 196 |
<label>Tempo :</label> |
| 197 |
<alignment>right</alignment> |
| 198 |
<font>Liberation Sans</font> |
| 199 |
<fontsize>14</fontsize> |
| 200 |
<precision>3</precision> |
| 201 |
<color> |
| 202 |
<r>0</r> |
| 203 |
<g>0</g> |
| 204 |
<b>0</b> |
| 205 |
</color> |
| 206 |
<bgcolor mode="nobackground"> |
| 207 |
<r>255</r> |
| 208 |
<g>255</g> |
| 209 |
<b>255</b> |
| 210 |
</bgcolor> |
| 211 |
<bordermode>noborder</bordermode> |
| 212 |
<borderradius>1</borderradius> |
| 213 |
<borderwidth>1</borderwidth> |
| 214 |
</bsbObject> |
| 215 |
<bsbObject version="2" type="BSBSpinBox"> |
| 216 |
<objectName>Tempo</objectName> |
| 217 |
<x>97</x> |
| 218 |
<y>52</y> |
| 219 |
<width>60</width> |
| 220 |
<height>30</height> |
| 221 |
<uuid>{163e9b1f-3627-4639-b0d1-b01a2d21e248}</uuid> |
| 222 |
<visible>true</visible> |
| 223 |
<midichan>0</midichan> |
| 224 |
<midicc>0</midicc> |
| 225 |
<alignment>right</alignment> |
| 226 |
<font>Arial</font> |
| 227 |
<fontsize>14</fontsize> |
| 228 |
<color> |
| 229 |
<r>0</r> |
| 230 |
<g>0</g> |
| 231 |
<b>0</b> |
| 232 |
</color> |
| 233 |
<bgcolor mode="nobackground"> |
| 234 |
<r>255</r> |
| 235 |
<g>255</g> |
| 236 |
<b>255</b> |
| 237 |
</bgcolor> |
| 238 |
<resolution>1.00000000</resolution> |
| 239 |
<minimum>1</minimum> |
| 240 |
<maximum>240</maximum> |
| 241 |
<randomizable group="0">false</randomizable> |
| 242 |
<value>90</value> |
| 243 |
</bsbObject> |
| 244 |
</bsbPanel> |
| 245 |
<bsbPresets> |
| 246 |
</bsbPresets> |
| 247 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |