wavelength 1.0.0
Loading...
Searching...
No Matches
scratcher.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "gs/muse.h"
7#include "gs/muselooper.h"
8#include "os/command.h"
9#include "os/ptr.h"
10
20class Scratcher {
21public:
23 static constexpr int kNumPieces = 3;
24
31 class ScratchNoteCB : public Muse::NoteCB {
32 public:
39 ~ScratchNoteCB() override = default;
40
49 void OnNote(unsigned char nNote, int nDuration) override;
50
52 int GetTickOffset() const {
53 return mTickOffset;
54 }
55
57 void SetTickOffset(int nTickOffset) {
58 mTickOffset = nTickOffset;
59 }
60
62 int GetPlayer() const {
63 return mPlayer;
64 }
65
67 void SetPlayer(int nPlayer) {
68 mPlayer = nPlayer;
69 }
70
71 private:
72 int mPlayer;
73 int mTickOffset;
74 };
75
90 Scratcher(Muse *pFirst,
91 Muse *pSecond,
92 Muse *pThird,
93 int nQuantumTicks,
94 int nLengthTicks,
95 int nChannel);
96
103 virtual ~Scratcher();
104
115 virtual void Start(int nPlayer, int nTickOffset);
116
123 virtual void Stop();
124
132 virtual int IsScratching();
133
141 virtual int GetLoopLength();
142
150 virtual void SetPitch(float fPitch);
151
159 virtual void SetPosition(float fPosition);
160
161private:
169 void SendPitchBend(float fPitch);
170
178 void SwitchPiece(int nPiece);
179
186 void Restart();
187
188 int mChannel;
189 int mQuantumTicks;
190 std::vector<std::unique_ptr<MuseLooper>> mLoopers;
191 std::vector<Ptr<Muse>> mCopies;
192 Ptr<Command> mRestartCmd;
193 int mScratching;
194 float mPitch;
195 int mReserved34; // +0x34, cleared by the constructor and not yet identified.
196 int mPiece;
197 ScratchNoteCB mNoteCB;
198};
Receiver of each note a muse starts.
Definition muse.h:20
Piece of MIDI performance that a Scheduler plays.
Definition muse.h:12
Owner of one reference to an Attachment.
Definition ptr.h:16
Receiver that shows each note a piece starts on the scratching player's track.
Definition scratcher.h:31
int GetTickOffset() const
Definition scratcher.h:52
~ScratchNoteCB() override=default
Destroy the object.
void SetPlayer(int nPlayer)
Definition scratcher.h:67
void SetTickOffset(int nTickOffset)
Definition scratcher.h:57
int GetPlayer() const
Definition scratcher.h:62
void OnNote(unsigned char nNote, int nDuration) override
Show a note at the current tick.
virtual void Start(int nPlayer, int nTickOffset)
Start scratching for a player.
virtual int IsScratching()
Report whether the scratcher is scratching.
virtual void Stop()
Stop scratching and bend the channel back.
virtual int GetLoopLength()
Report the ticks of one loop of the pieces.
Scratcher(Muse *pFirst, Muse *pSecond, Muse *pThird, int nQuantumTicks, int nLengthTicks, int nChannel)
Construct a scratcher over three recorded pieces.
virtual ~Scratcher()
Stop scratching and release the pieces.
virtual void SetPosition(float fPosition)
Pick the piece from the horizontal position of the stick.
virtual void SetPitch(float fPitch)
Set the pitch.
static constexpr int kNumPieces
Number of pieces, one for each stick position.
Definition scratcher.h:23