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 6149 of file klang.h.
◆ Array
◆ add() [1/3]
Definition at line 324 of file klang.h.
324 {
325 if (
count < CAPACITY)
327 return nullptr;
328 }
◆ add() [2/3]
Definition at line 318 of file klang.h.
318 {
319 if (
count < CAPACITY)
321 }
◆ add() [3/3]
Definition at line 5667 of file klang.h.
5667 {
5668 for (
int n = 0; n <
count; n++) {
5669 TYPE* note = new TYPE();
5670 note->attach(
synth);
5672 }
5673 }
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 5679 of file klang.h.
5679 {
5680
5681 for (
unsigned int i = 0; i <
count; i++) {
5682 if (
items[i]->stage == NOTE::Off) {
5684 return i;
5685 }
5686 }
5687
5688
5689 int oldest = -1;
5690 unsigned int oldest_start = 0;
5691 for (
unsigned int i = 0; i <
count; i++) {
5692 if (
items[i]->stage == NOTE::Release) {
5693 if (oldest == -1 ||
noteStart[i] < oldest_start) {
5694 oldest = i;
5696 }
5697 }
5698 }
5699 if (oldest != -1) {
5701 return oldest;
5702 }
5703
5704
5705 oldest = -1;
5706 oldest_start = 0;
5707 for (
unsigned int i = 0; i <
count; i++) {
5708 if (oldest == -1 ||
noteStart[i] < oldest_start) {
5709 oldest = i;
5711 }
5712 }
5714 return oldest;
5715 }
unsigned int noteStart[128]
◆ capacity()
◆ clear()
◆ max()
Definition at line 334 of file klang.h.
334 {
335 float max = 0.f;
336 for (
unsigned int i = 0; i <
count; i++)
337 if (abs(
items[i]) > max)
340 }
◆ mean()
Definition at line 343 of file klang.h.
343 {
344 float sum = 0.f;
345 for (
unsigned int i = 0; i <
count; i++)
346 sum += abs(
items[i]);
348 }
◆ normalise()
Definition at line 359 of file klang.h.
359 {
361
363 const float scale = current == 0.f ? 0.f : target / current;
364 for (
int i = 0; i <
count; i++)
366 }
◆ operator[]() [1/2]
◆ operator[]() [2/2]
◆ rms()
Definition at line 351 of file klang.h.
351 {
352 float sum = 0.f;
353 for (
unsigned int i = 0; i <
count; i++)
355 return sqrt(sum /
count);
356 }
◆ size()
◆ count
◆ items
◆ noteOns
◆ noteStart
◆ synth