diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-23 21:35:17 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-23 21:35:17 -0400 |
commit | cff174b5417d9b242673588792d390db9f61ca93 (patch) | |
tree | ceb2af2d957165ec10b77e3828c83b501d0804a8 /gtk2_ardour/utils.cc | |
parent | 884789bfadddadcda49cef603a754f8e12e911a6 (diff) |
move rate_as_string() from EngineControl to utils.cc
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 c81aff85ab..a0fd7016b5 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> @@ -860,3 +861,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; +} |