Yet Another Synthesizer Engine
 
Loading...
Searching...
No Matches
yase::MidiInput Class Reference

#include <midi_input.hh>

+ Inheritance diagram for yase::MidiInput:
+ Collaboration diagram for yase::MidiInput:

Detailed Description

A Midi Input manager.

Add one of these to your container for each Midi device you are using. Any MIDI Event received from that device will be sent to the containing Module. For example

Container container;
MidiInput keyboard("My keyboard make/model");
container.add(keyboard);
container.listen(MIDI_KEYDOWN, keyboard.port(), [&] (const Event &e) {
std::cout << "You pressed the key associated with MIDI id " << e.id() << "\n";
});
A module and event manager that can contain other modules.
Definition container.hh:63
Container & add(Module &module)
Definition container.cc:62
Contains MIDI event information.
Definition event.hh:32
A Midi Input manager.
Definition midi_input.hh:48
#define MIDI_KEYDOWN
A key press.
Definition globals.hh:46

This class is a YASE wrapper of RTMidi (https://www.music.mcgill.ca/~gary/rtmidi/).

Public Member Functions

 MidiInput (string device_name)
 
void init ()
 
void update ()
 
int port ()
 
- Public Member Functions inherited from yase::Module
virtual void init ()=0
 
virtual void update ()=0
 
int add_input (string name)
 
int add_output (string name)
 
int get_input_index (string name) const
 
string get_input_name (int index) const
 
string get_output_name (int index) const
 
int get_output_index (string name) const
 
void set_input (string name, double value)
 
void set_input (int index, double value)
 
double get_input (int index) const
 
double get_input (string name) const
 
double get_output (string name) const
 
double get_output (int index) const
 
void set_output (int index, double value)
 
void copy_inputs (const Module &source)
 
void copy_outputs (Module &destination) const
 
void configure (std::vector< std::tuple< string, double > > assignments)
 
int num_inputs () const
 
int num_outputs () const
 
void emit (Event e)
 
void set_ts (double s)
 
double get_ts ()
 

Constructor & Destructor Documentation

◆ MidiInput()

yase::MidiInput::MidiInput ( string  device_name)

Construct a new MidiInput object. When constructed, the object will attempt to find the Midi Device connected to your computer with the given name. If it cannot, it will throw an exception.

Parameters
device_nameThe name of the device

Member Function Documentation

◆ init()

void yase::MidiInput::init ( )
virtual

This method should be overridden by derived classes. It will usually be called once, after all modules and connections objects have been added to a synthesizer, but before the synthesizer starts running.

Implements yase::Module.

◆ port()

int yase::MidiInput::port ( )
inline

Return the MIDI port of the device. This is needed in listeners to distinguish among MidiInput objects when there are more than one.

◆ update()

void yase::MidiInput::update ( )
virtual

This method should be overridden by derived classes. It will be called repeatedly by a synthesizer at a frequency determined by SAMPLE_RATE.

Implements yase::Module.


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