#include <lvtk/gtkui.hpp>
#include "beep.h"
using namespace sigc;
using namespace Gtk;
struct midi_t {
LV2_Atom atom;
uint8_t midi[3];
};
class BeepGUI :
public lvtk::UI<BeepGUI, lvtk::GtkUI<true>, lvtk::URID<true> > {
public:
BeepGUI(const char* URI) : m_button("Click me!")
{
m_button.signal_pressed().connect(
mem_fun(*this, &BeepGUI::send_note_on));
m_button.signal_released().connect(
mem_fun(*this, &BeepGUI::send_note_off));
add (m_button);
}
protected:
void send_note_on()
{
LV2_URID xfer = map(LV2_ATOM__eventTransfer);
LV2_URID midiEvent = map(LV2_MIDI__MidiEvent);
midi_t midi = {{3, midiEvent}, { 0x90, 0x40, 0x40 }};
write (p_midi, sizeof(midi), xfer, (void*)&midi);
}
void send_note_off()
{
LV2_URID xfer = map(LV2_ATOM__eventTransfer);
LV2_URID midiEvent = map(LV2_MIDI__MidiEvent);
midi_t midi = {{3, midiEvent},{ 0x80, 0x40, 0x40 }};
write (p_midi, sizeof(midi), xfer, (void*)&midi);
}
Button m_button;
};
static int _ = BeepGUI::register_class ("http://ll-plugins.nongnu.org/lv2/lv2pftci/beep/gui");