| 1 |
/* Getting started.. Control structures |
| 2 |
|
| 3 |
Let's add tones, the same way, as we've put T-Shirts into the bag! |
| 4 |
|
| 5 |
*/ |
| 6 |
<CsoundSynthesizer> |
| 7 |
<CsOptions> |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
seed 0; makes the random choice each time different |
| 17 |
|
| 18 |
instr 100 ; Oscillator |
| 19 |
irand random 0, p4 |
| 20 |
kEnv madsr 0.1, 0.1, 0.9, 0.1 |
| 21 |
a1 oscils 0.1, 440*(2^(irand/12)), 0 ; Sine-Osc, producing random freqs between 440 and 1760 hz |
| 22 |
outs a1*kEnv, a1*kEnv |
| 23 |
endin |
| 24 |
|
| 25 |
; The "if" method.. |
| 26 |
instr 1 |
| 27 |
iIndex = 0 ; index |
| 28 |
iLimit = p4 |
| 29 |
loop1: ; label |
| 30 |
event_i "i",100, 0, 1, iLimit ; this generates a scoreline from the instrument.. |
| 31 |
prints "Instance of instr 100 by loop1_%d created!%n", iIndex+1 |
| 32 |
iIndex = iIndex+1 |
| 33 |
if (iIndex < 5) igoto loop1 |
| 34 |
endin |
| 35 |
|
| 36 |
; Using loop_lt.. |
| 37 |
instr 2 |
| 38 |
iIndex = 0 ; index |
| 39 |
iLimit = p4 |
| 40 |
loop2: ; label |
| 41 |
event_i "i",100, 0, 1, iLimit ; this generates a scoreline from the instrument.. |
| 42 |
prints "Instance of instr 100 by loop2_%d created!%n", iIndex+1 |
| 43 |
loop_lt iIndex, 1, 5, loop2 |
| 44 |
endin |
| 45 |
</CsInstruments> |
| 46 |
|
| 47 |
<CsScore> |
| 48 |
i 1 0 2 24 |
| 49 |
i 2 3 2 24 |
| 50 |
i 2 5 2 12 |
| 51 |
i 2 7 2 2 |
| 52 |
e |
| 53 |
</CsScore> |
| 54 |
</CsoundSynthesizer> |
| 55 |
; written by Alex Hofmann (Mar. 2010) - Incontri HMT-Hannover |
| 56 |
|
| 57 |
<bsbPanel> |
| 58 |
<label>Widgets</label> |
| 59 |
<objectName/> |
| 60 |
<x>1013</x> |
| 61 |
<y>279</y> |
| 62 |
<width>563</width> |
| 63 |
<height>397</height> |
| 64 |
<visible>true</visible> |
| 65 |
<uuid/> |
| 66 |
<bgcolor mode="background"> |
| 67 |
<r>255</r> |
| 68 |
<g>255</g> |
| 69 |
<b>255</b> |
| 70 |
</bgcolor> |
| 71 |
<bsbObject version="2" type="BSBScope"> |
| 72 |
<objectName/> |
| 73 |
<x>24</x> |
| 74 |
<y>26</y> |
| 75 |
<width>350</width> |
| 76 |
<height>150</height> |
| 77 |
<uuid>{bd0a0ae1-2149-4248-82ce-26a3860e190b}</uuid> |
| 78 |
<visible>true</visible> |
| 79 |
<midichan>0</midichan> |
| 80 |
<midicc>-3</midicc> |
| 81 |
<value>-255.00000000</value> |
| 82 |
<type>scope</type> |
| 83 |
<zoomx>2.00000000</zoomx> |
| 84 |
<zoomy>1.00000000</zoomy> |
| 85 |
<dispx>1.00000000</dispx> |
| 86 |
<dispy>1.00000000</dispy> |
| 87 |
<mode>0.00000000</mode> |
| 88 |
</bsbObject> |
| 89 |
</bsbPanel> |
| 90 |
<bsbPresets> |
| 91 |
</bsbPresets> |
| 92 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="320" y="218" width="596" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |