Add method to format set of MIDI channels
eg. channels 1,2,3,5,6 will be formatted as "1-3, 5, 6"
This commit is contained in:
parent
12e8235193
commit
ef8904210e
|
@ -801,6 +801,51 @@ ARDOUR_UI_UTILS::samples_as_time_string (samplecnt_t s, float rate, bool show_sa
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
ARDOUR_UI_UTILS::midi_channels_as_string (std::set<uint8_t> const& channels)
|
||||||
|
{
|
||||||
|
if (channels.empty ()) {
|
||||||
|
return _("none");
|
||||||
|
}
|
||||||
|
|
||||||
|
string rv;
|
||||||
|
auto i = channels.begin ();
|
||||||
|
|
||||||
|
uint8_t next = *i;
|
||||||
|
uint8_t prev = next;
|
||||||
|
rv += to_string<int> (next + 1);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (*i == next) {
|
||||||
|
++i;
|
||||||
|
++next;
|
||||||
|
if (i != channels.end ()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (next - prev > 2) {
|
||||||
|
rv += "-";
|
||||||
|
rv += to_string<int> (next);
|
||||||
|
} else if (next - prev > 1) {
|
||||||
|
rv += ", ";
|
||||||
|
rv += to_string<int> (next);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == channels.end ()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv += ", ";
|
||||||
|
rv += to_string<int> (*i + 1);
|
||||||
|
|
||||||
|
prev = *i;
|
||||||
|
next = prev + 1;
|
||||||
|
++i;
|
||||||
|
} while (i != channels.end ());
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ARDOUR_UI_UTILS::windows_overlap (Gtk::Window *a, Gtk::Window *b)
|
ARDOUR_UI_UTILS::windows_overlap (Gtk::Window *a, Gtk::Window *b)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,6 +103,8 @@ Gdk::Color unique_random_color (std::list<Gdk::Color> &);
|
||||||
std::string rate_as_string (float r);
|
std::string rate_as_string (float r);
|
||||||
std::string samples_as_time_string (ARDOUR::samplecnt_t s, float r, bool show_samples = false);
|
std::string samples_as_time_string (ARDOUR::samplecnt_t s, float r, bool show_samples = false);
|
||||||
|
|
||||||
|
std::string midi_channels_as_string (std::set<uint8_t> const&);
|
||||||
|
|
||||||
bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
|
bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
|
||||||
|
|
||||||
bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
|
bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user