Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
MidiPort Class Referencefinal

MIDI port specifics. More...

#include <src/gui/dsp/midi_port.h>

Inheritance diagram for MidiPort:
Collaboration diagram for MidiPort:

Public Member Functions

 MidiPort (utils::Utf8String label, PortFlow flow)
void process_block (EngineProcessTimeInfo time_nfo) override
void prepare_for_processing (sample_rate_t sample_rate, nframes_t max_block_length) override
 Called to allocate resources required for processing.
void release_resources () override
 Called to release resources allocated by prepare_for_processing().
void clear_buffer (std::size_t block_length) override
 Clears the port buffer.
Public Member Functions inherited from Port
void init_loaded (IPortOwner &owner)
 This function finds the Ports corresponding to the PortIdentifiers for srcs and dests.
void set_owner (IPortOwner &owner)
utils::Utf8String get_label () const
bool is_control () const
bool is_audio () const
bool is_cv () const
bool is_event () const
bool is_midi () const
bool is_input () const
bool is_output () const
utils::Utf8String get_node_name () const override
 Returns a human friendly name of the node.
nframes_t get_single_playback_latency () const override
 Ports have no latency.
virtual bool has_sound () const
 If MIDI port, returns if there are any events, if audio port, returns if there is sound in the buffer.
utils::Utf8String get_full_designation () const
 Gets a full designation of the port in the format "Track/Port" or "Track/Plugin/Port".
void change_track (IPortOwner::TrackUuid new_track_id)
 Updates the owner track identifier.
bool has_label () const
PortType get_type () const
PortFlow get_flow () const
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< Port >
UuidIdentifiableObjectoperator= (const UuidIdentifiableObject &other)=default
auto get_uuid () const

Data Fields

dsp::MidiEvents midi_events_
 Contains raw MIDI data (MIDI ports only)
std::unique_ptr< RingBuffer< dsp::MidiEvent > > midi_ring_
 Ring buffer for saving MIDI events to be used in the UI instead of directly accessing the events.
std::atomic< bool > has_midi_events_ = false
 Whether the port has midi events not yet processed by the UI.
qint64 last_midi_event_time_ = 0
 Used by the UI to detect when unprocessed MIDI events exist.
midi_byte_t last_midi_status_ = 0
 Last known MIDI status byte received.
Data Fields inherited from Port
std::unique_ptr< PortIdentifierid_
 Owned pointer.
IPortOwnerowner_ {}
PortRange range_
Data Fields inherited from PortConnectionsCacheMixin< MidiPort >
std::vector< ElementType > port_sources_
 Caches filled when recalculating the graph.
Data Fields inherited from RingBufferOwningPortMixin
std::atomic< int > num_ring_buffer_readers_ { 0 }
 Number of entities that want ring buffers to be written.

Friends

void init_from (MidiPort &obj, const MidiPort &other, utils::ObjectCloneType clone_type)
void to_json (nlohmann::json &j, const MidiPort &p)
void from_json (const nlohmann::json &j, MidiPort &p)

Additional Inherited Members

Public Types inherited from Port
using PortIdentifier = dsp::PortIdentifier
using PortType = dsp::PortType
using PortFlow = dsp::PortFlow
using PortConnection = dsp::PortConnection
Protected Member Functions inherited from Port
 Port (utils::Utf8String label, PortType type={}, PortFlow flow={}, float minf=0.f, float maxf=1.f, float zerof=0.f)

Detailed Description

MIDI port specifics.

Definition at line 19 of file midi_port.h.

Member Function Documentation

◆ clear_buffer()

void MidiPort::clear_buffer ( std::size_t block_length)
overridevirtual

Clears the port buffer.

Implements Port.

◆ prepare_for_processing()

void MidiPort::prepare_for_processing ( sample_rate_t sample_rate,
nframes_t max_block_length )
overridevirtual

Called to allocate resources required for processing.

Parameters
sample_rate
max_block_length

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ process_block()

void MidiPort::process_block ( EngineProcessTimeInfo time_nfo)
overridevirtual

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ release_resources()

void MidiPort::release_resources ( )
overridevirtual

Called to release resources allocated by prepare_for_processing().

This may be called multiple times.

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ from_json

void from_json ( const nlohmann::json & j,
MidiPort & p )
friend

Definition at line 53 of file midi_port.h.

◆ to_json

void to_json ( nlohmann::json & j,
const MidiPort & p )
friend

Definition at line 49 of file midi_port.h.

Field Documentation

◆ has_midi_events_

std::atomic<bool> MidiPort::has_midi_events_ = false

Whether the port has midi events not yet processed by the UI.

Definition at line 79 of file midi_port.h.

◆ last_midi_event_time_

qint64 MidiPort::last_midi_event_time_ = 0

Used by the UI to detect when unprocessed MIDI events exist.

Definition at line 82 of file midi_port.h.

◆ last_midi_status_

midi_byte_t MidiPort::last_midi_status_ = 0

Last known MIDI status byte received.

Used for running status (see http://midi.teragonaudio.com/tech/midispec/run.htm).

Not needed for JACK.

Definition at line 92 of file midi_port.h.

◆ midi_events_

dsp::MidiEvents MidiPort::midi_events_

Contains raw MIDI data (MIDI ports only)

Definition at line 62 of file midi_port.h.

◆ midi_ring_

std::unique_ptr<RingBuffer<dsp::MidiEvent> > MidiPort::midi_ring_

Ring buffer for saving MIDI events to be used in the UI instead of directly accessing the events.

This should keep pushing MidiEvent's whenever they occur and the reader should empty it after checking if there are any events.

Currently there is only 1 reader for each port so this wont be a problem for now, but we should have one ring for each reader.

Definition at line 74 of file midi_port.h.


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