Cabbage Logo
Back to Cabbage Site

Oscillators as sources for vst synth

Trying to create an oscillator that I can use different fgen waveforms selected using something like a combobox widget any ideas on how to do this welcome the whole project is to build a vst instrument also handy to be able to use a rslider widget to alter the phase of the waveform :thinking:

Oscili synth combobox ?

<Cabbage>

form caption("Synth") size(400, 300), colour(58, 110, 182), pluginid("def1")

keyboard bounds(8, 158, 381, 95)

combobox items("sine", "saw", "square", "pulse"), channel("combobox")

</Cabbage>

<CsoundSynthesizer>

<CsOptions>

-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5

</CsOptions>

<CsInstruments>

; Initialize the global variables.

ksmps = 32

nchnls = 2

0dbfs = 1

;gen10routines

instr 1

 

gisine ftgen 0, 0, 16384, 10, 1

gisaw ftgen 0, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0, 0.167, 0.14, 0.125, .111

gisquare ftgen 0, 0, 16384, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111

gipulse ftgen 0, 0, 16384, 10, 1, 1, 1, 1, 0.7, 0.5, 0.3, 0.1

 

isine2 oscili p5, p4, gisine

isaw2 oscili p5, p4, gisaw

isquare2 oscili p5, p4, gisquare

ipulse2 oscili p5, p4, gipulse

 

kwaveselect = chnget i:("combobox")

 

if kwaveselect = i:(1) then

 

asigin = isine2

 

elseif kwaveselect = i:(2) then

 

asigin = isaw2

 

elseif kwaveselect = i:(3) then

 

asigin = isquare2

 

else kwaveselect = i:(4) then

 

asigin = ipulse2

 

endif

 

endin

  

instr 2

  

aOut oscili p5, p4, asigin

  

outs aOut, aOut

  

endin

 

</CsInstruments>

<CsScore>

;causes Csound to run for about 7000 years...

f0 z

</CsScore>

</CsoundSynthesizer>

 This is the code I have so far and I'm wondering where my syntax is going wrong I'm try to create a wave table synth that I can choose either a sine saw square or pulse wave using a combobox widget

form caption(“Synth”) size(400, 300), colour(58, 110, 182), pluginid(“def1”)

keyboard bounds(8, 158, 381, 95)

combobox items(“sine”, “saw”, “square”, “pulse”), channel(“combobox”), value(1), range(1, 4, 1, 1, 1)

-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5

; Initialize the global variables.

ksmps = 32

nchnls = 2

0dbfs = 1

;gen10routines

instr 1

gisine ftgen 0, 0, 16384, 10, 1

gisaw ftgen 0, 0, 16384, 10, 1, 0.5, 0.3, 0.25, 0.2, 0, 0.167, 0.14, 0.125, .111

gisquare ftgen 0, 0, 16384, 10, 1, 0, 0.3, 0, 0.2, 0, 0.14, 0, .111

gipulse ftgen 0, 0, 16384, 10, 1, 1, 1, 1, 0.7, 0.5, 0.3, 0.1

kwave chnget “combobox”

iwave = i(kwave)

if iwave==1 then

asigin init gisine

elseif iwave==2 then

asigin init gisaw

elseif iwave==3 then

asigin init gisquare

elseif iwave==4 then

asigin init gipulse

endif

endin

instr 2

aOut oscili p5, p4, asigin

outs aOut, aOut

endin

;causes Csound to run for about 7000 years…

f0 z

</CsoundSynthesizer>

Changed up the syntax I believe it’s more accurate but I’m still not having any luck
Was hoping someone might have any ideas
where I’m going wrong

Wanted to know the name of any good csound
Learning resources

You can just use an i-rate channel to get the waveshape you want.

iwave chnget “combobox”
aOut oscili p5, p4, iwave

Channels can handle i, k and a rate data. The floss manual is a good resource for learning Csound. I think this book is one of the best out there.

That’s brilliant but what if I want to use multiple oscillators and a combobox for each oscillator

Just modify the code above? I think it might be worth your while going over the Csound floss manual first. It’s quite hard to jump straight into Csound. But much of what you are trying to do should become clearer if you start at the beginning and work from there.