MIDI Out CHOP

From TouchDesigner 099 Wiki

Summary

The MIDI Out CHOP sends MIDI events to any available MIDI devices when its input channels change. More flexibly, the Python MidioutCHOP Class can be used to send any type of MIDI event to a MIDI device via an existing MIDI Out CHOP. In Tscript, the midi command can output MIDI events.

The MIDI devices can be other software programs (such as midisynth) or devices attached to the serial ports. Channels are used to control the sending of the MIDI events. The channels are evaluated over the last time slice (from the last Timeline position to the current).

The MIDI Out CHOP sends MIDI events based on any changes to its input channels. The channels have to be named appropriately, like ch3c14 and ch7n60.

An event is sent every time a channel changes its value during this slice. All timing is preserved, as long as the Timeline is running in realtime (the "Realtime" flag is in the top menu bar).

Naming the CHOP channels: Channels are mapped to events by their name. Events like notes, controllers and velocities must be followed by the note/controller number (n65, c7). If the number is left off a note event, the note number is the value of the channel. Other events, which are sent to the entire channel, do not need a trailing number (pc, pw). The channel prefix can be used to identify the MIDI channel the event should be sent on (i.e. "ch1n45" assigns that TouchDesigner channel to note 45 messages on MIDI channel 1). Channels can always be renamed with a Rename CHOP before entering the MIDI Out CHOP.

The MIDI Out CHOP sends MIDI velocity as well. The values of the channels entering the MIDI Out CHOPs are sent as the velocity of the note. If Normalize is "None", the channel needs to be 0 to 127. If Normalize is "0 to 1", channel values between 0 and 1 are scaled to be MIDI 0 to 127.

The "Cook Every Frame" option cooks the CHOP every frame, even if the CHOP isn't being displayed. All Volume Off and All Volume On flags are new and emit events for Controller 7 of all 16 channels. MIDI output go in a separate thread to allow output that slows TouchDesigner less. It now works in Time Slice mode for note events and controller events. (Not for Program Change or Sysex messages yet) Note channels only trigger anew Note On when the input channel goes from 0 or less to a value greater than zero. Similar for Note Off events.The channel name determines how it is interpreted.

For example,

ch3n60 - this channel is interpreted as channel3 note 60. A Note On event is sent when the value goes from 0 or less to greater than zero
ch5n - This channel will contain note numbers.  The value quantized to an integer, and when the integer value changes, the note of the old value goes off and the note of the new value goes on. If the channel steps from 53 to 78, it sends a Note Off event for note 53, and a Note On event for note 78.
ch14c7 - the value of the channel is sent to controller 7 (volume) of channel 14. By default, the values 0 to 1 are mapped to MIDI value 0 to 127.

These features work in Time Slice mode:

By default, channels are to start with "ch" followed by the channel number (1-16). In the case of notes, it is followed by "n" for notes, then digits for the note number. In the case of controllers, it is followed by "c" and a controller number. These prefixes can be altered. MIDI Out now interprets aftertouch, pressure, pitchwheel channels, and outputs these events to the MIDI stream. Note-normalization is added allowing 0 to 127 and 0 to 1 ranges. MIDI Out reads a bar ramp channel to output MIDI clock events  (with a channel popup menu to the parameter to select the channel name). Program change events are implemented through the "pc" channels.both 7 and 14 bit controller events can be output. You can capture a MIDI stream and output it to a file.

See also the MIDI In DAT, MIDI Event DAT, MIDI In Map CHOP, MIDI In CHOP, midi command.

PythonIcon.png midioutCHOP_Class

Parameters - Dest Page

MIDI Destination - Where the MIDI events are sent to. MIDI Mapper is the default destination.

MIDI File - The filename of the output MIDI file.

Write MIDI File - Writes all the data to a MIDI file.

Channel Prefix - The prefix string that all input channels must have in order to extract the channel number from their name (i.e. "ch1note44", with a channel prefix of "ch").

Cook Every Frame - Forces a cook of the CHOP every frame. It should be On because the MIDI Out CHOP will otherwise only cook if the CHOP leads to a graphics display viewer. You want it to cooks whether you are displaying anything or not.

Echo Messages To Textport - not implemented.

Parameters - Output Page

Automatic Note Off - A MIDI 'All Note Off' event can be sent upon the start and/or end of the output.

All Notes Off - Sends an All Notes Off message to all MIDI channels.

All Volume Off - Sends an All Notes Off message to all MIDI channels.

All Volume On - Sends an All Notes Off message to all MIDI channels.

Send Start/Stop/Continue Events - Sends the appropriate events when the framebar starts or stops.

---- not implemented: ----

Pre-Queue Time - MIDI events are generated and queued this amount of time ahead of the current frame.

Delay Time - All events will be played later by this amount of time.

Max Jump Time - If the Timeline increases by this amount or more since the last cook, MIDI events in that interval will be skipped.

Synchonize - If TouchDesigner could not cook in time to generate the next set of MIDI events, it recovers by one of two methods. Missed events are either skipped or output immediately.

Parameters - Note Page

Note Name - The base name of the note channels. If input channels have a number after the name, it is assumed to be the note number. If not, the channel value is assumed to contain the note number.

Aftertouch Name - The name of the aftertouch channel.

Pressure Name - The name of the channel pressure channel.

Normalize - Values in the range 0-1 are mapped to MIDI value 0-127.

Pitch Wheel Name - The name of the pitch wheel channel.

Parameters - Control Page

Controller Name - The base name of the controller channels.

Controller Format - Sends 7 or 14 bit controller events.

Normalize - Maps channel values from different ranges to 0-127.

Program Change - The name of the program change channel.

Bar Ramp Name - Clock ticks frequency is determined by the period of the ramp. The ramp must be 0 to 1. An incoming channel name for a 0 to 1 ramp over each 4-beat bar.

Ticks Per Bar - default is 96 = 4 beats * 24 ticks per beat.

Parameters - Sys Page

Standard Options and Local Variables

None.