wavelength 1.0.0
Loading...
Searching...
No Matches
scratchtrack.h
Go to the documentation of this file.
1#pragma once
2
5#include "gs/muse.h"
6#include "gs/scratcher.h"
7#include "os/command.h"
8#include "os/mem.h"
9#include "os/ptr.h"
10
19public:
22
28 static void operator delete(void *pBlock) {
29 PoolMemFree(pBlock);
30 }
31
47 const SectionBoundaries *pSections,
48 PlayMap *pPlayMap,
49 const float *pfMsPerTick,
50 int nIndex,
51 int nIntroBars,
52 int nNumBars,
53 int nTicksPerBar);
54
61 ~ScratchTrack() override;
62
69 void Start() override;
70
77 void Stop() override;
78
86 void SetPlayer(Player *pPlayer) override;
87
89
98 void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override;
99
108 void HandleInput(Player *pPlayer, const StickEvent<2> &event) override;
109
118 void HandleInput(Player *pPlayer, const BtnEvent<10> &event) override;
119
127 bool IsActive() override {
128 return mActiveButton != kNoButton;
129 }
130
137 void Refresh() override;
138
139private:
140 int mTicksPerBar;
141 int mNumBars;
142 ScratchTrackData *mData;
143 Scratcher *mScratchers[kNumScratchers];
144 int mActiveButton;
145 int mLastButton;
146 float mX;
147 float mY;
148 Ptr<Command> mUpdateCommand;
149 Ptr<Command> mRetriggerCommand;
150 Ptr<Muse> mReleaseSounds[kNumScratchers];
152 static constexpr int kNoButton = -1;
153
160 void Retrigger();
161
168 void ReleaseScratch();
169
179 void StartScratch(int nButton, float fX, float fY);
180
187 void EndScratch();
188
196 void UpdateScratchers();
197
205 void PlayReleaseSound(int nButton);
206};
Input event of a button press that names only the player.
Definition btnevent.h:15
FreestyleTrack(const SectionBoundaries *pSections, PlayMap *pPlayMap, const float *pfMsPerTick, int nIndex, int nNumBars, int nTicksPerBar)
Construct a track.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Send a note the track's player played, and start or stop the scoring of the time it sounds.
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
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Owner of one reference to an Attachment.
Definition ptr.h:16
The scratchers of a scratch track, one set of three for each span of the song.
Definition scratchtrackdata.h:15
static constexpr int kSetSize
The number of scratchers in a set.
Definition scratchtrackdata.h:18
void Stop() override
Withdraw the scheduled commands and stop every scratcher.
~ScratchTrack() override
Stop the track and release it.
void SetPlayer(Player *pPlayer) override
End the active scratch, then assign the player.
void Start() override
Select the scratchers of the set at the song position.
void HandleInput(Player *pPlayer, const StickEvent< 2 > &event) override
Move the active scratcher with a stick position of the track's player.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Start or end a scratch of the track's player.
bool IsActive() override
Report whether a scratch is active.
Definition scratchtrack.h:127
static constexpr int kNumScratchers
The number of scratchers in a set, one for each gem button.
Definition scratchtrack.h:21
void Refresh() override
Withdraw the scheduled update and select the scratchers of the set at the song position.
ScratchTrack(ScratchTrackData *pData, const SectionBoundaries *pSections, PlayMap *pPlayMap, const float *pfMsPerTick, int nIndex, int nIntroBars, int nNumBars, int nTicksPerBar)
Construct a track and its release sounds.
void HandleInput(Player *pPlayer, const BtnEvent< 10 > &event) override
Release the scratch of the track's player and play the release sound.
Player of the three recorded pieces one scratch button plays.
Definition scratcher.h:20
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Input event of an analog stick position.
Definition stickevent.h:15
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.