Synthesiser note array (stereo)
More...
#include <klang.h>
|
void | add (int count) |
|
void | add (const Note *&item) |
| Add the specified item to the end of the array.
|
|
Note ** | add () |
| Add a blank item to the end of the array, returning a pointer that allows the item to be modified.
|
|
int | assign () |
|
unsigned int | size () const |
| The current number of items in the array.
|
|
void | clear () |
| Clear the array contents. Only resets the item count, without wiping memory.
|
|
float | max () const |
| Find the maximum value in the array.
|
|
float | mean () const |
| Find the mean average of values in the array.
|
|
float | rms () const |
| Find the root mean squared (RMS) average of values in the array.
|
|
void | normalise (float target=1.f, int mode=Peak) |
| Normalises values in the array to the specified target, based on peak, mean, or RMS value;.
|
|
Note *& | operator[] (int index) |
| Returns a reference to the array item at the given index.
|
|
const Note *& | operator[] (int index) const |
| Returns a read-only reference to the array item at the given index.
|
|
|
static int | capacity () |
| The maximum capacity of the array.
|
|
Definition at line 3570 of file klang.h.
◆ Array
◆ add() [1/3]
Definition at line 255 of file klang.h.
255 {
256 if (
count < CAPACITY)
258 return nullptr;
259 }
◆ add() [2/3]
◆ add() [3/3]
Definition at line 3204 of file klang.h.
3204 {
3205 for (
int n = 0; n <
count; n++) {
3206 TYPE* note = new TYPE();
3207 note->attach(
synth);
3209 }
3210 }
TYPE * add()
Add a blank item to the end of the array, returning a pointer that allows the item to be modified.
◆ assign()
Definition at line 3216 of file klang.h.
3216 {
3217
3218 for (
int i = 0; i <
count; i++) {
3219 if (
items[i]->stage == NOTE::Off){
3221 return i;
3222 }
3223 }
3224
3225
3226 int oldest = -1;
3227 unsigned int oldest_start = 0;
3228 for (
int i = 0; i <
count; i++) {
3229 if (
items[i]->stage == NOTE::Release) {
3230 if(oldest == -1 ||
noteStart[i] < oldest_start){
3231 oldest = i;
3233 }
3234 }
3235 }
3236 if(oldest != -1){
3238 return oldest;
3239 }
3240
3241
3242 oldest = -1;
3243 oldest_start = 0;
3244 for (
int i = 0; i <
count; i++) {
3245 if(oldest == -1 ||
noteStart[i] < oldest_start){
3246 oldest = i;
3248 }
3249 }
3251 return oldest;
3252 }
unsigned int noteStart[128]
◆ capacity()
◆ clear()
◆ max()
Definition at line 265 of file klang.h.
265 {
267 for (
unsigned int i = 0; i <
count; i++)
271 }
◆ mean()
Definition at line 274 of file klang.h.
274 {
275 float sum = 0.f;
276 for (
unsigned int i = 0; i <
count; i++)
277 sum += abs(
items[i]);
279 }
◆ normalise()
Definition at line 290 of file klang.h.
290 {
292
294 const float scale = current == 0.f ? 0.f : target / current;
295 for (
int i = 0; i <
count; i++)
297 }
◆ operator[]() [1/2]
◆ operator[]() [2/2]
◆ rms()
Definition at line 282 of file klang.h.
282 {
283 float sum = 0.f;
284 for (
unsigned int i = 0; i <
count; i++)
286 return sqrt(sum /
count);
287 }
◆ size()
◆ count
◆ items
◆ noteOns
◆ noteStart
◆ synth