wavelength 1.0.0
Loading...
Searching...
No Matches
song.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/axetrackdata.h"
7#include "game/backmusic.h"
8#include "game/bankloader.h"
11#include "game/fxmgr.h"
13#include "game/lyric.h"
14#include "game/pitchtrackgems.h"
16#include "game/playmap.h"
20#include "game/slotgrid.h"
21#include "game/worldtrack.h"
22#include "gs/muse.h"
23#include "mid/trackbuilder.h"
24#include "os/file.h"
25#include "os/mem.h"
26#include "os/string.h"
27#include "script/dataarray.h"
28#include "synth/syntheffects.h"
29
38class Song {
39public:
48
56
58 static constexpr int kNumMixerChannels = 16;
59
61 static constexpr int kNumPatternFiles = 3;
62
69 public:
75 explicit PatternFile(const char *pszPath) : mPath(pszPath) {
76 }
77
80 PoolMemFree(mBuffer);
81 }
82
91 void Start(int nIndex, Song *pSong);
92
100 bool Poll();
101
102 private:
103 String mPath;
104 int mIndex;
105 Song *mSong;
106 std::unique_ptr<File> mFile;
107 char *mBuffer;
108 int mSize;
109 int mDone;
110 };
111
121 Song(DataArray *pSongConfig, int nSkillLevel, int nRuleSet);
122
130
139 void Load();
140
149 void PollLoad();
150
160 bool IsLoaded();
161
172
184
192 int GetNumTracks() const;
193
202 int GetTrackType(int nTrack) const;
203
212 int GetTrackInstrument(int nTrack) const;
213
224
234
244
253 AxeTrackData *GetAxeData(int nTrack) const;
254
264
273 CatchTrackData *GetVoxData(int nTrack) const;
274
283 int GetTrackFlags(int nTrack) const;
284
292 int GetNumBackMusic() const;
293
302 BackMusic *GetBackMusic(int nIndex) const;
303
312 int GetBackMusicMaster(int nIndex) const;
313
321 int GetNumIntroMuses() const;
322
331 Muse *GetIntroMuse(int nIndex) const;
332
341 ScriptTrackData *GetScriptTrack(const char *pszName) const;
342
351
359 float *GetMsPerTick() const;
360
369
378
387
395 Lyric *GetLyric() const;
396
404 FXMgr *GetFXMgr() const;
405
413 float GetSpeed() const;
414
423
434 std::vector<std::unique_ptr<PitchTrackGems>> *GetTrackPitchData(int nTrack);
435
443 const std::vector<std::vector<int>> &GetEnableOrder() const;
444
453 bool HasLowVolumes(int nChannel) const;
454
465 const std::vector<unsigned char> *GetLowVolumes(int nChannel) const;
466
475 bool HasTrackVolumes(int nTrack) const;
476
488 const std::vector<unsigned char> &GetTrackVolumes(int nTrack) const;
489
498
508 const std::vector<unsigned char> *GetFreestyleLowVolumes() const;
509
518
526 const char *GetRemixEffectsName() const;
527
536 const char *GetSectionLabel(int nIndex) const;
537
539 int GetDifficulty() const {
540 return mDifficulty;
541 }
542
545 return mBuilder.get();
546 }
547
549 int GetTicksPerBar() const {
550 return mBuilder->GetTicksPerBar();
551 }
552
554 int GetNumBars() const {
555 return mNumBars;
556 }
557
559 int GetIntroBars() const {
560 return mIntroBars;
561 }
562
564 const std::vector<int> &GetSkippedBars() const {
565 return mSkippedBars;
566 }
567
569 const std::vector<int> &GetDuelTrackOrder() const {
570 return mDuelTrackOrder;
571 }
572
573private:
582 void StartLoad();
583
591 void Error(const String &message);
592
602 const char *ReadSymbol(const char *pszName, DataArray *pData);
603
613 int ReadInt(const char *pszName, DataArray *pData);
614
624 float ReadFloat(const char *pszName, DataArray *pData);
625
636 DataArray *ReadArray(const char *pszName, DataArray *pData, bool bRequired);
637
644 void StartPatternLoad();
645
652 void ReadConfig();
653
660 void ReadTrackConfig();
661
669 void ReadRemixSections();
670
677 void ReadSectionStarts();
678
687 void BuildSections(DataArray *pStarts);
688
695 void ReadMixerOverrides();
696
703 void ReadDuelMixVolumes();
704
711 void ReadEffects();
712
719 void ReadEnableOrder();
720
727 void ReadBackgroundTracks();
728
735 void ReadDuelTracks();
736
743 void ReadDuelPatterns();
744
751 void ValidateEnableOrder();
752
753 int mState;
754 int mDifficulty;
755 int mRuleSet;
756 TrackBuilder::ErrorHandler mErrorHandler;
757 int mValidate;
758 int mReserved14; // +0x14, cleared by the constructor and not otherwise used here.
759 std::unique_ptr<LevelMidiBuilder> mBuilder;
760 DataArray *mConfig;
761 DuelPatternTable mDuelPatterns;
762 String mReserved30; // +0x30, emptied by the constructor and not otherwise used here.
763 int mNumBars;
764 int mIntroBars;
765 String mMidiFile;
766 String mMidiDir;
767 std::unique_ptr<SectionBoundaries> mSections;
768 std::unique_ptr<float> mMsPerTick;
769 std::unique_ptr<SlotGrid> mSlotGrid;
770 std::vector<int> mBackMusicMasters;
771 std::vector<unsigned char> mLowVolumes[kNumMixerChannels];
772 std::vector<unsigned char> mFreestyleLowVolumes;
773 std::vector<unsigned char> mTrackVolumes[kNumMixerChannels];
774 std::vector<std::vector<int>> mEnableOrder;
775 SynthEffects mEffects;
776 int mFreestyleEffectsBus;
777 int mRemixEffectsBus;
778 const char *mRemixEffectsName;
779 std::vector<String> mSectionLabels;
780 std::vector<int> mSkippedBars;
781 std::vector<std::vector<std::unique_ptr<PitchTrackGems>>> mPitchGems;
782 std::unique_ptr<PatternFile> mPatternFiles[kNumPatternFiles];
783 std::vector<int> mDuelTrackOrder;
784};
The notes and chords of a guitar track, one set of each for each span of the song.
Definition axetrackdata.h:17
Background music of a song, played alone or along with a catch track.
Definition backmusic.h:20
Loader of the sound banks of a song, from its track named "BANK".
Definition bankloader.h:19
The gems of one catch track, in the order of their ticks.
Definition catchtrackdata.h:14
Reference-counted array of script data nodes.
Definition dataarray.h:20
The duel patterns of a song, each with the tick it applies from, embedded in the song at +0x20.
Definition duelpatterntable.h:14
The effect sets a song applies to the synthesiser channels at given bars.
Definition fxmgr.h:15
Reader of the MIDI file of a song, which builds the data of every track it names.
Definition levelmidibuilder.h:36
Lyrics of a song loop, each shown when the song reaches its tick.
Definition lyric.h:18
Piece of MIDI performance that a Scheduler plays.
Definition muse.h:12
The riffs a pitch track plays, one set of riffs for each tick that starts a set.
Definition pitchtrackriffdata.h:16
Map from the bars a song plays to the bars of the song as written, with the loops that repeat stretch...
Definition playmap.h:11
The scratchers of a scratch track, one set of three for each span of the song.
Definition scratchtrackdata.h:15
The script commands of a song's SCRIPT track, each at its tick.
Definition scripttrackdata.h:14
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
The pattern each section of a remixed song repeats, as the section the pattern comes from.
Definition slotgrid.h:10
~PatternFile()
Release the file and its contents.
Definition song.h:79
bool Poll()
Report whether the file is read, and load the patterns of each pitch track once it is.
void Start(int nIndex, Song *pSong)
Open the file and start reading it into a buffer.
PatternFile(const char *pszPath)
Construct the record of a file.
Definition song.h:75
~Song()
Release the song and its tracks.
int GetDifficulty() const
Definition song.h:539
int GetIntroBars() const
Definition song.h:559
void PollLoad()
Advance the load Load() started.
const std::vector< int > & GetDuelTrackOrder() const
Definition song.h:569
int GetTrackInstrument(int nTrack) const
Report the instrument of a track.
float GetSpeed() const
Report the speed of the song.
void ApplySavedRemix()
Replace the tracks with the saved remix the game database selects.
void ApplySynthSettings()
Apply the effects buses of the song, and set controller 16 of every MIDI channel to the level of the ...
Song(DataArray *pSongConfig, int nSkillLevel, int nRuleSet)
Read the configuration of a song for a difficulty and a rule set.
BankLoader * GetBankTrack() const
Report the track named "BANK".
float * GetMsPerTick() const
Report the duration of one tick.
CatchTrackData * GetCatchTrackData(int nTrack) const
Report the gems of a catch track.
ScriptTrackData * GetScriptTrack(const char *pszName) const
Find a track named "SCRIPT" of the MIDI file by the name of its commands.
int GetNumTracks() const
Report the number of instrument tracks.
int GetTrackFlags(int nTrack) const
Report the flags of a track.
BackMusic * GetBackMusic(int nIndex) const
Report one background music track.
std::vector< std::unique_ptr< PitchTrackGems > > * GetTrackPitchData(int nTrack)
Report the gem patterns of a pitch track.
const std::vector< unsigned char > & GetTrackVolumes(int nTrack) const
Report the volumes of a track.
static constexpr int kNumMixerChannels
Number of mixer channels the song can set the low volumes of.
Definition song.h:58
const std::vector< std::vector< int > > & GetEnableOrder() const
Report the steps of the catch tracks to enable, each a list of track indices.
int GetNumBackMusic() const
Report the number of background music tracks.
int GetNumIntroMuses() const
Report the number of performances of the tracks named "INTRO".
PlayMap * GetPlayMap() const
Report the map of the song positions.
const std::vector< int > & GetSkippedBars() const
Definition song.h:564
int GetTrackType(int nTrack) const
Report the type of an instrument track.
const char * GetSectionLabel(int nIndex) const
Report the label of a remix section.
TrackType
Types of an instrument track.
Definition song.h:41
@ kTrackTypeScratch
Definition song.h:44
@ kTrackTypeVox
Definition song.h:45
@ kTrackTypeCatch
Definition song.h:46
@ kTrackTypePitch
Definition song.h:43
@ kTrackTypeAxe
Definition song.h:42
CatchTrackData * GetVoxData(int nTrack) const
Report the gems of a vocal track.
int GetTicksPerBar() const
Definition song.h:549
FXMgr * GetFXMgr() const
Report the effect sets.
SectionBoundaries * GetSections() const
Report the sections.
bool HasTrackVolumes(int nTrack) const
Report whether a track has a volume list.
ScratchTrackData * GetScratchData(int nTrack) const
Report the patterns of a turntable track.
Muse * GetIntroMuse(int nIndex) const
Report the performance of one track named "INTRO".
const char * GetRemixEffectsName() const
Report the localised name of the effects of a remix.
PitchTrackRiffData * GetTrackRiffData(int nTrack) const
Report the riffs of a track.
WorldTrack * GetWorldTrack() const
Report the events of the track named "WORLD".
AxeTrackData * GetAxeData(int nTrack) const
Report the notes of a guitar track.
const std::vector< unsigned char > * GetFreestyleLowVolumes() const
Report the low volumes of the freestyle track.
bool HasLowVolumes(int nChannel) const
Report whether the song sets the low volumes of a mixer channel.
int GetNumBars() const
Definition song.h:554
const std::vector< unsigned char > * GetLowVolumes(int nChannel) const
Report the low volumes of a mixer channel.
Lyric * GetLyric() const
Report the lyrics.
DuelPatternTable * GetDuelPatterns()
Report the duel patterns of the song.
LevelMidiBuilder * GetBuilder() const
Definition song.h:544
static constexpr int kNumPatternFiles
Number of pattern files a remix or a duel reads, and of gem patterns of a pitch track.
Definition song.h:61
LoadState
Values of mState.
Definition song.h:50
@ kLoadStatePatterns
Definition song.h:53
@ kLoadStateSetup
Definition song.h:52
@ kLoadStateParse
Definition song.h:51
@ kLoadStateDone
Definition song.h:54
bool IsLoaded()
Report whether the load Load() started is complete.
void Load()
Start loading the song without checking it for authoring errors.
int GetRemixEffectsBus() const
Report the effects bus of a remix.
SlotGrid * GetSlotGrid() const
Report the slot grid of the song.
int GetBackMusicMaster(int nIndex) const
Report the catch track a background music track plays along with.
bool HasFreestyleLowVolumes() const
Report whether the song sets the low volumes of the freestyle track.
Growable text buffer that is also a PrnStream.
Definition string.h:19
Settings of the two effect buses and the software effect of the sound output, read from an effects en...
Definition syntheffects.h:17
void(* ErrorHandler)(String &message)
Routine that reports a build error.
Definition trackbuilder.h:19
The events of the track of a song named "WORLD", sorted by tick.
Definition worldtrack.h:11
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.