-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroundaboutsequencer.h
101 lines (89 loc) · 3.3 KB
/
roundaboutsequencer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef ROUNDABOUTSEQUENCER_H
#define ROUNDABOUTSEQUENCER_H
/*
Copyright 2011 Arne Jacobs <[email protected]>
This file is part of Roundabout.
Roundabout is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Roundabout is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Roundabout. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QBitArray>
#include "roundaboutthread.h"
class RoundaboutSequencer;
struct RoundaboutSequencerInboundEvent {
enum EventType {
TOGGLE_STEP,
TOGGLE_NOTE,
CONNECT_STEP,
CHANGE_STEP_BRANCH_FREQUENCY
} eventType;
int step, note, connectedStep, branchFrequency, continueFrequency;
RoundaboutSequencer *sequencer;
};
struct RoundaboutSequencerOutboundEvent {
enum EventType {
ENTERED_STEP,
LEFT_STEP,
CHANGED_BRANCH_COUNTER
} eventType;
int step, branchCounter;
};
class RoundaboutSequencer : public QObject, public InboundEventsHelper<RoundaboutSequencerInboundEvent>, public OutboundEventsHelper<RoundaboutSequencerOutboundEvent>
{
Q_OBJECT
public:
class Step {
public:
Step() :
active(true),
activeNotes(13),
connection(0),
connectedStep(0),
branchFrequency(1),
continueFrequency(0),
branchCounter(0)
{}
bool active;
QBitArray activeNotes;
RoundaboutSequencer *connection;
int connectedStep;
int branchFrequency, continueFrequency, branchCounter;
};
RoundaboutSequencer(QObject *parent = 0);
void processChangeInputChannel(unsigned char channel);
void processChangeOutputChannel(unsigned char channel);
void setNextStep(int step);
virtual RoundaboutSequencer * processStepBegin(QVector<MidiEvent> &output);
virtual void processStepEnd(QVector<MidiEvent> &output);
void processStop(QVector<MidiEvent> &output);
virtual void processMidiEvents(const QVector<MidiEvent> &input);
protected:
// Reimplemented from InboundEventsHelper:
virtual void processInboundEvent(RoundaboutSequencerInboundEvent &event);
// Reimplemented from OutboundEventsHelper:
virtual void processOutboundEvent(RoundaboutSequencerOutboundEvent &event);
signals:
void enteredStep(int step);
void leftStep(int step);
void changedBranchCounter(int step, int branchCounter);
public slots:
void toggleStep(int step);
void toggleNote(int step, int note);
void connect(int step, RoundaboutSequencer *sequencer, int connectedStep);
void disconnect(int step);
void setStepBranchFrequency(int step, int branchFrequency, int continueFrequency);
private:
unsigned char inputChannel, outputChannel, baseNoteNumber, activeBaseNoteNumber;
QBitArray activeNotes;
int stepsPerBeat, nextStep, activeStep;
QVector<Step> steps;
};
#endif // ROUNDABOUTSEQUENCER_H