forked from vlad-litvinenko/spotykach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththat_simple.cpp
65 lines (53 loc) · 1.35 KB
/
that_simple.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
64
65
#include "daisy_seed.h"
#include "core/globals.h"
#include "core/Spotykach.h"
#include "control/controller.h"
#include "control/sync.h"
#include "control/leds.h"
#include "common/deb.h"
using namespace daisy;
using namespace vlly;
using namespace spotykach;
DaisySeed hw;
Controller controller;
Spotykach core;
PlaybackParameters p;
Sync snc;
Leds leds;
const float tempo { 120 };
const int bufferSize { 4 };
void AudioCallback(AudioHandle::InputBuffer in, AudioHandle::OutputBuffer out, size_t size) {
static int cnfg_cnt { 0 };
if (++cnfg_cnt == 40) {
p.tempo = snc.tempo();
p.sampleRate = kSampleRate;
cnfg_cnt = 0;
}
core.preprocess(p);
core.process(in, out, size);
}
int main(void) {
hw.Configure();
hw.Init();
//HW::hw().setHW(&hw);
//HW::hw().startLog();
core.initialize();
snc.run(core);
controller.initialize(hw, core);
leds.initialize();
core.engineAt(0).set_on_slice([](uint32_t sl, bool rev){ leds.blink_a(sl, rev); });
core.engineAt(1).set_on_slice([](uint32_t sl, bool rev){ leds.blink_b(sl, rev); });
hw.SetAudioBlockSize(bufferSize);
hw.SetAudioSampleRate(SaiHandle::Config::SampleRate::SAI_48KHZ);
hw.StartAudio(AudioCallback);
uint32_t count_limit = 10e2;
while(1) {
snc.pull(hw);
leds.tick();
static uint32_t counter = 0;
if (++counter == count_limit ) {
counter = 0;
controller.set_parameters(core, leds);
}
}
}