| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
-odac ;;;realtime audio out |
| 5 |
;-iadc ;;;uncomment -iadc if RT audio input is needed too |
| 6 |
; For Non-realtime ouput leave only the line below: |
| 7 |
; -o timedseq.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 32 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
giseq ftgen 0,0,128,-2, 2, 0, 0.5, 8.00,\ ;first note |
| 17 |
2, 1, 0.5, 8.02,\ ;second note |
| 18 |
2, 2, 0.5, 8.04,\ ;third |
| 19 |
2, 3, 0.5, 8.05,\ ;fourth |
| 20 |
2, 4, 0.5, 8.07,\ ;fifth |
| 21 |
2, 5, 0.5, 8.09,\ ;sixth |
| 22 |
2, 6, 0.5, 8.11,\ ;seventh |
| 23 |
2, 7, 0.5, 9.00,\ ;eight note |
| 24 |
2, 8, 0.5, 8.00,\ ;due to a quirk in the opcode, it needs an extra note - a copy of the first note |
| 25 |
-1, 8, -1, -1 ;last line is a dummy event that indicates to timedseq when to loop back to the beginning |
| 26 |
|
| 27 |
instr 1 |
| 28 |
|
| 29 |
ibeats = 8 ;lengths of sequence in beats |
| 30 |
itempo = p4 ;tempo |
| 31 |
iBPS = itempo/60 ;beats per second |
| 32 |
kphase phasor iBPS/ibeats ;phasor to move through table |
| 33 |
kpointer = kphase*ibeats ;multiply phase (range 0 - 1) by the number of beats contained within the sequence |
| 34 |
kp1 init 0 |
| 35 |
kp2 init 0 |
| 36 |
kp3 init 0 |
| 37 |
kp4 init 0 |
| 38 |
ktrigger timedseq kpointer, giseq, kp1, kp2,kp3, kp4 |
| 39 |
schedkwhen ktrigger, 0, 0, 2, 0, kp3/abs(iBPS), kp4 ;p3 values have been scaled according to tempo so that they maesure beats rather than seconds |
| 40 |
endin ;abs(iBPS)(absolute value) is used because the tempo provided by the fourth note of the score is negative. |
| 41 |
;Durations here should be positive, because negative values for duration would indicate a held note. |
| 42 |
instr 2 |
| 43 |
|
| 44 |
aenv linseg 0,0.01,1,p3-0.01,0 ;amplitude envelope |
| 45 |
asig vco2 0.4, cpspch(p4), 4, 0.5 |
| 46 |
outs asig*aenv, asig*aenv |
| 47 |
endin |
| 48 |
|
| 49 |
</CsInstruments> |
| 50 |
<CsScore> |
| 51 |
i 1 0 4 120 |
| 52 |
i 1 + . 240 |
| 53 |
i 1 + . 480 |
| 54 |
i 1 + . -480 ;when negative it plays backwards |
| 55 |
e |
| 56 |
</CsScore> |
| 57 |
</CsoundSynthesizer> |
| 58 |
|