|
OSSIA
Open Scenario System for Interactive Application
|
The notes a MIDI stream has started and not yet stopped.
Whoever cuts a stream short (a cable taken off, a node removed, an output rebound to another device) asks for what is left sounding and stops it at the far end, which otherwise never gets the note off.
One bit per (channel, pitch): a note on sets it, a note off clears it, so tracking a message is a mask and a store, and nothing is ever allocated. Releasing is conservative on purpose: a note off for a note that does not sound is ignored by receivers, a missing one is a note that never ends. Hence
Tracking keeps no summary of the table up to date: that would be paid on every message, for the sake of a release that happens once.
The damper pedal is tracked along: notes released under a pedal that stays down ring forever just as well.
Public Member Functions | |
| bool | empty () const noexcept |
| Looks at the whole table: for when a stream is cut, not for every tick. | |
| void | clear () noexcept |
| void | track (const libremidi::ump &m) noexcept |
| template<typename Messages> | |
| void | track (const Messages &messages) noexcept |
| void | track (const libremidi::ump *it, const libremidi::ump *end) noexcept |
| A tick's worth at once. | |
| template<typename Messages> | |
| void | release (Messages &out, int64_t timestamp=0) const |
Appends what stops everything held to out, stamped at timestamp: the pedals up, then a note off per note. | |
| int | count () const noexcept |
| Number of notes held. | |
Public Attributes | |
| std::array< uint64_t, channels *pitches/64 > | notes {} |
| Bit (channel * 128 + pitch). | |
| uint16_t | damper {} |
| Channels whose damper pedal (CC 64) is down. | |
| uint16_t | groups {} |
| UMP groups that carried a note on or a pedal. | |
| bool | midi1 {} |
| The last note came as a MIDI 1 channel voice message: stop it in kind. | |
Static Public Attributes | |
| static constexpr int | channels = 16 |
| static constexpr int | pitches = 128 |
|
inlinenoexcept |
A tick's worth at once.
The state other than the table is kept out of memory for the length of the loop: most messages of a stream are not notes, and those then cost a test and nothing else.
|
inline |
Appends what stops everything held to out, stamped at timestamp: the pedals up, then a note off per note.
The tracker is left untouched: the stream may go on elsewhere.
| uint16_t ossia::midi_note_tracker::groups {} |
UMP groups that carried a note on or a pedal.
Only ever grows: it says where to send the note offs, not whether there is something to stop.