|
resonance 1.0.1
|
Converter that reads a Standard MIDI File and fills a LevelBuilder from its events. More...
#include <levelconverter.h>


Classes | |
| struct | PendingEvent |
| One note on waiting for its note off. More... | |
| struct | Span |
| One gem of a gem track, as the three span collections store it. More... | |
Public Member Functions | |
| LevelConverter () | |
| virtual | ~LevelConverter () |
| void | Convert (const char *pszPath, void *pBuffer, int nLength, LevelBuilder *pBuilder) |
| Read one Standard MIDI File and fill a builder from it. | |
| virtual void | NewTrack (unsigned char nTrack) |
| Reset the per-track state and begin one track. | |
| virtual void | NoteOn (int nTick, unsigned char nNote, unsigned char nVelocity, unsigned char nChannel) |
| Receive a note on and forward it under MIDI status 0x90. | |
| virtual void | NoteOff (int nTick, unsigned char nNote, unsigned char nChannel) |
| Receive a note off and forward it under MIDI status 0x80. | |
| virtual void | Controller (int nTick, unsigned char nController, unsigned char nValue, unsigned char nChannel) |
| Receive a controller change and forward it under MIDI status 0xb0. | |
| virtual void | ProgramChange (int nTick, unsigned char nProgram, unsigned char nChannel) |
| Receive a program change and forward it under MIDI status 0xc0. | |
| virtual void | PitchBend (int nTick, unsigned char nLow, unsigned char nHigh, unsigned char nChannel) |
| Receive a pitch bend and forward it under MIDI status 0xe0. | |
| virtual void | Tempo (int nTick, int nMicrosecondsPerQuarter) |
| Hand a tempo meta event to the builder and record that the file has a tempo. | |
| virtual void | TextEvent (int nTick, const char *pText, unsigned char nType) |
| Parse a track name, and ignore every other text event. | |
| virtual void | EndTrack () |
| Finish the track NewTrack() began. | |
| Public Member Functions inherited from Mid::Receiver | |
| virtual | ~Receiver () |
| virtual void | AllDone () |
| Report that the whole file has been delivered. | |
| virtual void | UnusedFirstHook () |
| Do nothing. | |
| virtual void | UnusedSecondHook () |
| Do nothing. | |
| virtual void | UnusedThirdHook () |
| Do nothing. | |
| virtual void | UnusedFourthHook () |
| Do nothing. | |
Friends | |
| class | GrooveWorld |
Converter that reads a Standard MIDI File and fills a LevelBuilder from its events.
Its RTTI descriptor is at 0x008ef230. It has Mid::Receiver as its one base at offset 0. Its table is at 0x007e76b8 and has sixteen entries with a zero terminator at index 16, the same length as the base table. The class adds no virtual. It overrides slots 2 through 10 and inherits slots 11 through 15.
Slot 11 is worth stating separately. The derived table records 0x001ea360 where the base records 0x001ea2c0, and both are the same two instructions. This toolchain re-emits an inline empty body into every translation unit that needs one, so a unique address for an empty body is no evidence of an override. The slot is recorded as inherited and nothing is declared for it.
The object is at least 0xcc bytes, and several members are unrecovered. Every member whose purpose is undetermined retains its offset.
Convert() is the entry point. It stores the builder, extracts the file's base name into a global buffer at 0x00891a38, reads two display-configuration codes, builds three stack objects for the file, the byte stream, and the Standard MIDI File reader, hands itself to the reader as the event sink, and runs it. The three stack objects are an HxMemStream with HxStream::mSwapBytes set to 1, an HxIListChunk over the whole stream, and a Mid::Reader. The file-static comparator at 0x001e6450 is stored in Mid::Reader::mCompare before Mid::Reader::ReadAllTracks() runs. The comparator ranks each event by its status class (note off first, note on last).
The five event handlers all follow one shape. They report through ReportError() on the error paths, check the channel through CheckChannel(), and then forward to one of two sinks. With mRiffTrack clear the event goes to LevelBuilder::AddEvent(). With it set the event goes to Riff::AddMidiMsg() on mRiff instead, with the position rebased against mRiffStart and saturated to Sch::Tick's bounds.
Every method name below that is not a Mid::Receiver override is inferred from its body.
| LevelConverter::LevelConverter | ( | ) |
|
virtual |
| void LevelConverter::Convert | ( | const char * | pszPath, |
| void * | pBuffer, | ||
| int | nLength, | ||
| LevelBuilder * | pBuilder ) |
Read one Standard MIDI File and fill a builder from it.
The error log path is the file's base name with .err appended. The file is read through an HxMemStream with byte swapping on, an HxIListChunk, and a Mid::Reader whose events of one position are ordered by status class (note off first, note on last). LevelBuilder::DoneLoading() and FinishErrorLog() run after the file is read.
| pszPath | The file to read. |
| pBuffer | The file's contents, forwarded to the HxMemStream constructor. GrooveWorld::FinishLoad() passes the buffer its asynchronous read filled. |
| nLength | The length of pBuffer in bytes, forwarded to the same object. |
| pBuilder | The builder the events are appended to. |
|
virtual |
Reset the per-track state and begin one track.
The track type, the routing flags, the pending notes, the riff, the channel, the program, and the harmony all return to their unset values.
| nTrack | The track index. |
Reimplemented from Mid::Receiver.
|
virtual |
Receive a note on and forward it under MIDI status 0x90.
A harmony track adds the note to the harmony through AddHarmonyNote(). A track that pairs notes stores the note on in mPending instead of forwarding it.
| nTick | The event position, in MIDI ticks. |
| nNote | The note number. |
| nVelocity | The velocity. |
| nChannel | The channel. |
Reimplemented from Mid::Receiver.
|
virtual |
Receive a note off and forward it under MIDI status 0x80.
A harmony track ignores it. A track that pairs notes hands the first pending note on with the same note to AddNote() with the duration between the two, and reports a note off with no partner. Otherwise the forwarded call passes zero where the note-on path passes a velocity.
| nTick | The event position, in MIDI ticks. |
| nNote | The note number. |
| nChannel | The channel. |
Reimplemented from Mid::Receiver.
|
virtual |
Receive a controller change and forward it under MIDI status 0xb0.
Harmony and gem-span tracks reject it. On a riff track, controller 0x66 sets the bar quantisation (1, 2, 4, 8, or 16) unless mIgnoreQuantization is set, controller 7 (volume) is rejected, and controller 0x6a forwards whether its value is non-zero through LevelBuilder::SetActive(). Controller 0x6a is rejected on every other track, and controllers 0x68, 0x69, 0x6b, and 11 (expression) are rejected everywhere.
| nTick | The event position, in MIDI ticks. |
| nController | The controller number. |
| nValue | The value. |
| nChannel | The channel. |
Reimplemented from Mid::Receiver.
|
virtual |
Receive a program change and forward it under MIDI status 0xc0.
Harmony and gem-span tracks reject it. A riff track stores the program in mProgram and sends nothing, and EmitRiffProgram() sends it with each riff instead.
| nTick | The event position, in MIDI ticks. |
| nProgram | The program number. |
| nChannel | The channel. |
Reimplemented from Mid::Receiver.
|
virtual |
Receive a pitch bend and forward it under MIDI status 0xe0.
Harmony and gem-span tracks reject it. Otherwise it takes the shared shape.
| nTick | The event position, in MIDI ticks. |
| nLow | The low seven bits of the bend. |
| nHigh | The high seven bits of the bend. |
| nChannel | The channel. |
Reimplemented from Mid::Receiver.
|
virtual |
Hand a tempo meta event to the builder and record that the file has a tempo.
Both parameters pass through to LevelBuilder::AddTempo() in the registers they arrive in.
| nTick | The event position, in MIDI ticks. |
| nMicrosecondsPerQuarter | The tempo. |
Reimplemented from Mid::Receiver.
|
virtual |
Parse a track name, and ignore every other text event.
A type other than 3 and a position other than 0 are both ignored, and 3 is the MIDI track-name meta type. The discarded Sch::Tick::IsInRange(0) ahead of the test is the shape of an assertion compiled without its report.
| nTick | The event position, in MIDI ticks. |
| pText | The text. |
| nType | The meta type. |
Reimplemented from Mid::Receiver.
|
virtual |
Finish the track NewTrack() began.
A harmony that was started goes to the builder. A riff track that opened no riff forwards two zeroes through LevelBuilder::SetActive(). An axe riff with no length and a note on with no note off are both reported, and otherwise a riff track empties the three span collections.
Reimplemented from Mid::Receiver.
|
friend |