forked from korginc/logue-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit.cc
86 lines (65 loc) · 2.49 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
/**
* @file unit.cc
* @brief drumlogue SDK unit interface
*
* Copyright (c) 2020-2022 KORG Inc. All rights reserved.
*
*/
#include "unit.h" // Note: Include common definitions for all units
#include "masterfx.h" // Note: Include custom master fx code
static MasterFX s_master_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;
// Note: make sure the unit is being loaded to the correct platform/module target
if (desc->target != unit_header.target)
return k_unit_err_target;
// Note: check API compatibility with the one this unit was built against
if (!UNIT_API_IS_COMPAT(desc->api))
return k_unit_err_api_version;
// Note: (optional) caching runtime descriptor for future reference
s_runtime_desc = *desc;
return s_master_instance.Init(desc);
}
__unit_callback void unit_teardown() {
s_master_instance.Teardown();
}
__unit_callback void unit_reset() {
s_master_instance.Reset();
}
__unit_callback void unit_resume() {
s_master_instance.Resume();
}
__unit_callback void unit_suspend() {
s_master_instance.Suspend();
}
__unit_callback void unit_render(const float * in, float * out, uint32_t frames) {
s_master_instance.Process(in, out, frames);
}
__unit_callback void unit_set_param_value(uint8_t id, int32_t value) {
s_master_instance.setParameter(id, value);
}
__unit_callback int32_t unit_get_param_value(uint8_t id) {
return s_master_instance.getParameterValue(id);
}
__unit_callback const char * unit_get_param_str_value(uint8_t id, int32_t value) {
return s_master_instance.getParameterStrValue(id, value);
}
__unit_callback const uint8_t * unit_get_param_bmp_value(uint8_t id, int32_t value) {
return s_master_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_load_preset(uint8_t idx) {
s_master_instance.LoadPreset(idx);
}
__unit_callback uint8_t unit_get_preset_index() {
return s_master_instance.getPresetIndex();
}
__unit_callback const char * unit_get_preset_name(uint8_t idx) {
return MasterFX::getPresetName(idx);
}