X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmidi_mapper.cpp;h=d111a7a650dab499c7102f7e37e75a3663a10ffa;hb=2c9a83aeae44dae6a0bbfbae33719976e6d527af;hp=59637b1d24107473893f8487227c270942a19058;hpb=09f6cb41070d746115bbb4ca12325622b564c025;p=nageru diff --git a/nageru/midi_mapper.cpp b/nageru/midi_mapper.cpp index 59637b1..d111a7a 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); @@ -327,19 +312,6 @@ void MIDIMapper::update_highlights() } } -// Find what MIDI note the given light (as given by field_number) is mapped to, and enable it. -void activate_mapped_light(const MIDIMappingBusProto &bus_mapping, int field_number, set *active_lights) -{ - const FieldDescriptor *descriptor = bus_mapping.GetDescriptor()->FindFieldByNumber(field_number); - const Reflection *bus_reflection = bus_mapping.GetReflection(); - if (!bus_reflection->HasField(bus_mapping, descriptor)) { - return; - } - const MIDILightProto &light_proto = - static_cast(bus_reflection->GetMessage(bus_mapping, descriptor)); - active_lights->insert(light_proto.note_number()); -} - void MIDIMapper::update_lights_lock_held() { if (global_audio_mixer == nullptr) {