resonance 1.0.1
Loading...
Searching...
No Matches
levelconverter.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "game/harmony.h"
6#include "mid/receiver.h"
7#include "mid/tick.h"
8#include "os/hxstr.h"
9
10class Application;
11class LevelBuilder;
12class Riff;
13
37
71 // GrooveWorld::FinishLoad() at 0x00194d00 sets mIgnoreQuantization on its local converter
72 // directly.
73 friend class GrooveWorld;
74
75public:
82 struct PendingEvent {
83 unsigned char mNote;
84 unsigned char mVelocity;
85 int mTick;
86 };
87
100
106
112
129 void Convert(const char *pszPath, void *pBuffer, int nLength, LevelBuilder *pBuilder);
130
141 virtual void NewTrack(unsigned char nTrack);
142
156 virtual void
157 NoteOn(int nTick, unsigned char nNote, unsigned char nVelocity, unsigned char nChannel);
158
172 virtual void NoteOff(int nTick, unsigned char nNote, unsigned char nChannel);
173
190 virtual void
191 Controller(int nTick, unsigned char nController, unsigned char nValue, unsigned char nChannel);
192
205 virtual void ProgramChange(int nTick, unsigned char nProgram, unsigned char nChannel);
206
219 virtual void
220 PitchBend(int nTick, unsigned char nLow, unsigned char nHigh, unsigned char nChannel);
221
232 virtual void Tempo(int nTick, int nMicrosecondsPerQuarter);
233
247 virtual void TextEvent(int nTick, const char *pText, unsigned char nType);
248
260 virtual void EndTrack();
261
262private:
277 void ParseTrackTypeString(const char *pText);
278
294 void ApplyTrackType();
295
314 void AddNote(int nTick,
315 unsigned char nNote,
316 unsigned char nVelocity,
317 int nDuration,
318 unsigned char nChannel);
319
334 void AddGemSpan(int nTick, unsigned char nNote, int nDuration);
335
347 int CheckRiffPosition(int nTick);
348
359 void NextRiff();
360
372 void EmitRiffProgram(int nTick);
373
384 void SyncRiff(int nTick);
385
398 void CheckChannel(unsigned char nChannel, int nTick);
399
411 void AddHarmonyNote(int nTick, unsigned char nNote);
412
423 void FinishErrorLog();
424
439 void ReportError(int nTick, const char *pszMessage);
440
442 static constexpr int kDifficultyCount = 3;
443
444 HxStr mPath; // +0x04, assigned from Convert's path argument
445 // A LevelConverterTrackType, set by ParseTrackTypeString().
446 int mTrackType; // +0x0c
447 int mTrack; // +0x10, the track index, set to -1 by Convert
448 unsigned char mChannel; // +0x14, the MIDI channel events are sent on, 0xff at track start
449 HxStr mTrackName; // +0x18, the name ReportError() writes
450 int mInstrument; // +0x20
451 HxStr mDisplayName; // +0x24, the name LevelBuilder::SetInstrument() receives
452 int mScoreTrack; // +0x2c, the score track a named track writes to
453 int mBackingTrackCount; // +0x30, cleared by Convert
454 int mIntroTrackCount; // +0x34, cleared by Convert
455 int mUnusedTrackCount; // +0x38, cleared by Convert with the two counts above, never read
456 // Set, a note on waits in mPending for its note off and the pair goes to AddNote().
457 int mPairNotes; // +0x3c
458 // Set, a track's events go into the current riff. Clear, they go to the builder.
459 int mRiffTrack; // +0x40
460 int mHarmonyTrack; // +0x44
461 int mGemSpanTrack; // +0x48
462 int mGhostGems; // +0x4c, a ghost track whose third-difficulty gems go to the builder
463 LevelBuilder *mBuilder; // +0x50
464 Riff *mRiff; // +0x54
465 int mRiffIndex; // +0x58, the current riff's index in its riff set
466 // The position riff events are rebased against. -1 at the start of each track.
467 Sch::Tick mRiffStart; // +0x5c
468 Sch::Tick mRiffSetStart; // +0x60
469 unsigned char mProgram; // +0x64, the withheld program number, 0xff at track start
470 int mProgramSent; // +0x68
471 int mRiffOpened; // +0x6c, set when a riff opens
472 std::vector<PendingEvent> mPending; // +0x70
473 // The harmony the converter builds note by note through Harmony::AddPitch() (0x001e7b90) and
474 // hands to LevelBuilder::AddHarmony() (0x001e6a60, 0x001e7b04). The constructor, NewTrack(),
475 // and 0x001e7ac0 call its implicit default constructor, emitted at 0x001ea1e8.
476 Harmony mHarmony; // +0x7c
477 Sch::Tick mHarmonyStart; // +0x88, the position mHarmony starts at, -1 before the first note
478 int mHasTempo; // +0x8c, cleared by Convert and set to 1 by Tempo
479 int mIgnoreQuantization; // +0x90
480 // The gem difficulty, from configuration code 0x38a on a catch track.
481 int mDifficulty; // +0x94
482 std::vector<Span> mSpans[kDifficultyCount]; // +0x98
483 std::vector<Span>::iterator mNextSpan; // +0xbc
484 // Set by Convert from configuration code 0x3a4, and to zero when code 0x3a1 reports non-zero.
485 int mBankSelect; // +0xc0
486 int mLastBankBar; // +0xc4, set to -1 by NewTrack
487 // Set by Convert from Globals::GetPlayMode() (0x00118dd8).
488 int mPlayMode; // +0xc8
489};
The FreQuency application.
Definition application.h:23
The notes of one harmony a track plays from one song position onward.
Definition harmony.h:24
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Accumulator a MIDI conversion fills, and the one implementation of LevelData.
Definition levelbuilder.h:51
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 ProgramChange(int nTick, unsigned char nProgram, unsigned char nChannel)
Receive a program change and forward it under MIDI status 0xc0.
virtual ~LevelConverter()
virtual void NoteOff(int nTick, unsigned char nNote, unsigned char nChannel)
Receive a note off and forward it under MIDI status 0x80.
virtual void EndTrack()
Finish the track NewTrack() began.
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.
friend class GrooveWorld
Definition levelconverter.h:73
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 TextEvent(int nTick, const char *pText, unsigned char nType)
Parse a track name, and ignore every other text event.
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 Tempo(int nTick, int nMicrosecondsPerQuarter)
Hand a tempo meta event to the builder and record that the file has a tempo.
Sink a Standard MIDI File reader delivers one event at a time to.
Definition receiver.h:27
One riff of a track at one difficulty level, as a sequence of MIDI messages.
Definition riff.h:25
Song position in MIDI ticks, printed as measure, beat, and tick.
Definition tick.h:70
LevelConverterTrackType
Kind of a MIDI track, as LevelConverter's track-name parser reports it.
Definition levelconverter.h:21
@ kTrackTypePitch
Definition levelconverter.h:25
@ kTrackTypeData
Definition levelconverter.h:28
@ kTrackTypeCatch
Definition levelconverter.h:30
@ kTrackTypeHarmony
Definition levelconverter.h:29
@ kTrackTypeInstrument
Definition levelconverter.h:34
@ kTrackTypeScratch
Definition levelconverter.h:26
@ kTrackTypeVocal
Definition levelconverter.h:27
@ kTrackTypeUnknown
Definition levelconverter.h:22
@ kTrackTypeControl
Definition levelconverter.h:33
@ kTrackTypeTempo
Definition levelconverter.h:23
@ kTrackTypeGhost
Definition levelconverter.h:35
@ kTrackTypeAxe
Definition levelconverter.h:24
@ kTrackTypeBackground
Definition levelconverter.h:31
@ kTrackTypeIntro
Definition levelconverter.h:32
One note on waiting for its note off.
Definition levelconverter.h:82
unsigned char mNote
Definition levelconverter.h:83
int mTick
Definition levelconverter.h:85
unsigned char mVelocity
Definition levelconverter.h:84
One gem of a gem track, as the three span collections store it.
Definition levelconverter.h:95
Sch::Tick mLength
Definition levelconverter.h:98
int mGem
Definition levelconverter.h:97
Sch::Tick mStart
Definition levelconverter.h:96