X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmidi_mapper.cpp;h=d0a42ec60274e05c00d98ad528162ad3519c5b94;hb=f9a11c73b0c2ff2d44d79f856998f8cbfc88a478;hp=7457fbb53f99082a292c5c8699e6fd01e28fd103;hpb=c7627f3f46ca3ec755e301dde2fca2f6e244f64d;p=nageru diff --git a/nageru/midi_mapper.cpp b/nageru/midi_mapper.cpp index 7457fbb..d0a42ec 100644 --- a/nageru/midi_mapper.cpp +++ b/nageru/midi_mapper.cpp @@ -19,7 +19,8 @@ #include #include "audio_mixer.h" -#include "midi_mapping.pb.h" +#include "nageru_midi_mapping.pb.h" +#include "shared/midi_device.h" #include "shared/midi_mapper_util.h" #include "shared/text_proto.h" @@ -27,22 +28,6 @@ using namespace google::protobuf; using namespace std; using namespace std::placeholders; -namespace { - -double map_controller_to_float(int val) -{ - // Slightly hackish mapping so that we can represent exactly 0.0, 0.5 and 1.0. - if (val <= 0) { - return 0.0; - } else if (val >= 127) { - return 1.0; - } else { - return (val + 0.5) / 127.0; - } -} - -} // namespace - MIDIMapper::MIDIMapper(ControllerReceiver *receiver) : receiver(receiver), mapping_proto(new MIDIMappingProto), midi_device(this) { @@ -96,7 +81,7 @@ ControllerReceiver *MIDIMapper::set_receiver(ControllerReceiver *new_receiver) void MIDIMapper::controller_received(int controller, int value_int) { - const float value = map_controller_to_float(value_int); + const float value = map_controller_to_float(controller, value_int); receiver->controller_changed(controller); @@ -333,7 +318,7 @@ void MIDIMapper::update_lights_lock_held() return; } - set active_lights; // Desired state. + map active_lights; // Desired state. if (current_controller_bank == 0) { activate_lights_all_buses(MIDIMappingBusProto::kBank1IsSelectedFieldNumber, &active_lights); } @@ -378,7 +363,7 @@ void MIDIMapper::update_lights_lock_held() midi_device.update_lights(active_lights); } -void MIDIMapper::activate_lights_all_buses(int field_number, set *active_lights) +void MIDIMapper::activate_lights_all_buses(int field_number, map *active_lights) { 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);