X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=midi_mapper.cpp;h=6ce50302eec560f77472cc4c372e68fd8cdd547c;hb=refs%2Fheads%2Fmultichannel_audio;hp=8f43d21bc0de569ecf5d5ad28dcae765bca82cc8;hpb=7c1bb8357495778076a47636c2c4192674034165;p=nageru diff --git a/midi_mapper.cpp b/midi_mapper.cpp index 8f43d21..6ce5030 100644 --- a/midi_mapper.cpp +++ b/midi_mapper.cpp @@ -1,18 +1,25 @@ #include "midi_mapper.h" -#include "audio_mixer.h" -#include "midi_mapping.pb.h" - #include -#include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include - +#include +#include #include #include +#include "audio_mixer.h" +#include "midi_mapping.pb.h" + using namespace google::protobuf; using namespace std; using namespace std::placeholders; @@ -38,14 +45,16 @@ MIDIMapper::MIDIMapper(ControllerReceiver *receiver) { should_quit_fd = eventfd(/*initval=*/0, /*flags=*/0); assert(should_quit_fd != -1); - refresh_highlights(); } MIDIMapper::~MIDIMapper() { should_quit = true; const uint64_t one = 1; - write(should_quit_fd, &one, sizeof(one)); + if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { + perror("write(should_quit_fd)"); + exit(1); + } midi_thread.join(); close(should_quit_fd); } @@ -240,8 +249,6 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) lock_guard lock(mu); switch (event->type) { case SND_SEQ_EVENT_CONTROLLER: { - printf("Controller %d changed to %d\n", event->data.control.param, event->data.control.value); - const int controller = event->data.control.param; const float value = map_controller_to_float(event->data.control.value); @@ -275,8 +282,6 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) receiver->note_on(note); - printf("Note: %d\n", note); - for (size_t bus_idx = 0; bus_idx < size_t(mapping_proto->bus_mapping_size()); ++bus_idx) { const MIDIMappingBusProto &bus_mapping = mapping_proto->bus_mapping(bus_idx); if (bus_mapping.has_prev_bank() && @@ -341,6 +346,7 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) bind(&ControllerReceiver::toggle_limiter, receiver)); match_button(note, MIDIMappingBusProto::kToggleAutoMakeupGainFieldNumber, MIDIMappingProto::kToggleAutoMakeupGainBankFieldNumber, bind(&ControllerReceiver::toggle_auto_makeup_gain, receiver)); + break; } case SND_SEQ_EVENT_PORT_START: subscribe_to_port_lock_held(seq, event->data.addr);