-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit.cc
119 lines (90 loc) · 3.06 KB
/
unit.cc
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* @file unit.cc
* @brief drumlogue SDK unit interface
*
* Copyright (c) 2020-2022 KORG Inc. All rights reserved.
*
*/
#include <cstddef>
#include <cstdint>
#include "unit.h" // Note: Include common definitions for all units
#include "synth.h" // Note: Include custom master fx code
static Synth s_synth_instance; // Note: In this case, actual instance of custom master fx object.
static unit_runtime_desc_t s_runtime_desc; // Note: used to cache runtime descriptor obtained via init callback
// ---- Callback entry points from drumlogue runtime ----------------------------------------------
__unit_callback int8_t unit_init(const unit_runtime_desc_t * desc) {
if (!desc)
return k_unit_err_undef;
if (desc->target != unit_header.target)
return k_unit_err_target;
if (!UNIT_API_IS_COMPAT(desc->api))
return k_unit_err_api_version;
s_runtime_desc = *desc;
return s_synth_instance.Init(desc);
}
__unit_callback void unit_teardown() {
s_synth_instance.Teardown();
}
__unit_callback void unit_reset() {
s_synth_instance.Reset();
}
__unit_callback void unit_resume() {
s_synth_instance.Resume();
}
__unit_callback void unit_suspend() {
s_synth_instance.Suspend();
}
__unit_callback void unit_render(const float * in, float * out, uint32_t frames) {
(void)in;
s_synth_instance.Render(out, frames);
}
__unit_callback void unit_set_param_value(uint8_t id, int32_t value) {
s_synth_instance.setParameter(id, value);
}
__unit_callback int32_t unit_get_param_value(uint8_t id) {
return s_synth_instance.getParameterValue(id);
}
__unit_callback const char * unit_get_param_str_value(uint8_t id, int32_t value) {
return s_synth_instance.getParameterStrValue(id, value);
}
__unit_callback const uint8_t * unit_get_param_bmp_value(uint8_t id, int32_t value) {
return s_synth_instance.getParameterBmpValue(id, value);
}
__unit_callback void unit_set_tempo(uint32_t tempo) {
// const float t = (tempo >> 16) + (tempo & 0xFFFF) /
// static_cast<float>(0x10000);
(void)tempo;
}
__unit_callback void unit_note_on(uint8_t note, uint8_t velocity) {
s_synth_instance.NoteOn(note, velocity);
}
__unit_callback void unit_note_off(uint8_t note) {
s_synth_instance.NoteOff(note);
}
__unit_callback void unit_gate_on(uint8_t velocity) {
s_synth_instance.GateOn(velocity);
}
__unit_callback void unit_gate_off() {
s_synth_instance.GateOff();
}
__unit_callback void unit_all_note_off() {
s_synth_instance.AllNoteOff();
}
__unit_callback void unit_pitch_bend(uint16_t bend) {
s_synth_instance.PitchBend(bend);
}
__unit_callback void unit_channel_pressure(uint8_t pressure) {
s_synth_instance.ChannelPressure(pressure);
}
__unit_callback void unit_aftertouch(uint8_t note, uint8_t aftertouch) {
s_synth_instance.Aftertouch(note, aftertouch);
}
__unit_callback void unit_load_preset(uint8_t idx) {
return s_synth_instance.LoadPreset(idx);
}
__unit_callback uint8_t unit_get_preset_index() {
return s_synth_instance.getPresetIndex();
}
__unit_callback const char * unit_get_preset_name(uint8_t idx) {
return Synth::getPresetName(idx);
}