Zrythm v2.0.0-alpha.1+31.4967fd053471
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::MidiActivityProvider Class Reference

Tracks note activity and general MIDI activity on an observed port. More...

#include <src/dsp/midi_activity_provider.h>

Inheritance diagram for zrythm::dsp::MidiActivityProvider:
Collaboration diagram for zrythm::dsp::MidiActivityProvider:

Public Member Functions

 MidiActivityProvider (QObject *parent=nullptr)
dsp::Portport () const
void setPort (dsp::Port *port)
Q_SIGNAL void portChanged ()
dsp::PortObservationManagerportObservationManager () const
void setPortObservationManager (dsp::PortObservationManager *manager)
Q_SIGNAL void portObservationManagerChanged ()
bool hasActivity () const
 True when any MIDI events were received in the last update cycle.
Q_SIGNAL void activityChanged ()
Q_INVOKABLE bool isNoteActive (int note) const
 Returns true if note (0-127) is currently held.
Q_SIGNAL void activeNotesChanged ()
 Emitted when the set of active notes changes.
void update ()
 Drains pending events from the observation cache and updates state.

Properties

QML_ELEMENT zrythm::dsp::Portport
zrythm::dsp::PortObservationManagerportObservationManager
bool hasActivity

Detailed Description

Tracks note activity and general MIDI activity on an observed port.

Observes a MidiPort via the PortObservationManager infrastructure. A 60fps timer drains MIDI events from the observation cache and updates two kinds of state exposed to QML:

  1. Note activity — per-pitch tracking using a reference counter that correctly handles overlapping note-ons on the same pitch (from different channels or repeated presses). A pitch is considered active until all matching note-offs have been received. Query via isNoteActive().
  2. General activity — a boolean that is true for one update cycle when any MIDI events (notes, CC, program change, etc.) are received, and false when the cache is empty. Useful for activity indicators.

Typical QML usage:

MidiActivityProvider {
port: track.trackProcessorMidiOut
portObservationManager: session.project.portObservationManager
}
Thread safety
All public methods run on the Qt event loop (main thread). The RT thread writes to ring buffers via PortObserver; the observation manager's drain timer copies data into per-requester caches on the UI thread. No locks or atomics are needed in this class.

Definition at line 46 of file midi_activity_provider.h.

Member Function Documentation

◆ isNoteActive()

Q_INVOKABLE bool zrythm::dsp::MidiActivityProvider::isNoteActive ( int note) const

Returns true if note (0-127) is currently held.

Channels are aggregated — a note is active if any channel has it held. Overlapping note-ons are reference-counted; the note only becomes inactive when all note-offs have been received.

◆ update()

void zrythm::dsp::MidiActivityProvider::update ( )

Drains pending events from the observation cache and updates state.

Called automatically by the internal 60fps timer. Can also be called manually (e.g., in tests).

Property Documentation

◆ hasActivity

bool zrythm::dsp::MidiActivityProvider::hasActivity
read

Definition at line 52 of file midi_activity_provider.h.

◆ port

QML_ELEMENT zrythm::dsp::Port * zrythm::dsp::MidiActivityProvider::port
readwrite

Definition at line 50 of file midi_activity_provider.h.

◆ portObservationManager

zrythm::dsp::PortObservationManager * zrythm::dsp::MidiActivityProvider::portObservationManager
readwrite

Definition at line 51 of file midi_activity_provider.h.


The documentation for this class was generated from the following file: