| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; real-time audio in and out are both activated |
| 4 |
-iadc -odac |
| 5 |
</CsOptions> |
| 6 |
<CsInstruments> |
| 7 |
sr = 44100 |
| 8 |
ksmps = 32 |
| 9 |
nchnls = 2 |
| 10 |
0dbfs = 1 |
| 11 |
|
| 12 |
instr 1 |
| 13 |
; PRINT INSTRUCTIONS |
| 14 |
prints "Press 'r' to record, 's' to stop playback, " |
| 15 |
prints "'+' to increase pitch, '-' to decrease pitch.\\n" |
| 16 |
; SENSE KEYBOARD ACTIVITY |
| 17 |
kKey sensekey; sense activity on the computer keyboard |
| 18 |
aIn inch 1 ; read audio from first input channel |
| 19 |
kPitch init 1 ; initialize pitch parameter |
| 20 |
iDur init 2 ; inititialize duration of loop parameter |
| 21 |
iFade init 0.05 ; initialize crossfade time parameter |
| 22 |
if kKey = 114 then ; if 'r' has been pressed... |
| 23 |
kTrig = 1 ; set trigger to begin record-playback |
| 24 |
elseif kKey = 115 then ; if 's' has been pressed... |
| 25 |
kTrig = 0 ; set trigger to turn off record-playback |
| 26 |
elseif kKey = 43 then ; if '+' has been pressed... |
| 27 |
kPitch = kPitch + 0.02 ; increment pitch parameter |
| 28 |
elseif kKey = 45 then ; if '-' has been pressed |
| 29 |
kPitch = kPitch - 0.02 ; decrement pitch parameter |
| 30 |
endif ; end of conditional branches |
| 31 |
; CREATE SNDLOOP INSTANCE |
| 32 |
aOut, kRec sndloop aIn, kPitch, kTrig, iDur, iFade ; (kRec output is not used) |
| 33 |
out aOut, aOut ; send audio to output |
| 34 |
endin |
| 35 |
|
| 36 |
</CsInstruments> |
| 37 |
<CsScore> |
| 38 |
i 1 0 3600 ; instr 1 plays for 1 hour |
| 39 |
</CsScore> |
| 40 |
</CsoundSynthesizer> |
| 41 |
;example written by Iain McCurdy |