cs-midi/tests/examples/interfaces/send_midi_notes.cpp

28 lines
667 B
C++

#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <cs_midi.h>
using namespace cs;
BluetoothMIDI_Interface midi;
AH::Button pushbutton {5};
const MIDIAddress noteAddress {MIDI_Notes::C[4], Channel_1};
const uint8_t velocity = 0x7F;
int main() {
stdio_init_all();
if (cyw43_arch_init()) return 1;
pushbutton.begin();
midi.begin();
while (true) {
midi.update();
pushbutton.update();
if (pushbutton.getState() == AH::Button::Falling)
midi.sendNoteOn(noteAddress, velocity);
else if (pushbutton.getState() == AH::Button::Rising)
midi.sendNoteOff(noteAddress, velocity);
}
}