In this tutorial, we will expand on our use of the seq object by recording new MIDI data, loading existing files and writing sequences to disk. We will also use the second outlet of the seq object to provide looped playback of the current sequence.
Working with existing sequences is useful, but being able to record new sequences within Max allows us to create and store sequences and phrases for later use. This sequencing tutorial is focused on recording, the use of the file input/output functions, and the ability to use the seq object output to loop playback.
To open the tutorial patch, click on the green Open Tutorial button in the upper right-hand corner of the documentation window.
Recording a sequence
Our tutorial has a number of regions with different patcher logic in each. The leftmost region (labeled Recording) shows the basic setup for selecting MIDI input that we saw in earlier MIDI tutorials. The seq object expects a raw MIDI stream, so our recording input comes directly from a midiin object.
Select a valid MIDI input device from the umenu so we can record MIDI data into our own sequence. In addition, double-click the midiout object and select a valid MIDI output device. In addition to feeding the seq object, the midiin object is also sending data to the midiout (via midiflush), so you should be able to test your connections by playing on your MIDI controller.
Clicking on the red message box, then play some MIDI data in from a connected controller. Clicking the message will stop recording; we can then hit to hear the playback of the MIDI we just recorded. Since the seq object is recording the complete MIDI stream, we can also send continuous controllers, pitchbend messages, program changes or any other MIDI data – it will be recorded and played back just like note messages. As in the last tutorial, we use the midiflush object in between seq and midiout to silence any remaining note-on messages when we our sequence.message will start the recording of MIDI data. Click on this
Loading and saving a sequence
Once we’ve recorded a sequence, we may want to save the results. This is where the file-handling messages come into play. The top-right area (labeled File Handling) shows three messages that seq understands for saving and loading files; in this case, the message is our friend. Clicking on the message will open a Save dialog that allows us to store the sequence to disk. Click on the message, and save your newly recorded sequence to disk.
Reading the file from disk can take two forms: we can explicitly choose a file to read, or open a dialog to select from any MIDI file stored on disk. Explicit selection is done using a file name argument to themessage. Sending the message without an argument will provide an Open dialog for selecting any available MIDI file. Click on the message to load our test sequence file; to prove that we have changed the current sequence, play it using the message. Click on the no-argument message and select your saved sequence. Clicking the message should play back our sequence as we performed it earlier.
In the previous tutorial, we saw that the right outlet of seq produces a message when a sequence is done with playback. Using this information, we can perform a common sequencing task: looping playback of our sequence. The bottom-right area (labeled Loop Playback) shows a gswitch2 (Graphical Gate) that will route the message back to the message whenever the toggle object is checked. This is a simple use of the right-hand output for sequencer control; it could also be used for loading another sequence, starting a second seq object or even starting another process in Max entirely.
Recording a raw MIDI stream is one of the strengths of the seq object; it can grab and store almost any type of MIDI message. Using the read and write commands, we can save and then restore any recorded MIDI data, whether received from a MIDI controller or generated from Max. We can also use the right outlet of seq to control playback parameters or even start completely new Max processes. The seq object should be seen as a robust, useful tool for many sequencing tasks.
|seq||Sequencer for recording and playing MIDI data|
|midiflush||Send MIDI note-offs for hanging note-ons|