MIDI In CHOP

From TouchDesigner 099 Wiki

Summary

The MIDI In CHOP reads Note events, Controller events, Program Change events, System Exclusive messages and Timing events from both MIDI devices and files. See also MIDI In Map CHOP.

The MIDI In CHOP receives MIDI events from MIDI devices connected to the serial port, reads MIDI events internal to the workstation (i.e. the built-in software synth), and interprets musical scores in MIDI files. Supported MIDI events are:

Note On, Note Off
Polyphonic Aftertouch
Channel Pressure
Program Change
Control Change (MIDI controller devices)
Pitch Wheel
Timer Events including beat pulses
Bar Messages
Start, Stop, Continue
Song Position Pointer
System Exclusive Messages

MIDI events arriving on separate MIDI channels may be recorded on separate CHOP channels. Also, any number of MIDI CHOPs can read from the same or different sources. TouchDesigner can be configured such that MIDI Start, Stop, or Continue events can control the Timeline and Beat Dialog.

The 'Simplified Output' option creates a channel for every type of MIDI event received, so number of channels expands while the devices is being used. No need to specify name, channel and index patterns.

Note: The values of the MIDI inputs are saved into the TouchDesigner .toe file, and are restored when the file is reloaded. The physical controllers may be in a different position when the .toe is restarted, causing the values to jump when the controllers are moved. This is unavoidable.

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

PythonIcon.png midiinCHOP_Class

Parameters - Source Page

MIDI Source - Get MIDI input from a device or a file.

Device Table /device - path to the MIDI device Table DAT

Device ID /id - specify the id of which device to use.

MIDI File - If MIDI file is selected as the MIDI source use this field to specify the name of the MIDI file to read. The file can be read in from disk or from the web. Use http:// when specifying a URL.

Read Entire MIDI File - If enabled, the entire MIDI file is read. Otherwise, the Start and End parameters on the Channel page determine the segment of the file to read.

Simplified Output - When this is on channels are automatically created when MIDI signal is detected from the selected MIDI device.

1 Based Index - Make the index 1 based instead of the default 0 based.

MIDI Channels - The CHOP may read from any number of MIDI channels, numbered 1-16. Ranges and multiple entries are supported (i.e. "1 4 6", "1-7 12", "1-5:2").

If Channel Prefix is left blank, then the input streams from multiple MIDI channels will be combined into one set of CHOP channels (i.e., a "note 64 on" event on channel 12 followed by a "note 64 off" event on channel 8 appears in the note 64 CHOP channel as a single note).

Channel Prefix - When recording from multiple MIDI channels, putting a string like "ch" in this parameter causes the MIDI channel to be split into separate CHOP channels per MIDI channel. Otherwise the MIDI channels are all merged into one set of CHOP channels.

Parameters - Record Page

These parameters are disabled when Simplified Output is on.

Record Method - Determine what to record.

  • Single Frame - This only outputs the current value of notes, controllers, etc. It does not retain prior values. It creates a CHOP at frame 1 always, so the CHOP causes cooking only when MIDI events come in.
  • Current Frame - Same as "Single Frame", but the CHOP frame is always at the current frame, so the CHOP changes every frame, causing other CHOPs to recook every frame.
  • Current Time Slice - The CHOP frame is always at the current Time Slice.
  • Full Length - The entire length of the timeline is recorded.

Record - This parameter is used as a button to start and stop recording into the CHOP channels..

Reset - Sets the CHOP length to one sample, erasing the data in the channels.

Parameters - Note Page

Note Name - Put an "n" in here to generate channels for note events. It is the base name of the CHOP channel used to record notes. If blank, notes are ignored. If the Note Output parameter is set to Separate Channels, then CHOP channels will be created for each note in the Note Scope, of the form: notename | notenumber (i.e. "n64").

Note Scope - The scope of notes to record. Multiple ranges and notes can be recorded (i.e., "50-60", "64 65 66 70-80").

Note Output

  • Separate Channel - Each note number gets its own CHOP channel.
  • One Multiplexed Channel - One CHOP channel per MIDI channel is used for all notes. The value in the note channel is the number of the note currently playing (in the case of multiple notes playing, the most recent note is selected).

Velocity

  • Off - Velocity is not recorded.
  • Note Amplitude - The velocity is recorded as the amplitude of the note. Only valid when Note Output is set to Separate Channels.
  • Separate Channels - Velocity is recorded in separate CHOP channels. Each note channel will have a corresponding velocity channel.

Velocity Name - When Velocity is set to Separate Channels, this parameter is the base name of the Velocity CHOP channel (try "v"). If blank, no velocity channels will be recorded.

Aftertouch Name - The base name of the polyphonic Aftertouch CHOP channels. One aftertouch channel is created for each note in the Note Scope. If blank, no aftertouch channels will be created.

Pressure Name - The name of the Channel Pressure channel. If multiple channels are being recorded, all channel pressure changes of interest will be recording on this CHOP channel. If blank, this channel will not be created.

Normalize - Note values can be normalized for convenience:

  • None - When Normalize is Off, 7 bit controllers will return values in the range 0-127 and 14 bit controllers will return values in the range 0-16383.
  • 0 to 1 - These values are normalized to lie in the range 0 to 1.

Pitch Wheel Name - The name of the Pitch Wheel CHOP channel. Pitch wheel values range from -1 to +1. If blank, this channel will not be created. Put "p" in here to generate a channel.

Parameters - Control Page

Controller Name - The base name of the Control Change CHOP channels. The channel names are appended with the controller index (0-127). If blank, control changes will not be recorded. It typically contains "c".

Controller Type - There are 128 different controllers available. By choosing By Index Only, you can specify any number of controllers in the Control Index parameter. Otherwise, you can select a controller from the list from this menu. Some controllers have multiple instances, such as Sound Controllers 1-10. Selecting a controller with multiple instances allows you to use the Control Index parameter to select which instances you want. Any invalid control indices will be ignored.

Controller Index - Used to select controllers by number, or multiple controllers by ranges. When in By Index Only Controller Type mode, you can select up to the full 128 controllers or sub-ranges thereof (i.e. "1-10", "2 34 70", "1-32 70-80:2").

Controller Format - Some controllers can be paired together to form 14 bit controllers, rather than the normal 7 bit controllers (controller indices 0-31, 98 and 100). Selecting 14 bit Controllers interprets a pair as one 14 bit controller. Otherwise, they are interpreted as separate 7 bit Controllers.

Normalize - Controller values can be normalized for convenience:

  • None - When Normalize is Off, 7 bit controllers will return values in the range 0-127 and 14 bit controllers will return values in the range 0-16383.
  • 0 to 1 - These values are normalized to lie in the range 0 to 1.
  • -1 to 1 - These values are normalized to lie in the range -1 to +1.
  • On/Off - Several of the controllers are simply on/off states. When Convert to On/Off is enabled, values greater than or equal to 64 will be interpreted as "1" and all values less than 64 will be interpreted as "0".

Unwrap -

Program Change - The name of the Program Change CHOP channel. All program change messages will be recorded onto this channel. If blank, this channel will not be created.

Parameters - Sys Page - Common Sub-Page

Timer Pulse Name - The name of a channel that pulses on MIDI beats. Most MIDI devices can send a MIDI timer signal. This is the name of a CHOP channel that will record this timing signal. If blank, the channel will not be created.

Timer Ramp Name - The name of a channel that ramps from 0 to 1 between MIDI beats. Uses same MIDI timer signal as Timer Pulse Name.

Timer Period / Start - The names of two channels that are constant. The first channel is the MIDI pulse period, the time between pulses. The second channel is the time of the start of a pulse. These can be used to feed another CHOP that creates a reference start/end, such as what the Beat CHOP outputs.

Ticks per Beat - Defines the number of timer pulses that make up one MIDI beat. For example, if it is set to 24, every 24th timer pulse is recorded as one pulse and ramp of the Timer Pulse and Ramp channels.

Bar Marker Name - The name of a channel that ramps from 0 to 1 between MIDI bars. Uses same MIDI timer signal as Timer Pulse Name. After getting a Bar Marker event, the ramp does not start until the next tick event.

Bar Period / Start - The names of two channels that are constant. The first channel is the MIDI bar's period, the time of one bar of music. The second channel is the time of the start of a bar. These can be used to feed another CHOP that creates a reference start/end, such as what the Beat CHOP outputs.

Bar Message - To mark the start of a bar, a message can be sent in the MIDI stream. When it is received, the CHOP waits until it sees a MIDI Timer Pulse message (F8) before it starts the bar. The bar continues until the next Bar Message / Timer Pulse message.

The Bar Message has the same pattern-matching string as a System Exclusive message, as seen under the Exclusive1 to 3 pages.

Song Pos Name - The name of the Song Position pointer channel. This channel will contain the value of the last received song position.

Parameters - Sys Page, Exclusive1 to 3 Sub-Pages

Channel n / Message n - TouchDesigner can turn System Exclusive messages into CHOP channels. Each sub-page has enough room for four sysex messages and corresponding channel names.

The Exclusive sub-page's Message parameters are compared against the MIDI messages coming into the MIDI interface, and the Midi In CHOP tries to match them.

Example. Assume the following appears in the Message 1 parameter of the Exclusive 1 sub-page of the Sys page.:

 F0 7F 01 * v F7

These numbers are in hexadecimal. Sysex starts with F0 and ends with F7. Each MIDI byte is separated by a space in the message string. A * matches any byte. A v means that the CHOP interprets the bytes as a value that should be put in the channel named by the Channel Name 1 parameter.

Parameters - Chan Page

This is similar to other generators' Channel page. However, there are a few points to consider on how they affect the Midi In CHOP.

Start - Defines where recording begins. In "Tie to Time Line" mode, any events received before the start time will be ignored. In "Time Line Independent" mode, recording will start at this point and continue on (not looping back). If reading from a MIDI File, Start/End will determine the start of the segment to read.

End - Defines the end of the segment to read for MIDI Files.

Sample Rate - Defines the sample rate of this CHOP. If the sample rate is too low, a rapidly changing input may be misrepresented.

Note: If the sample rate is too low, you may miss MIDI events. A note event may set a sample value to 1, and then the next note event less than 1/30 second later can set it to 0 on the same sample in the CHOP channel. So the event will be missed. Make the sample rate higher, like 600, to catch these events, or make sure that your on-off events coming in are a minimum time separation, as can be achieved through Opcode's MAX.

Parameters - Common Page

Scope - Scoped channels will be overwritten upon recording; tracks that are not scoped will not be overwritten (they will also not be removed). Altering the scope and re-recording is a good way to layer effects.

Standard Options and Local Variables

There are no local variables.