Debian Codegraph @

examples/pvsbuffer

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ; Select audio/midi flags here according to platform
4 ; Audio out Audio in
5 -odac ;;;RT audio I/O
6 ; For Non-realtime ouput leave only the line below:
7 ; -o pvsbuffer.wav -W ;;; for file output any platform
8 </CsOptions>
9 <CsInstruments>
10
11 sr = 44100
12 ksmps = 32
13 nchnls = 2
14 0dbfs = 1
15
16 ;; example written by joachim heintz 2009
17 ; additions by Menno Knevel 2021
18
19 opcode FileToPvsBuf, iik, Siiiii
20 ;;writes an audio file at the first k-cycle to a fft-buffer (via pvsbuffer)
21 Sfile, ifftsize, ioverlap, iwinsize, iwinshape, ilength xin
22 ktimek timeinstk
23 if ktimek == 1 then
24 ilen filelen Sfile
25 kcycles = ilen * kr; number of k-cycles to write the fft-buffer
26 kcount init 0
27 loop:
28 ain soundin Sfile
29 fftin pvsanal ain, ifftsize, ioverlap, iwinsize, iwinshape
30 ibufln = (ilen * ilength) + (ifftsize / sr)
31 ibuf, ktim pvsbuffer fftin, ibufln
32
33 loop_lt kcount, 1, kcycles, loop
34 xout ibuf, ilen, ktim
35 endif
36 endop
37
38
39 instr 1
40 ifftsize = 1024
41 ioverlap = ifftsize / 4
42 iwinsize = ifftsize
43 iwinshape = 1; von-Hann window
44 ilength = p4
45 ibuffer, ilen, k0 FileToPvsBuf "fox.wav", ifftsize, ioverlap, iwinsize, iwinshape, ilength
46 ktmpnt linseg ilen, p3, 0; reads the buffer backwards in p3 seconds
47 fread pvsbufread ktmpnt, ibuffer
48 aout pvsynth fread
49 outs aout, aout
50 endin
51
52 </CsInstruments>
53 <CsScore>
54 i 1 0 5 .05 ; buffer a small portion
55 i 1 6 5 .5 ; half of total length
56 i 1 12 5 1 ; buffer total length
57 e
58 </CsScore>
59 </CsoundSynthesizer>