-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (40 loc) · 1.45 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
#include <grit/audio/stereo.hpp>
#include <grit/math/remap.hpp>
#include <grit/unit/decibel.hpp>
#include <daisy_patch_sm.h>
namespace hermas {
constexpr auto blockSize = 16U;
constexpr auto sampleRate = 96'000.0F;
auto patch = daisy::patch_sm::DaisyPatchSM{};
auto audioCallback(
daisy::AudioHandle::InterleavingInputBuffer in,
daisy::AudioHandle::InterleavingOutputBuffer out,
size_t size
) -> void
{
patch.ProcessAllControls();
auto const input = grit::StereoBlock<float const>{in, size};
auto const output = grit::StereoBlock<float>{out, size};
auto const gainLeftKnob = patch.GetAdcValue(daisy::patch_sm::CV_1);
auto const gainRightKnob = patch.GetAdcValue(daisy::patch_sm::CV_2);
auto const gainLeft = grit::fromDecibels(grit::remap(gainLeftKnob, -30.0F, 6.0F));
auto const gainRight = grit::fromDecibels(grit::remap(gainRightKnob, -30.0F, 6.0F));
for (size_t i = 0; i < size; ++i) {
auto const inLeft = input(0, i);
auto const inRight = input(1, i);
auto const leftGained = inLeft * gainLeft;
auto const rightGained = inRight * gainRight;
output(0, i) = leftGained + rightGained;
output(1, i) = leftGained + rightGained;
}
}
} // namespace hermas
auto main() -> int
{
using namespace hermas;
patch.Init();
patch.SetAudioSampleRate(sampleRate);
patch.SetAudioBlockSize(blockSize);
patch.StartAudio(audioCallback);
while (true) {}
}