Cabbage Logo
Back to Cabbage Site

Oscili synth combobox

Trying to code my first synth in cabbage and want to use a combobox to select which waveform to play I have four oscili opcodes all with different gen10 functions and have added outputs as asigsine asigsquare and so. I was wondering if anyone had any solutions to this problem.

Here you go. Note that the slider range. It’s set to move in increments of one. Also note that you should be careful generating waveforms with oscili as you may well get aliasing. vco2 is a better approach.

form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
rslider bounds(12, 8, 60, 60) channel("waveform"), range(1, 3, 1, 1, 1) text("Waveform")
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
aOut oscili p5, p4, chnget:i("waveform")
outs aOut*kEnv, aOut*kEnv

f1 0 4096 10 1 
f2 0 4096 10 1 .5
f3 0 4096 10 1 .5 .2 .1 

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

selectWaveform.csd (780 Bytes)

Sorry, I should have used a combobox :speak_no_evil:

Thanks that’s great.