Is there a way to give the user a [+] button, which when clicked will add a new oscillator to a list, much like in Phase Plant?
Allowing user to add an indefinite amount of oscillators
Sure. You could write your own additive UDO where the number of harmonics is controlled at k-time. Then enable or disable them at your leisure.
Oh, sorry if I was unclear, I meant separate oscillators. Each with their own knobs for unison, waveform, pan, etc.
Oh, right, Yeah, also possible. You can just start a new instance of your oscillator module when you push a button:
if changed(chnget:k("plusButton")) == 1 then
event "i", 0, "OscillatorModule", 0, 2, .etc..
endif
Wow, great! Thanks! I’ll have to look into event
. Is that considered an opcode?
Yes, there are quite a few ways of starting other instruments, readscore, scoreline, event, schedule, etc. They are very powerful. I use them all the time
Niiiice Now would the additional GUI element be part of that module?
This might be more involved. What I would do is create a basic plant for your module. Then add loads of them to the Cabbage section, but set their X/Y coordinates to be off screen. Then when a user hits the add button, you simply bring the plant into view. For this to work, you should use channels that have a number in their name. Then you can easily write your module to pick up the unique channels by simple passing a p-field parameter. For example, the Cabbage section might look like this:
image bounds(..){
rslider channel("detune1")
rslider channel("octave1")
}
image bounds(..){
rslider channel("detune2")
rslider channel("octave2")
}
image bounds(..){
rslider channel("detune3")
rslider channel("octave3")
}
Then in Csound:
instr 1
SChannel1 sprintf "detune%d", p4
kDetune chnget SChannel1
SChannel2 sprintf "detune%d", p4
kOctave chnget SChannel2
...
endin
Each time you start a new instance of instr 1, use a p-field that matches the channels, i.e,
kNumberOfInstances init 0
if changed(chnget:k("plusButton")) == 1 then
event "i", 0, "OscillatorModule", 0, 2, kNumberOfInstances
kNumberOfInstances +=1
endif
Basically, if you organise this correctly, you can save yourself a lot of work!
Ah, that’s what I was fearing… Okey, so if I wanted to do 3 different [+]-buttons for three different types of oscillators, that would… complicate things… heh
It shouldn’t be that complicated. But like I said, it will involve some planning!