MidiFile Module

— MusicWeaver Update 2.3 February 2006 —


MidiFile is a multiconnector module that lets you record and play back midifiles. This version now handles midifiles entirely itself, without involving the BeOS MidiKit. Which means it does things properly [I hope... (:-)]!

Both System Exclusive sequences and Tempo-change events in a MIDI file are transmitted along with normal events in the MIDI stream, as are midifile 'Meta-events'. (None of these have any representation in the serial MIDI protocol itself — only in a midifile. Therefore special Weaver packets are used.) Similarly, when recording, any such packets arriving (from a source MidiFile element) will be stored in the file generated.

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 'RECORD', 'PLAY', 'STOP', 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.

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 "RECORD", "STOP", and "PLAY" buttons. [Unlike RePlay, these are standard 'act-on-release' buttons, rather than 'activate-on-first-touch'.] Below these buttons are two popup menus: the left sets the recording mode, the right the playback.

Recording:

When you click the 'RECORD' button, the store is cleared ready to receive incoming events (status indicator shows "READY REC.", but actual recording doesn't normally begin immediately. By default, recording begins with the first MIDI event to arrive after the button is clicked. In more detail, this means that 'time zero' of the sequence equates to the arrival of that event. You can modify this behaviour with the popup menu immediately below the 'RECORD' button. Selecting 'Immediate', sets 'time zero' to the click of the button (to be precise, the release of the button); 'Trig on Control' sets it up so that recording does not start until an event (any event) arrives on the 'Control' input.

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 the button, 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'.)

Playback:

If there are events in the store (and status is not 'AT END') 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 'Trig 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 'Trig on Control', which will start playback if any event arrives on the 'Control' input.

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. Also currently there is no "autorewind" option; this may change later.]

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 notes 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 remember that it doesn't reset things like the sustain pedal, so if you go straight on to do something else you may get strange effects.)

'Rewind' obviously sets the sequence back to the start. It only functions if playback is stopped.

Save and Load:

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 reads 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.