X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=midi_mapper.cpp;h=3b22192b3b8b0670356ebdb9230a8133777b0983;hb=refs%2Ftags%2F1.7.4;hp=a81979650d8b500b171fa9f71028ac3a1dcde778;hpb=ad9585b7a6671903cadcf6c74491646736db8e1e;p=nageru diff --git a/midi_mapper.cpp b/midi_mapper.cpp index a819796..3b22192 100644 --- a/midi_mapper.cpp +++ b/midi_mapper.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,8 @@ ControllerReceiver *MIDIMapper::set_receiver(ControllerReceiver *new_receiver) void MIDIMapper::thread_func() { + pthread_setname_np(pthread_self(), "MIDIMapper"); + snd_seq_t *seq; int err; @@ -229,6 +232,10 @@ void MIDIMapper::thread_func() if (err < 0) { if (err == -EINTR) continue; if (err == -EAGAIN) break; + if (err == -ENOSPC) { + fprintf(stderr, "snd_seq_event_input: Some events were lost.\n"); + continue; + } fprintf(stderr, "snd_seq_event_input: %s\n", snd_strerror(err)); return; } @@ -263,6 +270,8 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) value, bind(&ControllerReceiver::set_makeup_gain, receiver, _2)); // Bus controllers. + match_controller(controller, MIDIMappingBusProto::kStereoWidthFieldNumber, MIDIMappingProto::kStereoWidthBankFieldNumber, + value, bind(&ControllerReceiver::set_stereo_width, receiver, _1, _2)); match_controller(controller, MIDIMappingBusProto::kTrebleFieldNumber, MIDIMappingProto::kTrebleBankFieldNumber, value, bind(&ControllerReceiver::set_treble, receiver, _1, _2)); match_controller(controller, MIDIMappingBusProto::kMidFieldNumber, MIDIMappingProto::kMidBankFieldNumber, @@ -346,6 +355,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); @@ -382,8 +392,14 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) void MIDIMapper::subscribe_to_port_lock_held(snd_seq_t *seq, const snd_seq_addr_t &addr) { - // Client 0 is basically the system; ignore it. - if (addr.client == 0) { + // Client 0 (SNDRV_SEQ_CLIENT_SYSTEM) is basically the system; ignore it. + // MIDI through (SNDRV_SEQ_CLIENT_DUMMY) echoes back what we give it, so ignore that, too. + if (addr.client == 0 || addr.client == 14) { + return; + } + + // Don't listen to ourselves. + if (addr.client == snd_seq_client_id(seq)) { return; } @@ -529,6 +545,8 @@ void MIDIMapper::update_highlights() // Per-bus controllers. for (size_t bus_idx = 0; bus_idx < size_t(mapping_proto->bus_mapping_size()); ++bus_idx) { + receiver->highlight_stereo_width(bus_idx, has_active_controller( + bus_idx, MIDIMappingBusProto::kStereoWidthFieldNumber, MIDIMappingProto::kStereoWidthBankFieldNumber)); receiver->highlight_treble(bus_idx, has_active_controller( bus_idx, MIDIMappingBusProto::kTrebleFieldNumber, MIDIMappingProto::kTrebleBankFieldNumber)); receiver->highlight_mid(bus_idx, has_active_controller(