Debian Codegraph @

examples/filepeak.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 realtime audio input is needed too
6 ; For Non-realtime ouput leave only the line below:
7 ; -o filepeak.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 instr 1
17
18 iscaldb = p4 ;set peak amplitude in dB
19 ipeak filepeak "Church.wav"
20 iscal = ampdb(iscaldb)/ipeak ;calculate amp multiplier
21 printf_i "\nPeak value in file '%s' is %f (%.3f dB).\n\n", 1, "Church.wav", ipeak, dbamp(ipeak)
22
23 asnd soundin "Church.wav"
24 outs asnd, asnd
25 ; scale & write file to disk
26 asig = asnd*iscal ;scale to p4
27 fout "Church_norm.wav", 14, asig
28
29 endin
30
31 instr 2 ; play scaled file
32
33 aout soundin "Church_norm.wav"
34 ipknew filepeak "Church_norm.wav"
35 printf_i "\nPeak value in file '%s' is %f (%.3f dB).\n\n", 1, "Church_norm.wav", ipknew, dbamp(ipknew)
36 outs aout, aout
37
38 endin
39 </CsInstruments>
40 <CsScore>
41
42 i 1 0 2 -6 ; normalize audio to -6 dB
43 i 2 2 2
44 e
45 </CsScore>
46 </CsoundSynthesizer>