Debian Codegraph @

src/Examples/FLOSS Manual Examples/04 Sound Synthesis/04A13_hsboscil.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -o dac -m0
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 32
8 0dbfs = 1
9 nchnls = 2
10
11 giSine ftgen 0, 0, 2^10, 10, 1
12 ; hanning window
13 giWindow ftgen 0, 0, 1024, -19, 1, 0.5, 270, 0.5
14 ; a complex pseudo inharmonic waveform (partials scaled up X 100)
15 giWave ftgen 0, 0, 262144, 9, 100,1.000,0, 278,0.500,0, 518,0.250,0,
16 816,0.125,0, 1166,0.062,0, 1564,0.031,0, 1910,0.016,0
17
18
19 instr 1 ; demonstration of hsboscil
20 kAmp = 0.3
21 kTone rspline -1,1,0.05,0.2 ; randomly shift spectrum up and down
22 kBrite rspline -1,3,0.4,2 ; randomly shift masking window up and down
23 iBasFreq = 200 ; base frequency
24 iOctCnt = 3 ; width of masking window
25 aSig hsboscil kAmp, kTone, kBrite, iBasFreq, giSine, giWindow, iOctCnt
26 out aSig, aSig
27 endin
28
29 instr 2 ; frequency shifting added
30 kAmp = 0.3
31 kTone = 0 ; spectrum remains static this time
32 kBrite rspline -2,5,0.4,2 ; randomly shift masking window up and down
33 iBasFreq = 75 ; base frequency
34 iOctCnt = 6 ; width of masking window
35 aSig hsboscil kAmp, kTone, kBrite, iBasFreq, giSine, giWindow, iOctCnt
36 ; frequency shift the sound
37 kfshift = -357 ; amount to shift the frequency
38 areal,aimag hilbert aSig ; hilbert filtering
39 asin poscil 1, kfshift, giSine, 0 ; modulating signals
40 acos poscil 1, kfshift, giSine, 0.25
41 aSig = (areal*acos) - (aimag*asin) ; frequency shifted signal
42 out aSig, aSig
43 endin
44
45 instr 3 ; hsboscil using a complex waveform
46 kAmp = 0.3
47 kTone rspline -1,1,0.05,0.2 ; randomly shift spectrum up and down
48 kBrite rspline -3,3,0.1,1 ; randomly shift masking window
49 iBasFreq = 200
50 aSig hsboscil kAmp, kTone, kBrite, iBasFreq/100, giWave, giWindow
51 aSig2 hsboscil kAmp,kTone, kBrite, (iBasFreq*1.001)/100, giWave, giWindow
52 out aSig+aSig2, aSig+aSig2 ; mix signal with \'detuned\' version
53 endin
54
55 </CsInstruments>
56 <CsScore>
57 i 1 0 14
58 i 2 15 14
59 i 3 30 14
60 </CsScore>
61 </CsoundSynthesizer>
62 ;example by iain mccurdy