Hi fellow cabbages!
I’m new to the whole csound/cabbage audio side of things and am coming across one or two problems with the synth I am building any help would be appreciated!
- How do I put an ADSR on a filter. Ie, I want a filter envelope.
- My master volume does not work for some reason.
;outs amixL, amixR
outs amixLklevel, amixRklevel
The first line of code works but when I multiply by klevel I cannot hear anything which is strange.
I do have more questions / problems but I’ll leave it there for now in the hope these can get answered first! Thanks to anyone who replies in advance!
D
<Cabbage>
form caption("Synth") size(725, 485), colour(0, 0, 0), pluginID("def1")
keyboard bounds(5, 375, 710, 100)
groupbox bounds(15,15,255,110), text("Oscil 1"), plant("oscil1"){
rslider bounds(5,35,65,65), channel("octave1"), text("Octave"), colour(400,100,100), trackercolour(0,400,0), range(-2,2,0)
rslider bounds(65,35,65,65), channel("semi1"), text("Semi"), colour(400,100,100), trackercolour(0,400,0), range(-12,12,0)
rslider bounds(125,35,65,65), channel("cent1"), text("Cent"), colour(400,100,100), trackercolour(0,400,0), range(-1,1,0)
rslider bounds(185,35,65,65), channel("gain1"), text("Level"), colour(400,100,100), trackercolour(0,400,0), range(0,1,.5)
}
groupbox bounds(15,140,255,110),text("Oscil 2"), plant("oscil2"){
rslider bounds(5,35,65,65), channel("octave2"), text("Octave2"), colour(400,100,100), trackercolour(0,400,0), range(-2,2,0)
rslider bounds(65,35,65,65), channel("semi2"), text("Semi2"), colour(400,100,100), trackercolour(0,400,0), range(-12,12,0)
rslider bounds(125,35,65,65), channel("cent2"), text("Cent2"), colour(400,100,100), trackercolour(0,400,0), range(-1,1,0)
rslider bounds(185,35,65,65), channel("gain2"), text("Level2"), colour(400,100,100), trackercolour(0,400,0), range(0,1,.5)
}
groupbox bounds(293,15,100,100),text("Drive"), plant("drive1"){
rslider bounds(20,30,55,55), channel("drive"), colour(400,100,100), trackercolour(0,400,0), range(0,1000,0,.5)
}
groupbox bounds(415,15,135,100),text("LP Filter"), plant("filer2"){
rslider bounds(5,30,65,65), channel("cutoff2"), text("Cutoff"), colour(400,100,100), trackercolour(0,400,0), range(0,300,100)
rslider bounds(65,30,65,65), channel("res2"), text("Res"), colour(400,100,100), trackercolour(0,400,0), range(0,1,.1)
}
groupbox bounds(415,130,135,100),text("HP Filter"), plant("filer1"){
rslider bounds(5,30,65,65), channel("cutoff1"), text("Cutoff1"), colour(400,100,100), trackercolour(0,400,0), range(1,20000,30,.2)
rslider bounds(65,30,65,65), channel("res1"), text("Res1"), colour(400,100,100), trackercolour(0,400,0), range(1,100,1)
}
groupbox bounds(350,265,250,95),text("Amp Env"), plant("amp1"){
rslider bounds(5,30,65,65), channel("att"), text("Attack"), colour(400,100,100), trackercolour(0,400,0), range(0.01,5,.05,.5)
rslider bounds(65,30,65,65), channel("dec"), text("Decay"), colour(400,100,100), trackercolour(0,400,0), range(0.0,3,1)
rslider bounds(125,30,65,65), channel("sus"), text("Sustain"), colour(400,100,100), trackercolour(0,400,0), range(0.0,3,1)
rslider bounds(185,30,65,65), channel("rel"), text("Release"), colour(400,100,100), trackercolour(0,400,0), range(0.01,3,.3,.7)
}
groupbox bounds(600,15,100,250),text("FilterEnv"), plant("filterenv"){
rslider bounds(20,30,65,65), channel("att2"), text("Attack2"), colour(400,100,100), trackercolour(0,400,0), range(0.01,5,.1)
rslider bounds(20,100,65,65), channel("dec2"), text("Decay2"), colour(400,100,100), trackercolour(0,400,0), range(0,3,.5)
rslider bounds(20,170,65,65), channel("sus2"), text("Sustain2"), colour(400,100,100), trackercolour(0,400,0), range(0,3,.5)
rslider bounds(20,200,65,65), channel("rel2"), text("Release2"), colour(400,100,100), trackercolour(0,400,0), range(0.01,3,.5)
}
groupbox bounds(130,265,200,95),text("Reverb"), plant("reverb1"){
rslider bounds(5,30,65,65), channel("drywet") text("Dry/Wet"),colour(400,100,100),trackercolour(0,400,0), range(0,1,0)
rslider bounds(65,30,65,65), channel("size") text("Size"), colour(400,100,100),trackercolour(0,400,0), range(0,1,.1)
rslider bounds(125,30,65,65), channel("lp") text("Lp"), colour(400,100,100),trackercolour(0,400,0), range(0,1,.1)
}
groupbox bounds(15,265,95,95),text("Master"),
rslider bounds(35,295,55,55), channel ("master"), colour(400,100,100), trackercolour(0,400,0), range(0,1,1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
kGain chnget "gain1"
ksemi chnget "semi1"
kdetune chnget "cent1"
koctave chnget "octave1"
kGain2 chnget "gain2"
ksemi2 chnget "semi2"
kdetune2 chnget "cent2"
koctave2 chnget "octave2"
kdrive chnget "drive"
kcutoff2 chnget "cutoff2"
kres2 chnget "res2"
kcutoff1 chnget "cutoff1"
kres1 chnget "res1"
iatt chnget "att"
idec chnget "dec"
isus chnget "sus"
irel chnget "rel"
iatt2 chnget "att2"
idec2 chnget "dec2"
isus2 chnget "sus2"
irel2 chnget "rel2"
kdrywet chnget "drywet"
kreverbsize chnget "size"
kreverblp chnget "lp"
klevel chnget "master"
;MIDI SETUP
imidinn notnum ;notnum — Get a note number from a MIDI event.
iamp ampmidi 1 ;ampmidi — Get the velocity of the current MIDI event.
kbend pchbend 0,2 ;pchbend — Get the current pitch-bend value for this channel.
koctavesel = octave (koctave) ;octave — Calculates a factor to raise/lower a frequency by a given amount of octaves.
kfreq1 = cpsmidinn(imidinn+kbend+int(ksemi)+kdetune) ;cpsmidinn — Converts a Midi note number value to cycles-per-second.
kfreq1 = kfreq1*koctavesel
koctavesel2 = octave (koctave2) ;octave — Calculates a factor to raise/lower a frequency by a given amount of octaves.
kfreq2 = cpsmidinn(imidinn+kbend+int(ksemi2)+kdetune2) ;cpsmidinn — Converts a Midi note number value to cycles-per-second.
kfreq2 = kfreq2*koctavesel2
asig oscil p5, kfreq1, 1 ;Oscil 1
asig2 oscil p5, kfreq2, 2 ;Oscil 2
aout = asig*kGain + asig2*kGain2 ; Oscil 1 + Oscil 2
adrive lpf18 aout, kcutoff2, kres2, kdrive ; lpf18 — A 3-pole sweepable resonant lowpass filter.
ahp bqrez adrive, kcutoff1, kres1, 1 ;ares bqrez asig, xfco, xres [, imode] [, iskip]
kadsr mxadsr iatt,idec,isus,irel ;mxadsr — Calculates the classical ADSR envelope using the expsegr mechanism.
ahp = ahp*kadsr ;Apply amp adsr to output
denorm ahp ;denorm — Mixes low level noise to a list of a-rate signals
aoutL, aoutR freeverb ahp, ahp, kreverbsize, kreverblp ;Reverb
amixL ntrpol ahp, aoutL, kdrywet ;CREATE A DRY/WET MIX BETWEEN THE DRY AND THE REVERBERATED SIGNAL
amixR ntrpol ahp, aoutR, kdrywet ;CREATE A DRY/WET MIX BETWEEN THE DRY AND THE REVERBERATED SIGNAL
outs amixL, amixR
;outs amixL*klevel, amixR*klevel
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f1 0 1024 10 1 ; Sin wave
f2 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111 ; Saw wave
f0 2000
</CsScore>
</CsoundSynthesizer>