| 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 pvsadsyn.wav -W ;;; for file output any platform |
| 8 |
</CsOptions> |
| 9 |
<CsInstruments> |
| 10 |
|
| 11 |
sr = 44100 |
| 12 |
ksmps = 16 |
| 13 |
nchnls = 2 |
| 14 |
0dbfs = 1 |
| 15 |
|
| 16 |
;; example written by joachim heintz 2009 |
| 17 |
; (additions by Menno Knevel 2021) |
| 18 |
opcode FileToPvsBuf, iik, Siiii |
| 19 |
;;writes an audio file at the first k-cycle to a fft-buffer (via pvsbuffer) |
| 20 |
Sfile, ifftsize, ioverlap, iwinsize, iwinshape xin |
| 21 |
ktimek timeinstk |
| 22 |
if ktimek == 1 then |
| 23 |
ilen filelen Sfile |
| 24 |
kcycles = ilen * kr; number of k-cycles to write the fft-buffer |
| 25 |
kcount init 0 |
| 26 |
loop: |
| 27 |
ain soundin Sfile |
| 28 |
fftin pvsanal ain, ifftsize, ioverlap, iwinsize, iwinshape |
| 29 |
ibuf, ktim pvsbuffer fftin, ilen + (ifftsize / sr) |
| 30 |
loop_lt kcount, 1, kcycles, loop |
| 31 |
xout ibuf, ilen, ktim |
| 32 |
endif |
| 33 |
endop |
| 34 |
|
| 35 |
|
| 36 |
instr 1 |
| 37 |
istretch = p4; time stretching factor |
| 38 |
ifftsize = 1024 |
| 39 |
ioverlap = ifftsize / 4 |
| 40 |
iwinsize = ifftsize |
| 41 |
iwinshape = 1; von-Hann window |
| 42 |
ibuffer, ilen, k0 FileToPvsBuf "fox.wav", ifftsize, ioverlap, iwinsize, iwinshape |
| 43 |
p3 = istretch * ilen; set p3 to the correct value |
| 44 |
prints "--**new duration of note = %f seconds**--\n", p3 |
| 45 |
ktmpnt linseg 0, p3, ilen; time pointer |
| 46 |
fread pvsbufread ktmpnt, ibuffer; read the buffer |
| 47 |
aout pvsadsyn fread, 50, 1, p5; resynthesis of 50 bins, with offset p5 |
| 48 |
aout *= .7 ; scale amplitude |
| 49 |
outs aout, aout |
| 50 |
endin |
| 51 |
|
| 52 |
</CsInstruments> |
| 53 |
<CsScore> |
| 54 |
; stretch offset |
| 55 |
i 1 0 1 10 0 |
| 56 |
i 1 28 1 5 30 |
| 57 |
e |
| 58 |
</CsScore> |
| 59 |
</CsoundSynthesizer> |