[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] How would I send midi control changes using VoicerMIDISocket



On Saturday, December 28, 2013 11:20:17 PM HKT, Simon Rees wrote:
I'm using a BCR2000 control surface with VoicerMIDISocket to control the arguments to SynthDefs. Because the BCR2000 uses rotary encoders with an LED indicator of the current value of a control it would be handy if I could send MIDI control changes to the BCR2000 when the control initial value is set in sclang. This would mean there would be no need to 'pick up' the control value and I instantly be able to see the current control values on the control surface. Is there a way of doing this using VoicerMIDISocket? If this feature
isn't
available, does anyone have any suggestions as to how I might go about implementing this.

This isn't VoicerMIDISocket's job. In object-oriented programming, a class should have a clearly-defined purpose and not incorporate features that are only tangentially related. VoicerMIDISocket receives noteOn and noteOff messages, and forwards them to a Voicer object. It also, for convenience, helps with mapping CCs onto global controls -- like VoicerMIDISocket, this is unidirectional.

I think, actually, what you want to do is pick up any change of the controller's value, from any source, and forward that to the BCR. GenericGlobalControl broadcasts a "changed" notification every time its value changes, and you can attach an Updater to it. (VoicerGlobalControl is a subclass of GenericGlobalControl, and it does the same thing for value changes.)

v = Voicer(.....);
v.mapGlobal(\pan, nil, 0, \bipolar);

k = VoicerMIDISocket(0, v);
k.addControl(10, \pan);

u = Updater(v.globalControls[\pan], { |obj, what|
	if(what[\what] == \value) {
		myBCR2000MidiOut.control(chan, ctl, what[\value].linlin(-1, 1, 0, 127))
	}
});

No time to test this morning, but this ought to be pretty close. With this, if you set the pan control in code, it should show up on the BCR.

You'd probably also have to send MIDI out at initialization time (when creating the Voicer and MIDI mappings). Probably something like this:

k.ccs.do { |cc|
myBCR2000MidiOut.control(chan, cc.ccnum, cc.destination.value.linlin(-1, 1, 0, 127))
};

hjh

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/