MIDIBufManager


Storage for as many MIDIRecBuf objects (MIDI record buffers) as needed. Also handles the starting and stopping of MIDI note recording, and presents a GUI for selection of buffers and triggering recording.


*new(clock, chan, ccnum)


clock: The clock to use for measuring time while recording notes.

chan: The MIDI channel to listen for notes. See BasicMIDISocket for a description of how to identify the MIDI channel.

ccnum: A MIDI continuous controller may be used to select buffers. This is its controller number, or CControl object.


free


Release all objects belonging to this buffer manager.


Buffer access:


add(buf)

remove(buf)


Adds or removes the given MIDIRecBuf.


No two buffers in the same buffer manager may have the same name. The buffer manager has a Boolean flag, overwrite, that determines what to do if a buffer is added with the same name as an existing buffer. If true (the default behavior), the new buffer replaces the old one in the same index position. If false, an error is thrown.


removeAt(index)


Remove a buffer by position (array index) or name.


removeCurrent


Remove the currently selected buffer.


value_(index)


Set the current buffer to the buffer identified by the number or name provided.


at(index)


Retrieve a buffer by array index or name.


current


Returns the currently selected buffer.


Recording control:


initRecord(properties)


Begin recording. Buffer properties may be set; see the MIDIRecBuf help file for a description of MIDI buffer properties.


stopRecord


Complete recording, perform additional processing on the buffer and return the new buffer. The buffer is automatically saved in the currently selected buffer slot, set by value_.


Additional processing is performed by the postRecFunc function, which belongs to the buffer manager. If you want all buffers to be quantized in a specific way, or parsed for grace notes, write the operation into this function. The function will apply to all buffers recorded in this buffer manager.


myMBM.postRecFunc = { |buf| buf.quantize(0.25).parse };