Use samples_as_time_string API

This commit is contained in:
Robin Gareus 2019-09-29 02:43:06 +02:00
parent b3a20c7626
commit 24aa61f08c
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 5 additions and 21 deletions

View File

@ -33,6 +33,7 @@
#include "gtkmm2ext/utils.h"
#include "latency_gui.h"
#include "utils.h"
#include "pbd/i18n.h"
@ -54,17 +55,8 @@ std::vector<std::string> LatencyGUI::unit_strings;
std::string
LatencyBarController::get_label (double&)
{
double const nframes = _latency_gui->adjustment.get_value();
std::stringstream s;
if (nframes < (_latency_gui->sample_rate / 1000.0)) {
const samplepos_t nf = (samplepos_t) rint (nframes);
s << string_compose (P_("%1 sample", "%1 samples", nf), nf);
} else {
s << std::fixed << std::setprecision (2) << (nframes / (_latency_gui->sample_rate / 1000.0)) << " ms";
}
return s.str ();
return ARDOUR_UI_UTILS::samples_as_time_string (
_latency_gui->adjustment.get_value(), _latency_gui->sample_rate, true);
}
LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz)

View File

@ -582,17 +582,9 @@ void
PlugUIBase::set_latency_label ()
{
samplecnt_t const l = insert->effective_latency ();
samplecnt_t const sr = insert->session().sample_rate ();
float const sr = insert->session().sample_rate ();
string t;
if (l < sr / 1000) {
t = string_compose (P_("%1 sample", "%1 samples", l), l);
} else {
t = string_compose (_("%1 ms"), (float) l / ((float) sr / 1000.0f));
}
latency_button.set_text (t);
latency_button.set_text (samples_as_time_string (l, sr, true));
}
void