diff options
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r-- | gtk2_ardour/utils.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index eb370be0dc..00e94b0dd9 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -28,6 +28,7 @@ #include <clocale> #include <cstring> #include <cctype> +#include <cmath> #include <fstream> #include <list> #include <sys/stat.h> @@ -843,3 +844,15 @@ unique_random_color (list<Gdk::Color>& used_colors) /* XXX need throttle here to make sure we don't spin for ever */ } } + +string +rate_as_string (float r) +{ + char buf[32]; + if (fmod (r, 1000.0f)) { + snprintf (buf, sizeof (buf), "%.1f kHz", r/1000.0); + } else { + snprintf (buf, sizeof (buf), "%.0f kHz", r/1000.0); + } + return buf; +} |