-i adc
;Example by Joachim Heintz
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
; -- size for 5 seconds of recording audio data
giAudio ftgen 0, 0, -5*sr, 2, 0
instr 1 ;record live input
ktim timeinsts ; playing time of the instrument in seconds
prints "PLEASE GIVE YOUR LIVE INPUT AFTER THE BEEP!%n"
kBeepEnv linseg 0, 1, 0, .01, 1, .5, 1, .01, 0
aBeep oscils .2, 600, 0
outs aBeep*kBeepEnv, aBeep*kBeepEnv
;;record the audiosignal after 2 seconds
if ktim > 2 then
ain inch 1
printks "RECORDING LIVE INPUT!%n", 10
;create a writing pointer in the table,
;moving in 5 seconds from index 0 to the end
aindx phasor 1/5
;write the k-signal
tablew ain, aindx, giAudio, 1
endif
endin
instr 2; write the giAudio table to a soundfile
Soutname = "testwrite.wav"; name of the output file
iformat = 14; write as 16 bit wav file
itablen = ftlen(giAudio); length of the table in samples
kcnt init 0; set the counter to 0 at start
loop:
kcnt = kcnt+ksmps; next value (e.g. 10 if ksmps=10)
andx interp kcnt-1; calculate audio index (e.g. from 0 to 9)
asig tab andx, giAudio; read the table values as audio signal
fout Soutname, iformat, asig; write asig to a file
if kcnt <= itablen-ksmps kgoto loop; go back as long there is something to do
turnoff ; terminate the instrument
endin
i 1 0 7
i 2 7 .1