resonance 1.0.1
Loading...
Searching...
No Matches
phrase.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <iostream>
5#include <vector>
6
7#include "app/attachment.h"
8#include "mid/tick.h"
9#include "mid/tickobj.h"
10
11class IBStream;
12class MultiMuse;
13class MuseMsg;
14class OBStream;
15class Player;
16
38class Phrase : public Attachment {
39 friend class AxeOldGemMaker;
40 friend class AxePhraseMaker;
41 friend class PhraseDatabase;
42 friend class PhraseMgr;
43 friend class PhrasePlayer;
44 friend class TrackData;
45 friend class Voxer;
46
47public:
63 class Gem {
64 public:
71 bool operator<(const Gem &other) const {
72 return mPosition.mTick < other.mPosition.mTick;
73 }
74
83 bool operator==(const Gem &other) const {
84 return mPosition.mTick == other.mPosition.mTick && mGem == other.mGem &&
85 mTrans == other.mTrans;
86 }
87
89 int mGem;
90 int mTrans;
91 };
92
101 void *operator new(size_t nSize);
102
110 void operator delete(void *pBlock);
111
119
126 virtual ~Phrase();
127
141 int AddGem(int nTick, int nGem, int nTrans);
142
151 void AddMuseMsg(int nTick, MuseMsg *pMsg);
152
160 void Print(std::ostream &stream);
161
169 void Save(OBStream &stream);
170
182 void Load(IBStream &stream);
183
192 void AddXLocal(int nTick, float flValue);
193
202 float GetValue(int nTick);
203
204private:
212 void SaveValues(OBStream &stream);
213
223 void LoadValues(IBStream &stream);
224
225 std::vector<Gem> mGems; // +0x08, labelled `gems: `
226 Player *mPlayer; // +0x14, labelled `pl: `
227 MultiMuse *mMuse; // +0x18, created on first use
228 std::vector<TickObj<float> > mValues; // +0x1c, labelled `X: `
229 char mScore; // +0x28, the points the phrase was captured for
230};
231
244
255
265std::ostream &operator<<(std::ostream &stream, Phrase::Gem &gem);
266
277
288
300OBStream &operator<<(OBStream &stream, Phrase *pPhrase);
301
311IBStream &operator>>(IBStream &stream, Phrase *&pPhrase);
312
322std::ostream &operator<<(std::ostream &stream, Phrase &phrase);
Attachment()
Definition attachment.h:26
Input half of the byte stream interface.
Definition ibstream.h:36
Sequence of messages, each at a song position.
Definition multimuse.h:30
Abstract base shared by a family of messages.
Definition musemsg.h:28
Output half of the byte stream interface.
Definition obstream.h:25
One gem of the phrase at one song position.
Definition phrase.h:63
bool operator<(const Gem &other) const
Order two gems by position.
Definition phrase.h:71
int mGem
Definition phrase.h:89
bool operator==(const Gem &other) const
Compare two gems member by member, in declaration order.
Definition phrase.h:83
int mTrans
Definition phrase.h:90
Sch::Tick mPosition
Definition phrase.h:88
One phrase of a track, with its gems, its player, and the messages and values scheduled across it.
Definition phrase.h:38
void Save(OBStream &stream)
Write the phrase behind a version byte of 2.
int AddGem(int nTick, int nGem, int nTrans)
Place a gem at a song position, replacing any gem already there.
friend class PhraseDatabase
Definition phrase.h:41
void AddXLocal(int nTick, float flValue)
Add a value at a song position, keeping the values sorted by position.
void Print(std::ostream &stream)
Write the phrase to a diagnostic stream.
friend class AxePhraseMaker
Definition phrase.h:40
void Load(IBStream &stream)
Read the phrase back.
friend class TrackData
Definition phrase.h:44
void AddMuseMsg(int nTick, MuseMsg *pMsg)
Schedule a copy of a message at a song position, creating the sequence on first use.
float GetValue(int nTick)
Report the value in force at a song position.
Phrase()
Construct an empty phrase owned by the stand-in player.
friend class AxeOldGemMaker
Definition phrase.h:39
friend class PhraseMgr
Definition phrase.h:42
friend class PhrasePlayer
Definition phrase.h:43
friend class Voxer
Definition phrase.h:45
virtual ~Phrase()
Release the message sequence, when one exists, and both vectors.
One participant in a session, local or remote.
Definition player.h:39
Song position in MIDI ticks, printed as measure, beat, and tick.
Definition tick.h:70
int mTick
The position, in MIDI ticks at 480 per quarter note.
Definition tick.h:153
IBStream & operator>>(IBStream &stream, Phrase::Gem &gem)
Read one gem back.
OBStream & operator<<(OBStream &stream, const Phrase::Gem &gem)
Write one gem as a two-byte position and two single bytes.