MIDI CC and instrument connectivity issue

HI, everyone! I’m new to the community and SC as a whole, it’s incredibly nice to meet all of you and I hope you’re all having a great day.

[What is this chunk of code supposed to do?]

This is supposed to read midi messages from my hardware to software.
One part is a functional polyphonic synthesizer whose function depends on MIDI input called \bm, and the other part/instrument is a reverb unit that simply process’s \bm, but my MIDI params aren’t able to change or connect to \rev’s arguments, which is where my problem arises.

[Is there an area or topic I would like specific feedback on?]

I’m primarily having an issue with applying the MIDI CC7 (otherwise known as Mididef.cc(/ccT6 and boo in my code), to the reverb instrument instance /rev. The problem is that I can read the messages from the MIDI instance using postln, and I can see that it is reading CC7 properly in the post window, but I can’t seem to connect the param ~boo or boo to /rev’s params.

I understand that the polyphonic synthesizer part works, because with every note press it is applying a new iteration of params and Synths with each note on, and turns them off(free’s) as soon as the end of their cycles have been met. but why can’t I get ~boo / boo or CC7 to work with /rev? I know I don’t want to keep recreating reverb units every time I turn a knob or adjust a param, (like the polyphonic synthesizer) so how do I make sure /rev understands what ~boo,\boo or CC7 is doing without issue?

CC7/boo is supposed to manipulate inputbandwidth of the Gverb reverb unit, \rev.

Thank you too, whomever takes a look at this, I’ve been furiously trying to get this to work over the last few days.


MIDIdef.cc(\ccT, {
	arg val, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\atk, ~atk);
		~atk = val.linlin(0, 127, 0.0, 1.0);
MIDIdef.cc(\ccT1, {
	arg val, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\dec, ~dec);
		~dec = val.linlin(0, 127, 0.0, 1.0);
MIDIdef.cc(\ccT2, {
	arg val, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\sus, ~sus);
		~sus = val.linlin(0, 127, 0.0, 1.0);
MIDIdef.cc(\ccT3, {
	arg val, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\rel, ~rel);
		~rel = val.linlin(0, 127, 0.0, 1.0);
MIDIdef.cc(\ccT4, {
	arg val, conv, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\cut, ~cut);
		~cut=val.linlin(0, 127, 20, 10000);


MIDIdef.cc(\ccT5, {
	arg val, cc, chan, src;
	[val, cc].postln;
	~notes.do ({ arg synth;
		synth.set(\q, ~q);
		~q = val.linlin(0, 127, 0.15, 1.0);
/*MIDIdef.cc(\ccT6, {
	arg val, cc, chan, src;
	[val, cc].postln;
	Synth(\rev,{ arg synth;
		~boo = val.linlin(0, 127, 0.0, 1.0);
MIDIdef.noteOn(\noteOnTest, {
	arg vel, nn, chan, src;
	[vel, nn].postln;
	~notes[nn] = Synth.new(
		\bm, [
			\freq, nn.midicps,
			\amp, vel.linexp(1, 127, 0.01, 0.5),
			\gate, 1.0,
			\atk, ~atk,
			\dec, ~dec,
			\sus, ~sus,
			\rel, ~rel,
			\cut, ~cut,
			\q, ~q
MIDIdef.noteOff(\noteOffTest, {
	arg vel, nn, chan, src;
	[vel, nn].postln;
	~notes[nn].set(\gate, 0);
	~notes[nn] = nil;


x=SynthDef.new(\bm, {
		arg out=4, freq = 440.0, amp=0.1, gate=0.0, atk=1.0, dec=0.8, sus=0.8, rel=0.8, cut=1.0, q=0.0;
		var sig, env, vern;
		sig = LFSaw.ar(freq)!2;
	vern = RLPF.ar(sig,cut,q,1.0);
	env = EnvGen.kr(Env.adsr(atk,dec,sus,rel), gate,timeScale:5, doneAction:2);
	sig = vern * env *  amp;
	Out.ar(out, sig);
SynthDef.new(\rev, {
		arg  in=4, out=0, boo=0.0;
		var sig;
	sig = In.ar(in, 2);
	sig = sig+(GVerb.ar(sig, 1, 0.5, 0.0, boo, taillevel:0.7, maxroomsize:300) * 0.2);
	Out.ar(out, sig);

x = Synth(\bm);
Synth.new(\rev, [\in, 4, \out, 0], x, \addAfter);


~notes = Array.newClear(128);
~atk = 0.0;
~dec = 0.0;
~sus = 0.0;
~rel = 0.0;
~cut = 1.0;
~q = 0.0;
~boo = 0.0;

1 Like

Hi Taylor. You are super close.

One thing is, you need to give the reverb synth a variable name, so that the language knows where it is on the server:

y = Synth.new(\rev, [\in, 4, \out, 0], x, \addAfter);

then you just need to set the argument for that variable:

MIDIdef.cc(\ccT6, {
	arg val, cc, chan, src;
	[val, cc].postln;
	y.set(\boo, val/127)
}, 7);


This way it only changes the existing synth.

Does that help?



Oh my gosh, that is perfect!!! Thank you so much Sam!!!