MidiFile is a multiconnector module that lets you record and play back standard midifiles. (Both Format0 — single-track — and Format1 — multi-track — midifiles can be played, but it will only record in Format0. Format1 has no particular advantage for playback, but a Sequencer app will normally separate the channels in a Format0 file into their own tracks for editing, and save as Format1.)
During playback, System Exclusive sequences, Tempo-change events, and other 'Meta-events' found in a midifile are transmitted, as special format packets, along with the normal events in the MIDI stream. (Except for System Exclusive, these never correspond to any events in the MIDI stream itself — they only appear in a midifile.) Conversely, when recording, any such packets arriving will be stored in the file generated. (Be aware that System Exclusive and Meta-events are typically only passed along the 'main' path from the source element. They will not be diverted by a Splitter or appear in the sorted output of a TimeSort, etc.)
Each event in a midifile was assigned to a "track" when the file was created. (A Format0 file only has a "Track 0".) This information may be attached to the events as they are output. By default, only Meta-events have this (mainly because the Karaoke module needs it to know which text events are lyrics). An option checkbox at the bottom of the control panel can be set to add the track number to MIDI events as well; MidiMon will then show it, but no other module uses the information right now. MidiFile itself does not record the track from an incoming stream.
As well as an input connector for MIDI recording ('Record Midi'), it has a 'Control' connector that lets you trigger recording and playback from other events. It has three output connectors: a playback connection ('Play Midi'), and two feed-throughs of the inputs.
You can play a sequence that you have either loaded as a midifile from disc or recorded from live input. A sequence can only be recorded as a single continuous block: you can't add to a previously recorded one or pause a recording, although you can pause and resume playback. You can trigger the start of both recording and playback, either from events on the MIDI input connection, or from events on the control connection
Its control panel has the obvious 'PLAY', 'STOP', 'RECORD', and 'Rewind' buttons, as well as 'Load...' and 'Save...'. They all behave much as you would expect, but will be described in more detail below. Note, though, that the first three are "touch buttons", that activate when pressed, rather than when released as most screen buttons do, which should make precise synchronization easier.
At the top of the panel is a box that will display the loaded file, if any. Below this are buttons for "Load", "Rewind", and "Save". In the centre of the panel there is a 'song-position indicator' that shows where you are in the song during playback. Immediately below this are two text fields, the left showing the current status of the element, and one on the right displaying the length in seconds of the song currently in memory. Next down are the "PLAY", "STOP", and "RECORD" buttons.
Below these buttons are two popup menus: the left sets the playback mode, the right the recording. Below these are some fields that let you specify the exact event at which playback will start and will display the current and last event number in the file; the displays only appear when relevant.
The effect of clicking the 'RECORD' button depends on the setting of the menu below it. By default, recording is OFF, and the button is inoperative. In either of the 'Trig' modes, clicking 'RECORD' primes the element to start recording on the next appropriate event arrival. In 'Immediate' mode, recording begins on the button press. "Time zero" of the recorded sequence is always at the moment actual recording begins. Except when Record is OFF, clicking the 'RECORD' button clears any stored sequence immediately, ready to receive incoming events (status indicator shows "READY REC." if in a 'Trig' mode.)
The difference between the two 'Trig' modes is the input connector they monitor. If you simply want recording to start with the first MIDI (or Meta-) event to arrive, use 'Trig on MIDI'. If you want to be more selective and provide a specific trigger event, use 'Trig on Control', and send the desired trigger to the 'Control' connector.
Recording continues until you press 'STOP' (or one of the other buttons). Note that the actual end of the sequence is not the moment that you clicked STOP, but rather the last MIDI event preceding that click: you don't have to worry about being precise. When you stop recording, the sequence is ready for immediate playback. (Status will show 'AT START'.)
If there are events in the store pressing 'PLAY' will start playback. There is a mode-selection popup menu immediately below the button, but this doesn't affect the action of the button itself. If the mode is 'Manual' (the default), only the button will initiate playing. You can, however, instead select 'Play on MIDI', in which case any MIDI event arriving on the MIDI connector ('Record Midi') will start playback — provided it is not already playing —; or you can select 'Play on Control', which will start playback if any event arrives on the 'Control' input.
The final 'Play on Load' option will start playing the file as soon as it is loaded. (If you're using this mode, and the Synth module for playback, you should ensure that the 'STATE' section for the Synth in the configuration file is placed before the MidiFile element's STATE. In this way the soundfont specified for the synth gets loaded before proceeding to play the file. Otherwise the first note or two of the file may get lost. Any text editor can be used to fix the configuration file.)
Pressing 'STOP' during playback pauses it at the current song position; it will resume when you press 'PLAY' again. [It does not resume on either MIDI or Control events, when one of these modes is active; they only function when the sequence is at its start. Rewind is automatic when playback completes.
Clicking the 'STOP' button during playback, pauses it exactly at that point, meaning that notes that were playing at that point will remain playing... You can shut everything up by pressing 'STOP' a second time: this sends "all sounds off" signals to all channels, and should result in blessed silence. However, it only turns the notes off — it doesn't reset anything else, so you can pretty much still resume playing if you wish to. (In particular it doesn't reset Controllers like the sustain pedal, so if you go straight on to do something else you may get strange effects.) If you want to ensure controllers are reset as well. click STOP a third time in succession.
'Rewind' obviously sets the sequence back to the start. It only functions if playback is stopped.
The 'Start Event' entry field below the popup menus lets you enter the event number at which you want playback to start. (Direct entry seems preferable to a slider here to give precise control.) Any entered value will not take effect until <Enter> is typed in the field or 'Rewind' is clicked (or when rewind is automatic at the end of playback).
To guide you in entering this number there are two displays immediately below (only appearing when appropriate). On the right, in parantheses, is shown the number of the final event in the file. To its left the current event in the playback is listed, whenever the file is not at the start.
The 'Save...' button brings up a save-file requester so that you can preserve a sequence that you have recorded. It is saved as a standard format midifile, playable by almost any MIDI sequencer or other application on any platform. It will only write single-track files ("Format 0" — all channels and events are merged into a single track), though it loads multitrack ones as well.
'Load...' similarly brings up a requester to load in any standard midifile (either previously recorded or acquired elsewhere).
The two file requesters will independently remember where they were in any saved configuration. The path of the file currently in the element is also saved.