#include <buttons.hh>
A class for managing MIDI buttons.
Public Member Functions | |
Buttons (string output_device_name) | |
void | init () |
void | update () |
Buttons & | on (unsigned char id) |
Buttons & | on (unsigned char id, unsigned char color) |
Buttons & | off (unsigned char id) |
Buttons & | blink_on (int id, double period) |
Buttons & | blink_off (int id) |
Buttons & | momentary (int id, function< void(const Event &)> handler, int type=MIDI_KEYDOWN) |
Buttons & | mutex (vector< int > ids, vector< function< void(const Event &)> > handlers) |
Buttons & | toggle (int id, function< void(const Event &)> handler, bool init_on) |
Buttons & | send (std::vector< unsigned char > msg) |
void | set (int id, BUTTON_STATE state) |
map< int, BUTTON_STATE > | get_states () |
void | set_states (map< int, BUTTON_STATE > states) |
void | clear_leds () |
Turn off all the currently illuminated LEDs. | |
![]() | |
EventManager () | |
Make a new event manager. | |
void | process_events (vector< Module * > &modules) |
void | respond_to (const Event &event) |
EventManager & | listen (int event_type, function< void(const Event &)> handler) |
EventManager & | listen (int event_type, int port, function< void(const Event &)> handler) |
![]() | |
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 () |
yase::Buttons::Buttons | ( | string | device_name | ) |
Constructor for a new Buttons object.
device_name | The name of the MIDI device who's buttons should be be used. |
Buttons & yase::Buttons::blink_off | ( | int | id | ) |
Stop a button blinking
id | The MIDI id of the button |
Buttons & yase::Buttons::blink_on | ( | int | id, |
double | period | ||
) |
Set a button blinking.
id | The MIDI id of the button |
period | The period in seconds |
|
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.
Buttons & yase::Buttons::momentary | ( | int | id, |
function< void(const Event &)> | handler, | ||
int | type = MIDI_KEYDOWN |
||
) |
Associate a button with an method to run when the button is pressed. The LED of the button is illumiated momentarily. For example
id | The MIDI id of the button |
handler | The method to run |
Buttons & yase::Buttons::mutex | ( | vector< int > | ids, |
vector< function< void(const Event &)> > | handlers | ||
) |
Associate a set of buttons with a set of method to run when the associated button is pressed. The LED of the most recently pressed button is For example
id | The MIDI id of the button |
handler | The method to run |
Buttons & yase::Buttons::off | ( | unsigned char | id | ) |
Turn a button off, unilluminating it's LED
id | The MIDI id of the button |
Buttons & yase::Buttons::on | ( | unsigned char | id | ) |
Turn a button on, illuminating it's LED
id | The MIDI id of the button |
Buttons & yase::Buttons::on | ( | unsigned char | id, |
unsigned char | color | ||
) |
Turn a button on, illuminating it's LED
id | The MIDI id of the button |
void yase::Buttons::set | ( | int | id, |
BUTTON_STATE | state | ||
) |
Set a button's state.
id | The MIDI id of the button |
state | The desired state of the button |
Set up a toggle button. When it is pressed, the method is run and the led is illumated (unless init_on is true). When it is pressed again, the LED is turned off.
id | The midi id of the button |
handler | The function to call when the button is pressed |
init_on | Whether the led for the button is initially on or off |
|
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.