Debian Codegraph @

src/Examples/FLOSS Manual Examples/05 Sound Modification/05A10_lpshold_loopseg.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac ;activates real time sound output
4 </CsOptions>
5 <CsInstruments>
6 sr = 44100
7 ksmps = 4
8 nchnls = 2
9 0dbfs = 1
10
11 seed 0; seed random number generators from system clock
12
13 instr 1; Bassline instrument
14 kTempo = 90 ; tempo in beats per minute
15 kCfBase randomi 1,4, 0.2 ; base filter frequency (oct format)
16 kCfEnv randomi 0,4,0.2 ; filter envelope depth
17 kRes randomi 0.5,0.9,0.2 ; filter resonance
18 kVol = 0.5 ; volume control
19 kDecay randomi -10,10,0.2 ; decay shape of the filter.
20 kWaveform = 0 ; oscillator waveform. 0=sawtooth 2=square
21 kDist randomi 0,1,0.1 ; amount of distortion
22 kPhFreq = kTempo/240 ; freq. to repeat the entire phrase
23 kBtFreq = (kTempo)/15 ; frequency of each 1/16th note
24 ; -- Envelopes with held segments --
25 ; The first value of each pair defines the relative duration of that segment,
26 ; the second, the value itself.
27 ; Note numbers (kNum) are defined as MIDI note numbers.
28 ; Note On/Off (kOn) and hold (kHold) are defined as on/off switches, 1 or zero
29 ; note:1 2 3 4 5 6 7 8
30 ; 9 10 11 12 13 14 15 16 0
31 kNum lpshold kPhFreq, 0, 0,40, 1,42, 1,50, 1,49, 1,60, 1,54, 1,39, 1,40, \
32 1,46, 1,36, 1,40, 1,46, 1,50, 1,56, 1,44, 1,47,1
33 kOn lpshold kPhFreq, 0, 0,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,0, 1,1, \
34 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,0, 1,1, 1
35 kHold lpshold kPhFreq, 0, 0,0, 1,1, 1,1, 1,0, 1,0, 1,0, 1,0, 1,1, \
36 1,0, 1,0, 1,1, 1,1, 1,1, 1,1, 1,0, 1,0, 1
37 kHold vdel_k kHold, 1/kBtFreq, 1; offset hold by 1/2 note duration
38 kNum portk kNum, (0.01*kHold) ; apply portamento to pitch changes
39 ; if note is not held: no portamento
40 kCps = cpsmidinn(kNum) ; convert note number to cps
41 kOct = octcps(kCps) ; convert cps to oct format
42 ; amplitude envelope attack sustain decay gap
43 kAmpEnv loopseg kBtFreq, 0, 0, 0,0.1, 1, 55/kTempo, 1, 0.1,0, 5/kTempo,0,0
44 kAmpEnv = (kHold=0?kAmpEnv:1) ; if a held note, ignore envelope
45 kAmpEnv port kAmpEnv,0.001
46
47 ; filter envelope
48 kCfOct looptseg kBtFreq,0,0,kCfBase+kCfEnv+kOct,kDecay,1,kCfBase+kOct
49 ; if hold is off, use filter envelope, otherwise use steady state value:
50 kCfOct = (kHold=0?kCfOct:kCfBase+kOct)
51 kCfOct limit kCfOct, 4, 14 ; limit the cutoff frequency (oct format)
52 aSig vco2 0.4, kCps, i(kWaveform)*2, 0.5 ; VCO-style oscillator
53 aFilt lpf18 aSig, cpsoct(kCfOct), kRes, (kDist^2)*10 ; filter audio
54 aSig balance aFilt,aSig ; balance levels
55 kOn port kOn, 0.006 ; smooth on/off switching
56 ; audio sent to output, apply amp. envelope,
57 ; volume control and note On/Off status
58 aAmpEnv interp kAmpEnv*kOn*kVol
59 aOut = aSig * aAmpEnv
60 out aOut, aOut
61 endin
62
63 </CsInstruments>
64 <CsScore>
65 i 1 0 3600 ; instr 1 plays for 1 hour
66 </CsScore>
67 </CsoundSynthesizer>
68 ;example by Iain McCurdy