break out AudioClock::print_minsec() so that AudioClock and VerboseCursor can use the same formatting code.
This commit is contained in:
parent
a2294aa0ff
commit
eab61cbafe
|
@ -1100,15 +1100,43 @@ AudioClock::set_frames (framepos_t when, bool /*force*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioClock::set_minsec (framepos_t when, bool /*force*/)
|
AudioClock::print_minsec (framepos_t when, char* buf, size_t bufsize, float frame_rate)
|
||||||
{
|
{
|
||||||
char buf[32];
|
|
||||||
framecnt_t left;
|
framecnt_t left;
|
||||||
int hrs;
|
int hrs;
|
||||||
int mins;
|
int mins;
|
||||||
int secs;
|
int secs;
|
||||||
int millisecs;
|
int millisecs;
|
||||||
bool negative = false;
|
bool negative;
|
||||||
|
|
||||||
|
if (when < 0) {
|
||||||
|
when = -when;
|
||||||
|
negative = true;
|
||||||
|
} else {
|
||||||
|
negative = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
left = when;
|
||||||
|
hrs = (int) floor (left / (frame_rate * 60.0f * 60.0f));
|
||||||
|
left -= (framecnt_t) floor (hrs * frame_rate * 60.0f * 60.0f);
|
||||||
|
mins = (int) floor (left / (frame_rate * 60.0f));
|
||||||
|
left -= (framecnt_t) floor (mins * frame_rate * 60.0f);
|
||||||
|
secs = (int) floor (left / (float) frame_rate);
|
||||||
|
left -= (framecnt_t) floor ((double)(secs * frame_rate));
|
||||||
|
millisecs = floor (left * 1000.0 / (float) frame_rate);
|
||||||
|
|
||||||
|
if (negative) {
|
||||||
|
snprintf (buf, bufsize, "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
|
||||||
|
} else {
|
||||||
|
snprintf (buf, bufsize, " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioClock::set_minsec (framepos_t when, bool /*force*/)
|
||||||
|
{
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
if (_off) {
|
if (_off) {
|
||||||
_layout->set_text (" --:--:--.---");
|
_layout->set_text (" --:--:--.---");
|
||||||
|
@ -1121,25 +1149,7 @@ AudioClock::set_minsec (framepos_t when, bool /*force*/)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (when < 0) {
|
print_minsec (when, buf, sizeof (buf), _session->frame_rate());
|
||||||
when = -when;
|
|
||||||
negative = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
left = when;
|
|
||||||
hrs = (int) floor (left / (_session->frame_rate() * 60.0f * 60.0f));
|
|
||||||
left -= (framecnt_t) floor (hrs * _session->frame_rate() * 60.0f * 60.0f);
|
|
||||||
mins = (int) floor (left / (_session->frame_rate() * 60.0f));
|
|
||||||
left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f);
|
|
||||||
secs = (int) floor (left / (float) _session->frame_rate());
|
|
||||||
left -= (framecnt_t) floor ((double)(secs * _session->frame_rate()));
|
|
||||||
millisecs = floor (left * 1000.0 / (float) _session->frame_rate());
|
|
||||||
|
|
||||||
if (negative) {
|
|
||||||
snprintf (buf, sizeof (buf), "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
|
|
||||||
} else {
|
|
||||||
snprintf (buf, sizeof (buf), " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
|
|
||||||
}
|
|
||||||
|
|
||||||
_layout->set_text (buf);
|
_layout->set_text (buf);
|
||||||
set_slave_info();
|
set_slave_info();
|
||||||
|
|
|
@ -77,6 +77,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||||
void set_session (ARDOUR::Session *s);
|
void set_session (ARDOUR::Session *s);
|
||||||
void set_negative_allowed (bool yn);
|
void set_negative_allowed (bool yn);
|
||||||
|
|
||||||
|
static void print_minsec (framepos_t, char* buf, size_t bufsize, float frame_rate);
|
||||||
|
|
||||||
sigc::signal<void> ValueChanged;
|
sigc::signal<void> ValueChanged;
|
||||||
sigc::signal<void> mode_changed;
|
sigc::signal<void> mode_changed;
|
||||||
sigc::signal<void> ChangeAborted;
|
sigc::signal<void> ChangeAborted;
|
||||||
|
|
|
@ -98,9 +98,6 @@ VerboseCursor::set_time (framepos_t frame)
|
||||||
char buf[128];
|
char buf[128];
|
||||||
Timecode::Time timecode;
|
Timecode::Time timecode;
|
||||||
Timecode::BBT_Time bbt;
|
Timecode::BBT_Time bbt;
|
||||||
int hours, mins;
|
|
||||||
framepos_t frame_rate;
|
|
||||||
float secs;
|
|
||||||
|
|
||||||
if (_editor->_session == 0) {
|
if (_editor->_session == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -122,14 +119,7 @@ VerboseCursor::set_time (framepos_t frame)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AudioClock::MinSec:
|
case AudioClock::MinSec:
|
||||||
/* XXX this is copied from show_verbose_duration_cursor() */
|
AudioClock::print_minsec (frame, buf, sizeof (buf), _editor->_session->frame_rate());
|
||||||
frame_rate = _editor->_session->frame_rate();
|
|
||||||
hours = frame / (frame_rate * 3600);
|
|
||||||
frame = frame % (frame_rate * 3600);
|
|
||||||
mins = frame / (frame_rate * 60);
|
|
||||||
frame = frame % (frame_rate * 60);
|
|
||||||
secs = (float) frame / (float) frame_rate;
|
|
||||||
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -147,9 +137,7 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end)
|
||||||
Timecode::Time timecode;
|
Timecode::Time timecode;
|
||||||
Timecode::BBT_Time sbbt;
|
Timecode::BBT_Time sbbt;
|
||||||
Timecode::BBT_Time ebbt;
|
Timecode::BBT_Time ebbt;
|
||||||
int hours, mins;
|
framepos_t frame_rate;
|
||||||
framepos_t distance, frame_rate;
|
|
||||||
float secs;
|
|
||||||
Meter meter_at_start (_editor->_session->tempo_map().meter_at(start));
|
Meter meter_at_start (_editor->_session->tempo_map().meter_at(start));
|
||||||
|
|
||||||
if (_editor->_session == 0) {
|
if (_editor->_session == 0) {
|
||||||
|
@ -201,15 +189,7 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AudioClock::MinSec:
|
case AudioClock::MinSec:
|
||||||
/* XXX this stuff should be elsewhere.. */
|
AudioClock::print_minsec (end - start, buf, sizeof (buf), _editor->_session->frame_rate());
|
||||||
distance = end - start;
|
|
||||||
frame_rate = _editor->_session->frame_rate();
|
|
||||||
hours = distance / (frame_rate * 3600);
|
|
||||||
distance = distance % (frame_rate * 3600);
|
|
||||||
mins = distance / (frame_rate * 60);
|
|
||||||
distance = distance % (frame_rate * 60);
|
|
||||||
secs = (float) distance / (float) frame_rate;
|
|
||||||
snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user