Use samples_as_time_string API
This commit is contained in:
parent
b3a20c7626
commit
24aa61f08c
|
@ -33,6 +33,7 @@
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
|
||||||
#include "latency_gui.h"
|
#include "latency_gui.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
|
@ -54,17 +55,8 @@ std::vector<std::string> LatencyGUI::unit_strings;
|
||||||
std::string
|
std::string
|
||||||
LatencyBarController::get_label (double&)
|
LatencyBarController::get_label (double&)
|
||||||
{
|
{
|
||||||
double const nframes = _latency_gui->adjustment.get_value();
|
return ARDOUR_UI_UTILS::samples_as_time_string (
|
||||||
std::stringstream s;
|
_latency_gui->adjustment.get_value(), _latency_gui->sample_rate, true);
|
||||||
|
|
||||||
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 ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz)
|
LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz)
|
||||||
|
|
|
@ -582,17 +582,9 @@ void
|
||||||
PlugUIBase::set_latency_label ()
|
PlugUIBase::set_latency_label ()
|
||||||
{
|
{
|
||||||
samplecnt_t const l = insert->effective_latency ();
|
samplecnt_t const l = insert->effective_latency ();
|
||||||
samplecnt_t const sr = insert->session().sample_rate ();
|
float const sr = insert->session().sample_rate ();
|
||||||
|
|
||||||
string t;
|
latency_button.set_text (samples_as_time_string (l, sr, true));
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user