ExtensionVoicerMIDISocket makes it convenient to play a Voicer by MIDI keyboard.
There is a strict division of labor:
MIDI note data are sent to the Voicer as follows:
freq argument. The conversion is done by the socket's -midiToFreq function. If this function is not provided, then *defaultMidiToFreq is used.gate argument. The SynthDef can convert this to an amplitude using Latch and some range mapping: e.g., Latch.kr(gate, gate).linlin(0, 1, 0.1, 0.5).The note data are also provided to an event pattern that supplies arbitrary arguments for each note. See -noteOnArgsPat.
Create a new instance. Arguments are:
The socket instance.
The default function to convert the incoming MIDI note number into frequency (Hz). During library initialization, this is assigned _.midicps. You may change this function at any time, and it will apply to any new VoicerMIDISockets created in the future. It does not retroactively alter existing sockets.
This function must be deterministic. Voicer will fail to release notes correctly if this function returns different frequencies for the same note number.
Remove the socket completely from the ddwMIDI hierarchy.
Calls the target Voicer's panic method, shutting off all notes. Purely a convenience.
The lowest MIDI note to which this socket will respond. With hikey, this variable supports keyboard splits by creating multiple VoicerMIDISockets on the same channel, with different key ranges.
The highest MIDI note to which this socket will respond.
A number of semitones to add to the note number, before converting to frequency. May be fractional, in which case it also serves as a tuning parameter.
A custom function to translate MIDI note number into frequency. See *defaultMidiToFreq.
An event pattern (e.g., Pbind) providing additional argument values to the Voicer. The pattern can access note number and velocity by Pkey(\midinote) and Pkey(\velocity), respectively. All key-value pairs in the pattern's output events will be passed to the Voicer as note-onset synth arguments. Uses:
An Event containing default values to provide to noteOnArgsPat.
The following methods interface with global controls in the Voicer. Once a control is mapped globally, it makes sense to set its value using a physical continuous controller.
The connection between MIDI CC and global control is handled by VoicerMIDIController. You may use this class directly. In most cases, though, it's easier if the VoicerMIDISocket "owns" the controllers, so that (for instance) freeing the socket will also release the controllers.
Adds a MIDI controller to this socket instance. Two possible cases:
value and spec arguments are optional. If provided, they won't be used.)addControl method will create the global control in the voicer for you, and attach the MIDI controller. This is provided for convenience.| ccnum |
The controller number. See ddwMIDI Guide: Controller_Numbers. |
| name |
The synth argument name (as a Symbol). |
| value |
If a new global control is being created (because none existed), this is the initial value. (If a global control already existed, this is ignored.) |
| spec |
If a new global control is being created (because none existed), this is the ControlSpec. (If a global control already existed, this is ignored.) |
| overrideChan |
By default (if this argument is not given), then MIDI controller will be created on the same MIDI channel as the socket. You may specify a different channel here -- for instance, if you have a full-size keyboard without many continuous controllers, and another device with several knobs, the socket can receive notes from the keyboard, and you can create controller mappings to the other device. |
The socket instance (not the new MIDI controller object).
Disconnect and remove a VoicerMIDIController.
| control |
A way to identify the controller to remove. One of the following:
|
The socket instance.
Look up a VoicerMIDIController (attached to this socket) by the parameter name.
| control |
A |
The VoicerMIDIController instance.
An Array, containing the VoicerMIDIControllers attached to this socket.
Look up a VoicerMIDIController (attached to this socket) by the controller number.
| control |
An integer or |
The VoicerMIDIController instance.
The socket's parent MIDIChannel object. From this, you can get information about the device and channel from which the socket is receiving messages.
Move the socket to the parent MIDIChannel's list of enabled sockets. The socket will then respond to incoming messages.
Move the socket to the parent MIDIChannel's list of disabled sockets. The socket will not respond to incoming messages, but it remains intact so that you can reenable it at any time.
Boolean: true if the socket's destination exists and is active; false otherwise.
Subclasses may implement clear to keep the socket registered in the hierarchy, but become inactive.
This method is called in response to note-on messages. In normal use, you do not need to call this method. You may call it directly for testing or debugging.
| note |
The MIDI note number (0-127). |
| vel |
Velocity (0-127). |
This method is called in response to note-off messages. In normal use, you do not need to call this method. You may call it directly for testing or debugging.
| note |
The MIDI note number (0-127). |
| vel |
Velocity (0-127). |