resonance 1.0.1
Loading...
Searching...
No Matches
trackdata.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <iostream>
5#include <vector>
6
7#include "mid/tick.h"
8#include "mid/tickobj.h"
9#include "os/hxstr.h"
10#include "os/mem.h"
11
12class Gamer;
13class MuseMsg;
14class PhraseDatabase;
15class PlayMap;
16class Player;
17class Riff;
18class Harmony;
19class RiffSet;
20
29
52class TrackData {
53 // Catcher::FindNextGemTick() at 0x001aca48 reads mGemSearchBars directly.
54 friend class Catcher;
55 // LevelBuilder::SetInstrument() at 0x001ec5d0 assigns mName directly.
56 friend class LevelBuilder;
57
58public:
68 void *operator new(size_t nSize) {
69 return AllocateTaggedMemory(nSize, "TrackData");
70 }
71
79 void operator delete(void *pBlock) {
80 OperatorDeleteOverride(pBlock, "TrackData");
81 }
82
90 class Bar {
91 public:
98 Bar();
99
107
115 void Print(std::ostream &stream);
116
117 int mQuant;
120 std::vector<TickObj<Harmony *> > mHarmonies;
121 std::vector<TickObj<RiffSet *> > mRiffSets;
122 std::vector<TickObj<MuseMsg *> > mMidi;
123 std::vector<TickObj<int> > mGems;
124 };
125
134 TrackData(int nIndex, PlayMap *pMap);
135
145
158 void AddRiff(int nTick, Riff *pRiff);
159
171 void AddHarmony(int nTick, const Harmony &harmony);
172
184 void AddGem(int nTick, int nGem, Riff *pRiff);
185
199 void AddMidiMsg(int nTick, unsigned char nStatus, unsigned char nData1, unsigned char nData2);
200
214 void AddNoteMsg(int nTick,
215 unsigned char nNote,
216 unsigned char nVelocity,
217 int nLength,
218 unsigned char nChannel);
219
229 void ScoreBars();
230
242 int FindGemAtOrBefore(int nTick, int *pTick, int *pGem) const;
243
254 int FindGemAtOrAfter(int nTick, int *pTick, int *pGem) const;
255
263 void Print(std::ostream &stream);
264
274 void Locate(int nTick, Bar *&pBar, Sch::Tick &offset);
275
285 void LocateMapped(int nTick, const Bar *&pBar, Sch::Tick &offset) const;
286
296 void AddPhrases(PhraseDatabase *pDatabase);
297
308 void SetQuant(int nTick, int nQuant);
309
320 void SetActive(int nTick, int bActive);
321
330 void SetOwner(Player *pPlayer, int nBar) const;
331
338 Harmony *GetHarmony(int nTick) const;
339
347 Riff *GetRiff(int nTick, int nLevel) const;
348
357 Riff *GetRiffInMappedBar(int nBar, int nOffset, int nLevel) const;
358
367 Riff *GetRiffInBar(int nBar, int nOffset, int nLevel) const;
368
375 int GetGemAt(int nTick) const;
376
383 int GetQuant(int nBar) const;
384
391 int IsStepStart(int nBar) const;
392
399 int StepStartBar(int nBar) const;
400
407 int NextStepBar(int nBar) const;
408
415 int FollowingStepBar(int nBar) const;
416
425 int QueryBar(int nBar) const;
426
433 int GetPoints(int nBar) const;
434
441 int GetJuice(int nBar) const;
442
449 const std::vector<TickObj<MuseMsg *> > *GetMidiInBar(int nBar) const;
450
457 const std::vector<TickObj<int> > *GetGemsInBar(int nBar) const;
458
465 const std::vector<TickObj<MuseMsg *> > *GetMidi(int nBar) const;
466
473 const std::vector<TickObj<int> > *GetGems(int nBar) const;
474
483 void Locate(int nTick, Bar *&pBar);
484
493 void LocateMapped(int nTick, const Bar *&pBar) const;
494
503 void GetBar(int nBar, const Bar *&pBar) const;
504
511 int FindStepIndex(int nBar) const;
512
514 int mIndex;
515 unsigned char mChannel;
516 unsigned char mPaddingByte;
517 unsigned short mPaddingHalf;
518 int mKind;
519
527
528private:
538 static int ScoreGems(const std::vector<TickObj<int> > &gems);
539
546 static void InitScoreTables();
547
548 HxStr mName; // +0x14
549 PlayMap *mMap; // +0x1c
550 std::vector<Bar> mBars; // +0x20
551 int mBarLength; // +0x2c, 1920 ticks
552 int mGemSearchBars; // +0x30, the bars FindGemAtOrAfter() searches, 4
553 RiffSet *mCurrentRiffSet; // +0x34
554 int mCurrentRiffTick; // +0x38, starts at -1
555 std::vector<RiffSet *> mRiffSetsOwned; // +0x3c
556 std::vector<Harmony *> mHarmoniesOwned; // +0x48
557};
One participant's view of a session, driven by messages.
Definition gamer.h:47
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
Abstract base shared by a family of messages.
Definition musemsg.h:28
Store of one phrase per step of a play map, and one jam effect mask per step.
Definition phrasedatabase.h:29
Traversal order over one playable sequence.
Definition playmap.h:47
One participant in a session, local or remote.
Definition player.h:39
The riffs of one phrase, one per difficulty level.
Definition riffset.h:23
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
One bar of a track, with its scoring values and the sorted lists of what starts in it.
Definition trackdata.h:90
std::vector< TickObj< int > > mGems
Definition trackdata.h:123
void Print(std::ostream &stream)
Write every member Print() labels to a diagnostic stream.
int mCatchPoints
Definition trackdata.h:119
~Bar()
Delete every MIDI message the bar holds and free the four lists.
std::vector< TickObj< RiffSet * > > mRiffSets
Definition trackdata.h:121
int mQuant
Definition trackdata.h:117
std::vector< TickObj< Harmony * > > mHarmonies
Definition trackdata.h:120
Bar()
Construct an empty bar quantised to 120 ticks.
std::vector< TickObj< MuseMsg * > > mMidi
Definition trackdata.h:122
int mPoints
Definition trackdata.h:118
TrackData(int nIndex, PlayMap *pMap)
Construct an empty track over a play map.
void LocateMapped(int nTick, const Bar *&pBar, Sch::Tick &offset) const
Split a song position into its bar, mapped through PlayMap::MapBar(), and the offset.
void SetOwner(Player *pPlayer, int nBar) const
Report a player for a bar to the gamer, with this track's index.
friend class LevelBuilder
Definition trackdata.h:56
const std::vector< TickObj< int > > * GetGemsInBar(int nBar) const
int FindGemAtOrBefore(int nTick, int *pTick, int *pGem) const
Find the last gem at or before a song position, looking back into the previous bar when the position'...
void AddRiff(int nTick, Riff *pRiff)
Give a riff a place in the riff set at a song position.
int FollowingStepBar(int nBar) const
~TrackData()
Delete every riff set and harmony the track created, then the bars.
Riff * GetRiffInMappedBar(int nBar, int nOffset, int nLevel) const
void SetActive(int nTick, int bActive)
Do nothing.
void AddHarmony(int nTick, const Harmony &harmony)
Start a harmony at a song position.
int GetPoints(int nBar) const
unsigned char mChannel
Definition trackdata.h:515
int mKind
Definition trackdata.h:518
void Locate(int nTick, Bar *&pBar)
Find the bar of a song position, discarding the offset.
int NextStepBar(int nBar) const
Harmony * GetHarmony(int nTick) const
int FindStepIndex(int nBar) const
void SetQuant(int nTick, int nQuant)
Set the quantisation of the bar at a song position.
Riff * GetRiffInBar(int nBar, int nOffset, int nLevel) const
unsigned short mPaddingHalf
Definition trackdata.h:517
int IsStepStart(int nBar) const
void Locate(int nTick, Bar *&pBar, Sch::Tick &offset)
Split a song position into its bar and the offset within the bar.
int StepStartBar(int nBar) const
const std::vector< TickObj< MuseMsg * > > * GetMidi(int nBar) const
int GetQuant(int nBar) const
void Print(std::ostream &stream)
Write the track and every bar to a diagnostic stream.
void AddNoteMsg(int nTick, unsigned char nNote, unsigned char nVelocity, int nLength, unsigned char nChannel)
Add a NoteMsg built from four values to the bar at a song position.
void AddMidiMsg(int nTick, unsigned char nStatus, unsigned char nData1, unsigned char nData2)
Add a StdMidiMsg built from three bytes to the bar at a song position.
Gamer * mGamer
Definition trackdata.h:513
int GetGemAt(int nTick) const
int QueryBar(int nBar) const
Ask the gamer about a bar, with this track's index.
void AddGem(int nTick, int nGem, Riff *pRiff)
Add a gem at a song position, with a riff set of its own when a riff is given.
int mIndex
Definition trackdata.h:514
unsigned char mPaddingByte
Definition trackdata.h:516
const std::vector< TickObj< MuseMsg * > > * GetMidiInBar(int nBar) const
int mInstrument
Instrument index from 0 to 5.
Definition trackdata.h:526
void ScoreBars()
Give every bar its point value and its configured word.
int FindGemAtOrAfter(int nTick, int *pTick, int *pGem) const
Find the first gem at or after a song position within mGemSearchBars bars.
int GetJuice(int nBar) const
Riff * GetRiff(int nTick, int nLevel) const
const std::vector< TickObj< int > > * GetGems(int nBar) const
void LocateMapped(int nTick, const Bar *&pBar) const
Find the mapped bar of a song position, discarding the offset.
void AddPhrases(PhraseDatabase *pDatabase)
Add every gem of every phrase of a database, one phrase per step, and score each bar.
friend class Catcher
Definition trackdata.h:54
void GetBar(int nBar, const Bar *&pBar) const
Find a bar by its bar number, mapped through PlayMap::MapBar().
void OperatorDeleteOverride(void *pBlock, const char *pszClass)
Release a block that AllocateTaggedMemory() handed out.
void * AllocateTaggedMemory(size_t nSize, const char *pszClass)
Allocate a block for one object of a named class.
One value at one song position.
Definition tickobj.h:20
TrackMode
The play modes of a track, as TrackData::Print() writes them.
Definition trackdata.h:22
@ kTrackModeRiff
Definition trackdata.h:24
@ kTrackModeAxe
Definition trackdata.h:23
@ kTrackModeVocal
Definition trackdata.h:26
@ kTrackModeScratch
Definition trackdata.h:25
@ kTrackModeCatch
Definition trackdata.h:27