-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsequencer.cpp
63 lines (50 loc) · 1.07 KB
/
sequencer.cpp
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
//
// sequencer.cpp
// fluX
//
// Created by pd3v on 01/07/18.
//
//
#include "maximilian.h"
#include "note.h"
#include "sequencer.h"
#include "generator.h"
#include "synth.h"
maxiOsc Seq::_tick;
float Seq::_tempo;
int Seq::_pattern;
vector<int> Seq::_scale;
note_t Seq::_note;
function<vector<int>(void)> Seq::_f;
Gen Seq::_gen;
int Seq::counter = 0;
int& Seq::playHead = Seq::counter; // counter alias
int Seq::lastCount = -1;
Synth Seq::synth;
Seq& Seq::instance() {
static Seq s;
return s;
};
Seq& Seq::start(float tempo, float pattern) {
_tempo = tempo;
_pattern = pattern;
return Seq::instance();
};
Seq& Seq::gen(vector<int> scale, std::function<vector<int>(void)> f) {
_gen = Gen::instance(scale, f);
_scale = scale;
_f = f;
return Seq::instance();
};
Seq& Seq::synthOut() {
synth = Synth();
return Seq::instance();
};
double Seq::output() {
counter += (int)_tick.phasor(_tempo * _note.dur / 60);
if (lastCount != counter) {
_note = _gen.note();
lastCount = counter;
}
return synth.output(_note);
}