wavelength 1.0.0
Loading...
Searching...
No Matches
LevelMidiBuilder Class Reference

Reader of the MIDI file of a song, which builds the data of every track it names. More...

#include <levelmidibuilder.h>

Classes

class  BuilderReceiver
 MidiReceiver that passes the events of the MIDI file to the builder. More...

Public Types

enum  TrackKind {
  kTrackKindNone = 0 , kTrackKindConductor = 1 , kTrackKindAxeContour = 2 , kTrackKindAxeHarmony = 3 ,
  kTrackKindPitch = 4 , kTrackKindVox = 5 , kTrackKindScratch = 6 , kTrackKindCatch = 7 ,
  kTrackKindBackground = 8 , kTrackKindIntro = 9 , kTrackKindWorld = 10 , kTrackKindScript = 11 ,
  kTrackKindBank = 12 , kTrackKindIgnore = 13
}
 Kinds of a MIDI track, as its name identifies them. More...

Public Member Functions

 LevelMidiBuilder (const char *pszMidiFile, int nDifficulty, int nRuleSet, int nNumBars, int nIntroBars, int nFreestyleEffectsBus, int nRemixEffectsBus, SectionBoundaries *pSections, float *pMsPerTick, SlotGrid *pSlotGrid)
 Construct a builder for the MIDI file of a song.
 ~LevelMidiBuilder ()
 Release the builder, the file, and the data of every track.
void StartLoad ()
 Start reading the MIDI file without checking it for authoring errors.
void StartLoad (TrackBuilder::ErrorHandler pfnError)
 Start reading the MIDI file and check it for authoring errors.
void Poll ()
 Advance the read of the MIDI file, parsing it for up to 15 milliseconds once it is in memory, and release the file once it is parsed.
int IsDone () const
 Report whether the MIDI file is parsed.
void OnNewTrack (unsigned char nTrack)
 Start a track.
void OnEndTrack ()
 Finish the track, and make the lyrics after the conductor track.
void OnAllDone ()
 Report a song without a WORLD track or a BANK track.
void OnMidi (int nTick, unsigned char nStatus, unsigned char nData1, unsigned char nData2)
 Pass a channel message to the builder of the track.
void OnTempo (int nTick, int nMicrosecondsPerBeat)
 Pass a tempo change to the builder of the track.
void OnTimeSignature (int nTick, int nNumerator, int nDenominator)
 Pass a time signature to the builder of the track.
void OnText (int nTick, const char *pszText, unsigned char nType)
 Take the name of a track that has none yet, and build its builder.
void LoadRemix ()
 Replace the data of the tracks with the saved remix of the game database.
int GetNumTracks () const
 Report the number of instrument tracks.
int GetTrackType (int nTrack) const
 Report the type of an instrument track.
int GetTrackInstrument (int nTrack) const
 Report the instrument of a track.
CatchTrackData * GetCatchTrackData (int nTrack) const
 Report the gems of a catch track.
ScratchTrackData * GetScratchData (int nTrack) const
 Report the patterns of a turntable track.
AxeTrackData * GetAxeData (int nTrack) const
 Report the notes of a guitar track.
PitchTrackRiffData * GetTrackRiffData (int nTrack) const
 Report the riffs of a pitch track.
CatchTrackData * GetVoxData (int nTrack) const
 Report the gems of a vocal track.
int GetTrackFlags (int nTrack) const
 Report the flags of a track.
int GetNumBackMusic () const
 Report the number of background music tracks.
BackMusic * GetBackMusic (int nIndex) const
 Report one background music track.
int GetNumIntroMuses () const
 Report the number of performances of the tracks named "INTRO".
Muse * GetIntroMuse (int nIndex) const
 Report the performance of one track named "INTRO".
ScriptTrackData * FindScriptTrack (const char *pszName) const
 Find the commands of a track named "SCRIPT" by their name.
int GetTicksPerBar () const
PlayMap * GetPlayMap () const
BankLoader * GetBankTrack () const
WorldTrack * GetWorldTrack ()
Lyric * GetLyric () const
FXMgr * GetFXMgr () const
float GetSpeed () const

Static Public Member Functions

static String FormatError (const String &prefix, int nTick, int nTrack, const String &message)
 Format an error message with the MIDI track and the position it concerns.

Detailed Description

Reader of the MIDI file of a song, which builds the data of every track it names.

The class is not polymorphic. The name comes from the RTTI of its nested classes BuilderReceiver and Tracks. The object is 0x10c bytes. Each MIDI track names its kind in its name event, and the builder hands its events to a TrackBuilder for the kind. Track 0 is the conductor track. A game track name looks like T1 CATCH:D:Drums, with the number of the instrument track, its type, the instrument letter, and a label.

Member Enumeration Documentation

◆ TrackKind

Kinds of a MIDI track, as its name identifies them.

Enumerator
kTrackKindNone 

The name was not recognised.

kTrackKindConductor 

Track 0, with the tempo and the time signature.

kTrackKindAxeContour 

AXE_CONTOUR, the notes of a guitar track.

kTrackKindAxeHarmony 

AXE_HARMONY, the harmony of the guitar track before.

kTrackKindPitch 

PITCH, the riffs of a pitch track.

kTrackKindVox 

VOX, the gems of a vocal track.

kTrackKindScratch 

SCRATCH1 to SCRATCH3, the patterns of a turntable.

kTrackKindCatch 

CATCH, the gems of a catch track.

kTrackKindBackground 

A name starting BG, background music.

kTrackKindIntro 

A name starting INTRO, music before the song.

kTrackKindWorld 

WORLD, the events of the world.

kTrackKindScript 

A name starting SCRIPT, the commands of a tutorial.

kTrackKindBank 

A name starting BANK, the sound banks of the song.

kTrackKindIgnore 

A name starting IGNORE, not read.

Constructor & Destructor Documentation

◆ LevelMidiBuilder()

LevelMidiBuilder::LevelMidiBuilder ( const char * pszMidiFile,
int nDifficulty,
int nRuleSet,
int nNumBars,
int nIntroBars,
int nFreestyleEffectsBus,
int nRemixEffectsBus,
SectionBoundaries * pSections,
float * pMsPerTick,
SlotGrid * pSlotGrid )

Construct a builder for the MIDI file of a song.

Parameters
pszMidiFileThe MIDI file, which the caller retains.
nDifficultyThe difficulty, which the catch tracks build their gems for.
nRuleSetThe rule set of the game, one of GameDb::RuleSet.
nNumBarsThe length of the song in bars.
nIntroBarsThe bars before bar 0.
nFreestyleEffectsBusThe effects bus of the guitar tracks.
nRemixEffectsBusThe effects bus of a remix.
pSectionsThe sections of the song.
pMsPerTickThe duration of one tick in milliseconds.
pSlotGridThe patterns of the sections.
Ghidra address:
NTSC-U/C: 0x0011f318
Ghidra address:
PAL: 0x00120aa8

◆ ~LevelMidiBuilder()

LevelMidiBuilder::~LevelMidiBuilder ( )

Release the builder, the file, and the data of every track.

Ghidra address:
NTSC-U/C: 0x0011f4e0
Ghidra address:
PAL: 0x00120c70

Member Function Documentation

◆ StartLoad() [1/2]

void LevelMidiBuilder::StartLoad ( )

Start reading the MIDI file without checking it for authoring errors.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0011f888
Ghidra address:
PAL: 0x00121018

◆ StartLoad() [2/2]

void LevelMidiBuilder::StartLoad ( TrackBuilder::ErrorHandler pfnError)

Start reading the MIDI file and check it for authoring errors.

The name is inferred.

Parameters
pfnErrorThe routine that reports an error.
Ghidra address:
NTSC-U/C: 0x0011f8b0
Ghidra address:
PAL: 0x00121040

◆ Poll()

void LevelMidiBuilder::Poll ( )

Advance the read of the MIDI file, parsing it for up to 15 milliseconds once it is in memory, and release the file once it is parsed.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0011f9a8
Ghidra address:
PAL: 0x00121138

◆ IsDone()

int LevelMidiBuilder::IsDone ( ) const

Report whether the MIDI file is parsed.

The name is inferred.

Returns
mDone.
Ghidra address:
NTSC-U/C: 0x0011faa0
Ghidra address:
PAL: 0x00121230

◆ OnNewTrack()

void LevelMidiBuilder::OnNewTrack ( unsigned char nTrack)

Start a track.

Track 0 is the conductor track. Another track waits for its name.

Parameters
nTrackThe track.
Ghidra address:
NTSC-U/C: 0x0011faa8
Ghidra address:
PAL: 0x00121238

◆ OnEndTrack()

void LevelMidiBuilder::OnEndTrack ( )

Finish the track, and make the lyrics after the conductor track.

Ghidra address:
NTSC-U/C: 0x0011fb00
Ghidra address:
PAL: 0x00121290

◆ OnAllDone()

void LevelMidiBuilder::OnAllDone ( )

Report a song without a WORLD track or a BANK track.

Ghidra address:
NTSC-U/C: 0x0011fb98
Ghidra address:
PAL: 0x00121328

◆ OnMidi()

void LevelMidiBuilder::OnMidi ( int nTick,
unsigned char nStatus,
unsigned char nData1,
unsigned char nData2 )

Pass a channel message to the builder of the track.

Parameters
nTickThe tick of the message.
nStatusThe status byte.
nData1The first data byte.
nData2The second data byte.
Ghidra address:
NTSC-U/C: 0x0011fc28
Ghidra address:
PAL: 0x001213b8

◆ OnTempo()

void LevelMidiBuilder::OnTempo ( int nTick,
int nMicrosecondsPerBeat )

Pass a tempo change to the builder of the track.

Parameters
nTickThe tick.
nMicrosecondsPerBeatThe tempo.
Ghidra address:
NTSC-U/C: 0x0011fc68
Ghidra address:
PAL: 0x001213f8

◆ OnTimeSignature()

void LevelMidiBuilder::OnTimeSignature ( int nTick,
int nNumerator,
int nDenominator )

Pass a time signature to the builder of the track.

Parameters
nTickThe tick.
nNumeratorThe beats in a bar.
nDenominatorThe length of a beat.
Ghidra address:
NTSC-U/C: 0x0011fca0
Ghidra address:
PAL: 0x00121430

◆ OnText()

void LevelMidiBuilder::OnText ( int nTick,
const char * pszText,
unsigned char nType )

Take the name of a track that has none yet, and build its builder.

Pass every other text event to the builder of the track.

Parameters
nTickThe tick.
pszTextThe text.
nTypeThe type of the event, 3 for a track name.
Ghidra address:
NTSC-U/C: 0x0011fcd8
Ghidra address:
PAL: 0x00121468

◆ LoadRemix()

void LevelMidiBuilder::LoadRemix ( )

Replace the data of the tracks with the saved remix of the game database.

The name is inferred. The remix holds the speed, the effects, and the gems of each pitch and vocal track. A pitch track becomes a catch track of the riffs its gems pick.

Ghidra address:
NTSC-U/C: 0x00122088
Ghidra address:
PAL: 0x00123818

◆ GetNumTracks()

int LevelMidiBuilder::GetNumTracks ( ) const

Report the number of instrument tracks.

Returns
The number of tracks.
Ghidra address:
NTSC-U/C: 0x001223e0
Ghidra address:
PAL: 0x00123b60

◆ GetTrackType()

int LevelMidiBuilder::GetTrackType ( int nTrack) const

Report the type of an instrument track.

Parameters
nTrackThe track.
Returns
One of Song::TrackType.
Ghidra address:
NTSC-U/C: 0x00122400
Ghidra address:
PAL: 0x00123b80

◆ GetTrackInstrument()

int LevelMidiBuilder::GetTrackInstrument ( int nTrack) const

Report the instrument of a track.

Parameters
nTrackThe track.
Returns
The instrument.
Ghidra address:
NTSC-U/C: 0x00122458
Ghidra address:
PAL: 0x00123bd8

◆ GetCatchTrackData()

CatchTrackData * LevelMidiBuilder::GetCatchTrackData ( int nTrack) const

Report the gems of a catch track.

Parameters
nTrackThe track.
Returns
The gems, or null for another type of track.
Ghidra address:
NTSC-U/C: 0x00122470
Ghidra address:
PAL: 0x00123bf0

◆ GetScratchData()

ScratchTrackData * LevelMidiBuilder::GetScratchData ( int nTrack) const

Report the patterns of a turntable track.

Parameters
nTrackThe track.
Returns
The patterns, or null for another type of track.
Ghidra address:
NTSC-U/C: 0x00122488
Ghidra address:
PAL: 0x00123c08

◆ GetAxeData()

AxeTrackData * LevelMidiBuilder::GetAxeData ( int nTrack) const

Report the notes of a guitar track.

Parameters
nTrackThe track.
Returns
The notes, or null for another type of track.
Ghidra address:
NTSC-U/C: 0x001224a0
Ghidra address:
PAL: 0x00123c20

◆ GetTrackRiffData()

PitchTrackRiffData * LevelMidiBuilder::GetTrackRiffData ( int nTrack) const

Report the riffs of a pitch track.

Parameters
nTrackThe track.
Returns
The riffs, or null for another type of track.
Ghidra address:
NTSC-U/C: 0x001224b8
Ghidra address:
PAL: 0x00123c38

◆ GetVoxData()

CatchTrackData * LevelMidiBuilder::GetVoxData ( int nTrack) const

Report the gems of a vocal track.

Parameters
nTrackThe track.
Returns
The gems, or null for another type of track.
Ghidra address:
NTSC-U/C: 0x001224d0
Ghidra address:
PAL: 0x00123c50

◆ GetTrackFlags()

int LevelMidiBuilder::GetTrackFlags ( int nTrack) const

Report the flags of a track.

Parameters
nTrackThe track.
Returns
The flags.
Ghidra address:
NTSC-U/C: 0x001224e8
Ghidra address:
PAL: 0x00123c68

◆ GetNumBackMusic()

int LevelMidiBuilder::GetNumBackMusic ( ) const

Report the number of background music tracks.

Returns
The number of tracks.
Ghidra address:
NTSC-U/C: 0x00122500
Ghidra address:
PAL: 0x00123c80

◆ GetBackMusic()

BackMusic * LevelMidiBuilder::GetBackMusic ( int nIndex) const

Report one background music track.

Parameters
nIndexThe index.
Returns
The track.
Ghidra address:
NTSC-U/C: 0x00122518
Ghidra address:
PAL: 0x00123c98

◆ GetNumIntroMuses()

int LevelMidiBuilder::GetNumIntroMuses ( ) const

Report the number of performances of the tracks named "INTRO".

Returns
The number of performances.
Ghidra address:
NTSC-U/C: 0x00122530
Ghidra address:
PAL: 0x00123cb0

◆ GetIntroMuse()

Muse * LevelMidiBuilder::GetIntroMuse ( int nIndex) const

Report the performance of one track named "INTRO".

Parameters
nIndexThe index.
Returns
The performance.
Ghidra address:
NTSC-U/C: 0x00122548
Ghidra address:
PAL: 0x00123cc8

◆ FindScriptTrack()

ScriptTrackData * LevelMidiBuilder::FindScriptTrack ( const char * pszName) const

Find the commands of a track named "SCRIPT" by their name.

The name is inferred.

Parameters
pszNameThe name.
Returns
The commands, or null.
Ghidra address:
NTSC-U/C: 0x00122570
Ghidra address:
PAL: 0x00123cf0

◆ FormatError()

String LevelMidiBuilder::FormatError ( const String & prefix,
int nTick,
int nTrack,
const String & message )
static

Format an error message with the MIDI track and the position it concerns.

Parameters
prefixThe text the message starts with.
nTickThe tick of the error.
nTrackThe MIDI track.
messageThe error.
Returns
The message.
Ghidra address:
NTSC-U/C: 0x00121e80
Ghidra address:
PAL: 0x00123610

◆ GetTicksPerBar()

int LevelMidiBuilder::GetTicksPerBar ( ) const
inline
Returns
The length of a bar in ticks.

◆ GetPlayMap()

PlayMap * LevelMidiBuilder::GetPlayMap ( ) const
inline
Returns
The map of the song positions.

◆ GetBankTrack()

BankLoader * LevelMidiBuilder::GetBankTrack ( ) const
inline
Returns
The track named "BANK", or null.

◆ GetWorldTrack()

WorldTrack * LevelMidiBuilder::GetWorldTrack ( )
inline
Returns
The events of the track named "WORLD".

◆ GetLyric()

Lyric * LevelMidiBuilder::GetLyric ( ) const
inline
Returns
The lyrics.

◆ GetFXMgr()

FXMgr * LevelMidiBuilder::GetFXMgr ( ) const
inline
Returns
The effect sets of a remix, or null.

◆ GetSpeed()

float LevelMidiBuilder::GetSpeed ( ) const
inline
Returns
The speed of the song.

The documentation for this class was generated from the following file: