wavelength 1.0.0
Loading...
Searching...
No Matches
sfxbuilder.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "gs/musebuilder.h"
6#include "mid/midireceiver.h"
7
15class SFXBuilder : public MidiReceiver {
16public:
24 explicit SFXBuilder(const char *pszFile) : mFile(pszFile), mBuilder(nullptr), mTrack(0) {
25 }
26
33 ~SFXBuilder() override;
34
41 void Read();
42
50 void OnNewTrack([[maybe_unused]] unsigned char nTrack) override {
51 }
52
59 void OnEndTrack() override;
60
67 void OnAllDone() override {
68 }
69
80 void
81 OnMidi(int nTick, unsigned char nStatus, unsigned char nData1, unsigned char nData2) override;
82
91 void OnTempo(int nTick, int nMicrosecondsPerBeat) override;
92
105 void OnText(int nTick, const char *pszText, unsigned char nType) override;
106
116 void OnTimeSignature([[maybe_unused]] int nTick,
117 [[maybe_unused]] int nNumerator,
118 [[maybe_unused]] int nDenominator) override {
119 }
120
121private:
122 const char *mFile; // The MIDI file. Borrowed.
123 std::unique_ptr<MuseBuilder> mBuilder; // The builder of the current track's cue, or null.
124 int mTrack; // The number of tracks ended so far.
125};
126
132extern std::unique_ptr<float> TheSfxTickDuration;
Listener a MIDI file reader reports each track and event to.
Definition midireceiver.h:8
void OnEndTrack() override
Finish the cue of the track and count the track.
void OnMidi(int nTick, unsigned char nStatus, unsigned char nData1, unsigned char nData2) override
Pass a channel message to the builder of the track, if any.
void OnText(int nTick, const char *pszText, unsigned char nType) override
Start the builder of the cue a track name identifies, after the first track.
SFXBuilder(const char *pszFile)
Construct a builder for a file.
Definition sfxbuilder.h:24
void OnTempo(int nTick, int nMicrosecondsPerBeat) override
Set TheSfxTickDuration from the tempo, at 480 ticks a beat.
void OnAllDone() override
Ignore the end of the file.
Definition sfxbuilder.h:67
void Read()
Read the file.
~SFXBuilder() override
Destroy the builder of the current track.
void OnNewTrack(unsigned char nTrack) override
Ignore the start of a track.
Definition sfxbuilder.h:50
void OnTimeSignature(int nTick, int nNumerator, int nDenominator) override
Ignore a time signature.
Definition sfxbuilder.h:116
std::unique_ptr< float > TheSfxTickDuration
The duration of one tick of the interface sounds, which the last tempo of the file set.