1<CsoundSynthesizer> 2<CsOptions> 3--env:SSDIR+=../SourceMaterials -i adc 4</CsOptions> 5<CsInstruments> 6;Example by Joachim Heintz 7sr = 44100 8ksmps = 32 9nchnls = 2 100dbfs = 1 11; -- size for 5 seconds of recording audio data 12giAudio ftgen 0, 0, -5*sr, 2, 0 13 14 instr 1 ;record live input 15ktim timeinsts ; playing time of the instrument in seconds 16 prints "PLEASE GIVE YOUR LIVE INPUT AFTER THE BEEP!%n" 17kBeepEnv linseg 0, 1, 0, .01, 1, .5, 1, .01, 0 18aBeep oscils .2, 600, 0 19 outs aBeep*kBeepEnv, aBeep*kBeepEnv 20;;record the audiosignal after 2 seconds 21 if ktim > 2 then 22ain inch 1 23 printks "RECORDING LIVE INPUT!%n", 10 24 ;create a writing pointer in the table, 25 ;moving in 5 seconds from index 0 to the end 26aindx phasor 1/5 27 ;write the k-signal 28 tablew ain, aindx, giAudio, 1 29 endif 30 endin 31 32 instr 2; write the giAudio table to a soundfile 33Soutname = "testwrite.wav"; name of the output file 34iformat = 14; write as 16 bit wav file 35itablen = ftlen(giAudio); length of the table in samples 36 37kcnt init 0; set the counter to 0 at start 38loop: 39kcnt = kcnt+ksmps; next value (e.g. 10 if ksmps=10) 40andx interp kcnt-1; calculate audio index (e.g. from 0 to 9) 41asig tab andx, giAudio; read the table values as audio signal 42 fout Soutname, iformat, asig; write asig to a file 43 if kcnt <= itablen-ksmps kgoto loop; go back as long there is something to do 44 turnoff ; terminate the instrument 45 endin 46 47</CsInstruments> 48<CsScore> 49i 1 0 7 50i 2 7 .1 51</CsScore> 52</CsoundSynthesizer> 53