-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
65 lines (50 loc) · 1.98 KB
/
main.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 <grit/eurorack/kyma.hpp>
#include <etl/linalg.hpp>
#include <daisy_patch_sm.h>
namespace kyma {
static constexpr auto blockSize = 16U;
static constexpr auto sampleRate = 96'000.0F;
auto patch = daisy::patch_sm::DaisyPatchSM{};
auto toggle = daisy::Switch{};
auto button = daisy::Switch{};
auto processor = grit::Kyma{};
auto audioCallback(
daisy::AudioHandle::InterleavingInputBuffer in,
daisy::AudioHandle::InterleavingOutputBuffer out,
size_t size
) -> void
{
patch.ProcessAllControls();
toggle.Debounce();
button.Debounce();
patch.SetLed(not toggle.Pressed());
auto const controls = grit::Kyma::ControlInput{
.pitchKnob = patch.GetAdcValue(daisy::patch_sm::CV_1),
.morphKnob = patch.GetAdcValue(daisy::patch_sm::CV_3),
.attackKnob = patch.GetAdcValue(daisy::patch_sm::CV_2),
.releaseKnob = patch.GetAdcValue(daisy::patch_sm::CV_4),
.vOctCV = patch.GetAdcValue(daisy::patch_sm::CV_5),
.morphCV = patch.GetAdcValue(daisy::patch_sm::CV_6),
.subGainCV = patch.GetAdcValue(daisy::patch_sm::CV_7),
.subMorphCV = patch.GetAdcValue(daisy::patch_sm::CV_8),
.gate = patch.gate_in_1.State() or button.Pressed(),
.subShift = toggle.Pressed(),
};
auto const input = grit::StereoBlock<float const>{in, size};
auto const output = grit::StereoBlock<float>{out, size};
etl::linalg::copy(input, output);
auto const env = processor.process(output, controls);
patch.WriteCvOut(daisy::patch_sm::CV_OUT_2, env * 5.0F);
}
} // namespace kyma
auto main() -> int
{
kyma::patch.Init();
kyma::toggle.Init(daisy::patch_sm::DaisyPatchSM::B8);
kyma::button.Init(daisy::patch_sm::DaisyPatchSM::B7);
kyma::processor.prepare(kyma::sampleRate, kyma::blockSize);
kyma::patch.SetAudioSampleRate(kyma::sampleRate);
kyma::patch.SetAudioBlockSize(kyma::blockSize);
kyma::patch.StartAudio(kyma::audioCallback);
while (true) {}
}