Debian Codegraph @

examples/foutk.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 -odac ;;;realtime audio out
5 -iadc ;;;uncomment -iadc if real audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o foutk.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 ; by Stefano Cucchi - 2020
12
13 ; Sing in your microphone for 10''
14 ; Estimated pitch & amplitude are written on 2 files "amp" 6 "pitch"
15 ; After 10'' a sawtooth is played with these values
16
17
18 sr = 44100
19 ksmps = 32
20 nchnls = 2
21 0dbfs = 1
22
23
24 instr 1 ;use pitch
25
26 iupdte = 0.001
27 ilo = 6
28 ihi = 10
29 idbthresh = 10
30 ifrqs = 24
31 iconf = 10
32 istrt = 8
33
34 asig1, asig2 inch 1, 2
35 koct, kamp pitch asig1, iupdte, ilo, ihi, idbthresh, ifrqs, iconf, istrt ; pitch & amplitude tracking
36
37 kcps = cpsoct(koct)
38 kamp = kamp*0.00002
39 foutk "amp", 6, kamp ; write amplitude values on a file - 32-bit floats without header
40 foutk "pitch", 6, kcps ; write pitch values on a file - 32-bit floats without header
41
42 endin
43
44 instr 2
45
46 kamp readk "amp", 6, p4 ; read amplitude values fro the file
47 kcps readk "pitch", 6, p4 ; read pitchvalues fro the file
48
49 kcps portk kcps, 0.008
50 asig oscili kamp, kcps*p5, 1 ; use amplitude & pitch to play a sawtooth
51 kdeclick linseg 0, 0.2, 1, p3 -0.4, 1, 0.2, 0
52
53 outs asig*kdeclick, asig*kdeclick
54
55 endin
56
57 </CsInstruments>
58 <CsScore>
59
60 f1 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111 ;sawtooth
61
62 i 1 0 10
63 i 2 10 10 0.001 1 ;
64 e
65 </CsScore>
66 </CsoundSynthesizer>