Debian Codegraph @

src/Examples/FLOSS Manual Examples/03 Csound Language/03D07_Record_audio_to_table.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -iadc -odac
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 nchnls = 2
9 0dbfs = 1
10
11 giFt ftgen 0, 0, -5*sr, 2, 0; size for 5 seconds of recording audio
12 seed 0
13
14 instr 1 ;generating a band filtered noise for 5 seconds, and recording it
15 aNois rand .2
16 kCfreq randomi 200, 2000, 3; random center frequency
17 aFilt butbp aNois, kCfreq, kCfreq/10; filtered noise
18 aBal balance aFilt, aNois, 1; balance amplitude
19 outs aBal, aBal
20 ;;record the audiosignal with a phasor as index
21 prints "RECORDING FILTERED NOISE!%n"
22 ;create a writing pointer in the table,
23 ;moving in 5 seconds from index 0 to the end
24 aindx phasor 1/5
25 ;write the k-signal
26 tablew aBal, aindx, giFt, 1
27 endin
28
29 instr 2 ;read the values of the table and play it
30 prints "PLAYING FILTERED NOISE!%n"
31 aindx phasor 1/5
32 aSnd table3 aindx, giFt, 1
33 outs aSnd, aSnd
34 endin
35
36 instr 3 ;record live input
37 ktim timeinsts ; playing time of the instrument in seconds
38 prints "PLEASE GIVE YOUR LIVE INPUT AFTER THE BEEP!%n"
39 kBeepEnv linseg 0, 1, 0, .01, 1, .5, 1, .01, 0
40 aBeep oscils .2, 600, 0
41 outs aBeep*kBeepEnv, aBeep*kBeepEnv
42 ;;record the audiosignal after 2 seconds
43 if ktim > 2 then
44 ain inch 1
45 printks "RECORDING LIVE INPUT!%n", 10
46 ;create a writing pointer in the table,
47 ;moving in 5 seconds from index 0 to the end
48 aindx phasor 1/5
49 ;write the k-signal
50 tablew ain, aindx, giFt, 1
51 endif
52 endin
53
54 instr 4 ;read the values from the table and play it
55 prints "PLAYING LIVE INPUT!%n"
56 aindx phasor 1/5
57 aSnd table3 aindx, giFt, 1
58 outs aSnd, aSnd
59 endin
60
61 </CsInstruments>
62 <CsScore>
63 i 1 0 5 ; record 5 seconds of generated audio to a table
64 i 2 6 5 ; play back the recording of generated audio
65 i 3 12 7 ; record 5 seconds of live audio to a table
66 i 4 20 5 ; play back the recording of live audio
67 </CsScore>
68 </CsoundSynthesizer>
69 ;example by joachim heintz