X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fvalue_as_string.h;h=9e042b78fa2acf39d9420cfcbe715d17ef52b3d4;hb=d04ca6d4149b602a193da8fbb88c03fef94f9e5d;hp=6c17ace5d3baba3f0140ae99e684701ab193a47c;hpb=47c4929bc285da6d752e68aa5a32cf73f20b9f22;p=ardour.git diff --git a/libs/ardour/ardour/value_as_string.h b/libs/ardour/ardour/value_as_string.h index 6c17ace5d3..9e042b78fa 100644 --- a/libs/ardour/ardour/value_as_string.h +++ b/libs/ardour/ardour/value_as_string.h @@ -46,22 +46,15 @@ value_as_string(const ARDOUR::ParameterDescriptor& desc, // Value is not a scale point, print it normally if (desc.unit == ARDOUR::ParameterDescriptor::MIDI_NOTE) { - if (v >= 0 && v <= 127) { - const int num = rint(v); - static const char names[12][3] = { - "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" - }; - snprintf(buf, sizeof(buf), "%s %d", names[num % 12], (num / 12) - 2); - } else { - // Odd, invalid range, just print the number - snprintf(buf, sizeof(buf), "%.0f", v); - } + snprintf(buf, sizeof(buf), "%s", ParameterDescriptor::midi_note_name (rint(v)).c_str()); + } else if (!desc.print_fmt.empty()) { + snprintf(buf, sizeof(buf), desc.print_fmt.c_str(), v); } else if (desc.integer_step) { snprintf(buf, sizeof(buf), "%d", (int)v); } else { - snprintf(buf, sizeof(buf), "%.2f", v); + snprintf(buf, sizeof(buf), "%.3f", v); } - if (desc.unit == ARDOUR::ParameterDescriptor::DB) { + if (desc.print_fmt.empty() && desc.unit == ARDOUR::ParameterDescriptor::DB) { // TODO: Move proper dB printing from AutomationLine here return std::string(buf) + " dB"; }