Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::midi::MockMidiSystem Class Reference

#include <mock_midi_system.hpp>

Public Types

using PortChangeCallback = std::function<void()>
 Register a callback for MIDI port changes (device plug/unplug).

Public Member Functions

void add_port (const std::string &id, const std::string &name, bool is_input=true)
 Add (or replace) a port and notify the port-change callback.
void remove_port (const std::string &id, bool is_input=true)
 Remove a port and notify the port-change callback.
void set_ports_silently (std::vector< MidiPortInfo > ports)
 Change the port list without notifying, to model a notification that never arrived.
void notify ()
int inject (const std::string &id, const MidiEvent &event)
 Deliver event to every open input on id. Returns how many received it.
void drop_connections (const std::string &id)
 Sever the connection of every open input on id while the port stays listed, as when an OS replaces an endpoint behind a still-present name (a device that vanished and returned across a sleep).
int open_input_count (const std::string &id) const
 Number of currently open inputs on id.
int total_opens () const
 Total successful input opens since construction.
void fail_next_opens (int count)
 Make the next count open attempts fail, to model a busy device.
std::vector< MidiPortInfo > enumerate_inputs () override
std::vector< MidiPortInfo > enumerate_outputs () override
std::unique_ptr< MidiInput > create_input () override
std::unique_ptr< MidiOutput > create_output () override
void set_port_change_callback (PortChangeCallback cb) override

Member Typedef Documentation

◆ PortChangeCallback

using pulp::midi::MidiSystem::PortChangeCallback = std::function<void()>
inherited

Register a callback for MIDI port changes (device plug/unplug).

The callback may fire on an OS thread. Pass nullptr to unregister.

Member Function Documentation

◆ add_port()

void pulp::midi::MockMidiSystem::add_port ( const std::string & id,
const std::string & name,
bool is_input = true )
inline

Add (or replace) a port and notify the port-change callback.

◆ create_input()

std::unique_ptr< MidiInput > pulp::midi::MockMidiSystem::create_input ( )
inlineoverridevirtual

◆ create_output()

std::unique_ptr< MidiOutput > pulp::midi::MockMidiSystem::create_output ( )
inlineoverridevirtual

◆ drop_connections()

void pulp::midi::MockMidiSystem::drop_connections ( const std::string & id)
inline

Sever the connection of every open input on id while the port stays listed, as when an OS replaces an endpoint behind a still-present name (a device that vanished and returned across a sleep).

The inputs then report is_open() == false.

◆ enumerate_inputs()

std::vector< MidiPortInfo > pulp::midi::MockMidiSystem::enumerate_inputs ( )
inlineoverridevirtual

◆ enumerate_outputs()

std::vector< MidiPortInfo > pulp::midi::MockMidiSystem::enumerate_outputs ( )
inlineoverridevirtual

◆ fail_next_opens()

void pulp::midi::MockMidiSystem::fail_next_opens ( int count)
inline

Make the next count open attempts fail, to model a busy device.

◆ inject()

int pulp::midi::MockMidiSystem::inject ( const std::string & id,
const MidiEvent & event )
inline

Deliver event to every open input on id. Returns how many received it.

◆ notify()

void pulp::midi::MockMidiSystem::notify ( )
inline

◆ open_input_count()

int pulp::midi::MockMidiSystem::open_input_count ( const std::string & id) const
inline

Number of currently open inputs on id.

◆ remove_port()

void pulp::midi::MockMidiSystem::remove_port ( const std::string & id,
bool is_input = true )
inline

Remove a port and notify the port-change callback.

◆ set_port_change_callback()

void pulp::midi::MockMidiSystem::set_port_change_callback ( PortChangeCallback cb)
inlineoverridevirtual

Reimplemented from pulp::midi::MidiSystem.

◆ set_ports_silently()

void pulp::midi::MockMidiSystem::set_ports_silently ( std::vector< MidiPortInfo > ports)
inline

Change the port list without notifying, to model a notification that never arrived.

Call notify() or refresh the consumer afterwards.

◆ total_opens()

int pulp::midi::MockMidiSystem::total_opens ( ) const
inline

Total successful input opens since construction.


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