Another thing I am currently trying to learn how to accomplish in SC is to build a polyphonic synthesizer that (a) I can play via MIDI, and (b) whose parameters (= args of its SynthDef) I can change while playing it – with the ultimate goal to use MIDI controllers for changing its parameters.
If I understood the concept behind this explanation correctly, each voice of my MIDI-controlled polyphonic synthesizer is actually a synth
node on the server with its own ID, so I can’t address each individual synth
via storing it one variable and using VARIABLE.set(KEYWORD_VALUE_PAIRS)
:
But if I ensure that all voices (synths
) are put into a group, I can assign this group to a variable and change args of the enclosed synths using VARIABLE.set(KEYWORD_VALUE_PAIRS)
, no?
So I created a new group:
g = Group.new;
Then I added a SynthDef
(please see end of this post for complete code) and in my MIDI function ensured that the synths (= all voices) are created in the target group g
:
MIDIFunc.noteOn({
|vel,num|
//put a synth into the played index of array
notes[num] = Synth(\tone,
[\freq, num.midicps, \amp, vel/127, \gate, 1],
target: g
);
});
When playing, this sounds and looks successfull:
Now to the frustrating part: I want to set the arg
named feedback
for all sounding and all future notes I will be playing. So I did this:
g.set(\feedback, 3);
Unfortunately, this only works for the currently sounding notes. I guess I must have misunderstood something very thoroughly, but for the life of me I can’t figure out what it is. Please, how can I accomplish my goal? Thanks much in advance for any help!
Complete Code
g = Group.new;
(
SynthDef(\tone,{
arg freq = 300, amp= 0.1, feedback=0.7, gate=0;
var sig, env;
env = EnvGen.kr(Env.asr(0.1,1,1),gate,doneAction:2);
sig = SinOscFB.ar(freq,feedback*env*amp,amp);
sig = sig*env;
sig=Pan2.ar(sig,0);
Out.ar(0,sig*0.1);
}).add
)
(
var notes;
notes = Array.newClear(128);
MIDIFunc.noteOn({
|vel,num|
notes[num] = Synth(\tone,
[\freq, num.midicps, \amp, vel/127, \gate, 1],
target: g
);
});
MIDIFunc.noteOff({
|vel,num|
notes[num].release;
});
)
g.set(\feedback, 3);
P.S.
I need go to bed now, and as the working week starts again tomorrow morning, it will take some time until I have a chance to react to & digest any reaction. But I had to get this question out of my system before I can sleep. My journey with SC has been quite a rollercoaster ride: First I think I understood a concept (joy!), then I try to apply it to the things I want to achieve, only to find out I have not understood the concept (frustration). Perhaps I bite off more than I can chew. I dont know. So please pardon all the questions I am asking, and thank you for your continued patience & help!