-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathmasterfx.h
157 lines (128 loc) · 5.13 KB
/
masterfx.h
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#pragma once
/*
* File: master.h
*
* Dummy Master Effect Class
*
* Author: Etienne Noreau-Hebert <[email protected]>
*
* 2021 (c) Korg
*
*/
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <arm_neon.h>
#include "unit.h" // Note: Include common definitions for all units
class MasterFX {
public:
/*===========================================================================*/
/* Public Data Structures/Types. */
/*===========================================================================*/
/*===========================================================================*/
/* Lifecycle Methods. */
/*===========================================================================*/
MasterFX(void) {}
virtual ~MasterFX(void) {}
inline int8_t Init(const unit_runtime_desc_t * desc) {
// Check compatibility of samplerate with unit, for drumlogue should be 48000
if (desc->samplerate != 48000) // Note: samplerate format may change to add fractional bits
return k_unit_err_samplerate;
// Check compatibility of frame geometry
// Note: input format: [ main_left, main_right, sidechain_left, sidechain_right ]
// Note: Sidechain feature may unfortunately get removed before official release, in which case
// there will be only 2 input channels
if (desc->input_channels != 4 || desc->output_channels != 2)
return k_unit_err_geometry;
// Note: if need to allocate some memory can do it here and return k_unit_err_memory if getting allocation errors
return k_unit_err_none;
}
inline void Teardown() {
// Note: cleanup and release resources if any
}
inline void Reset() {
// Note: Reset effect state.
}
inline void Resume() {
// Note: Effect will resume and exit suspend state. Usually means the synth
// was selected and the render callback will be called again
}
inline void Suspend() {
// Note: Effect will enter suspend state. Usually means another effect was
// selected and thus the render callback will not be called
}
/*===========================================================================*/
/* Other Public Methods. */
/*===========================================================================*/
fast_inline void Process(const float * in, float * out, size_t frames) {
const float * __restrict in_p = in;
float * __restrict out_p = out;
const float * out_e = out_p + (frames << 1); // assuming stereo output
for (; out_p != out_e; in_p += 4, out_p += 2) {
// Note: should take advantage of NEON ArmV7 instructions
float32x4_t sig = vld1q_f32(in_p);
vst1_f32(out_p, vget_low_f32(sig));
}
}
inline void setParameter(uint8_t index, int32_t value) {
(void)value;
switch (index) {
default:
break;
}
}
inline int32_t getParameterValue(uint8_t index) const {
switch (index) {
default:
break;
}
return 0;
}
inline const char * getParameterStrValue(uint8_t index, int32_t value) const {
(void)value;
switch (index) {
// Note: String memory must be accessible even after function returned.
// It can be assumed that caller will have copied or used the string
// before the next call to getParameterStrValue
default:
break;
}
return nullptr;
}
inline const uint8_t * getParameterBmpValue(uint8_t index,
int32_t value) const {
(void)value;
switch (index) {
// Note: Bitmap memory must be accessible even after function returned.
// It can be assumed that caller will have copied or used the bitmap
// before the next call to getParameterBmpValue
// Note: Not yet implemented upstream
default:
break;
}
return nullptr;
}
inline void LoadPreset(uint8_t idx) { (void)idx; }
inline uint8_t getPresetIndex() const { return 0; }
/*===========================================================================*/
/* Static Members. */
/*===========================================================================*/
static inline const char * getPresetName(uint8_t idx) {
(void)idx;
// Note: String memory must be accessible even after function returned.
// It can be assumed that caller will have copied or used the string
// before the next call to getPresetName
return nullptr;
}
private:
/*===========================================================================*/
/* Private Member Variables. */
/*===========================================================================*/
std::atomic_uint_fast32_t flags_;
/*===========================================================================*/
/* Private Methods. */
/*===========================================================================*/
/*===========================================================================*/
/* Constants. */
/*===========================================================================*/
};