diff --git a/include/math.hpp b/include/math.hpp index f35d3440..9fc9ffe7 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -70,10 +70,13 @@ inline float nearf(float a, float b, float epsilon = 1e-6) { } /** Limits a value between a minimum and maximum -If min > max, returns min +If min > max, clamps the range to [max, min] */ inline float clampf(float x, float min, float max) { - return fmaxf(fminf(x, max), min); + if (min <= max) + return fmaxf(fminf(x, max), min); + else + return fmaxf(fminf(x, min), max); } /** If the magnitude of x if less than eps, return 0 */ diff --git a/include/midi.hpp b/include/midi.hpp index c1e70cbd..aff1c143 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -43,6 +43,7 @@ struct MidiIO { struct MidiInput : MidiIO { + RtMidiIn *rtMidiIn = NULL; MidiInput(); ~MidiInput(); virtual void onMessage(const MidiMessage &message) {} @@ -56,6 +57,7 @@ struct MidiInputQueue : MidiInput { struct MidiOutput : MidiIO { + RtMidiOut *rtMidiOut = NULL; MidiOutput(); ~MidiOutput(); }; diff --git a/src/app/RackScene.cpp b/src/app/RackScene.cpp index 417e3b16..5ae0fbc5 100644 --- a/src/app/RackScene.cpp +++ b/src/app/RackScene.cpp @@ -11,6 +11,8 @@ namespace rack { static std::string newVersion = ""; + +#if defined(RELEASE) static void checkVersion() { json_t *resJ = requestJson(METHOD_GET, gApiHost + "/version", NULL); @@ -25,6 +27,7 @@ static void checkVersion() { json_decref(resJ); } } +#endif RackScene::RackScene() { diff --git a/src/midi.cpp b/src/midi.cpp index 1fb6ae05..7f367fec 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -43,13 +43,13 @@ bool MidiIO::isActive() { json_t *MidiIO::toJson() { json_t *rootJ = json_object(); std::string deviceName = getDeviceName(device); - json_object_set_new(rootJ, "device", json_string(deviceName.c_str())); + json_object_set_new(rootJ, "deviceName", json_string(deviceName.c_str())); json_object_set_new(rootJ, "channel", json_integer(channel)); return rootJ; } void MidiIO::fromJson(json_t *rootJ) { - json_t *deviceNameJ = json_object_get(rootJ, "device"); + json_t *deviceNameJ = json_object_get(rootJ, "deviceName"); if (deviceNameJ) { std::string deviceName = json_string_value(deviceNameJ); // Search for device with equal name @@ -83,13 +83,13 @@ static void midiInputCallback(double timeStamp, std::vector *mess } MidiInput::MidiInput() { - RtMidiIn *rtMidiIn = new RtMidiIn(); + rtMidiIn = new RtMidiIn(); rtMidi = rtMidiIn; rtMidiIn->setCallback(midiInputCallback, this); } MidiInput::~MidiInput() { - delete dynamic_cast(rtMidi); + delete rtMidiIn; } void MidiInputQueue::onMessage(const MidiMessage &message) { @@ -107,11 +107,12 @@ void MidiInputQueue::onMessage(const MidiMessage &message) { //////////////////// MidiOutput::MidiOutput() { - rtMidi = new RtMidiOut(); + rtMidiOut = new RtMidiOut(); + rtMidi = rtMidiOut; } MidiOutput::~MidiOutput() { - delete dynamic_cast(rtMidi); + delete rtMidiOut; } diff --git a/src/widgets/Menu.cpp b/src/widgets/Menu.cpp index 973362fd..91a849f0 100644 --- a/src/widgets/Menu.cpp +++ b/src/widgets/Menu.cpp @@ -54,7 +54,7 @@ void Menu::onScroll(EventScroll &e) { if (!parent) return; if (!parent->box.contains(box)) - box.pos = box.pos.plus(e.scrollRel); + box.pos.y += e.scrollRel.y; e.consumed = true; } diff --git a/src/widgets/MenuOverlay.cpp b/src/widgets/MenuOverlay.cpp index 85665b66..21453a0d 100644 --- a/src/widgets/MenuOverlay.cpp +++ b/src/widgets/MenuOverlay.cpp @@ -9,7 +9,7 @@ void MenuOverlay::step() { // Fit all children in the box for (Widget *child : children) { - child->box = child->box.nudge(Rect(Vec(0, 0), parent->box.size)); + child->box = child->box.nudge(box.zeroPos()); } }