13
0

another in-progress snapshot of gtk2_ardour after getting audio_clock.cc to compile

This commit is contained in:
Paul Davis 2020-09-29 17:53:43 -06:00
parent 8fb70885ec
commit 1ee38e7a7f
14 changed files with 214 additions and 247 deletions

View File

@ -100,8 +100,6 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
, corner_radius (4)
, font_size (10240)
, editing (false)
, bbt_reference_time (-1)
, last_when(0)
, last_pdelta (0)
, last_sdelta (0)
, dragging (false)
@ -523,7 +521,7 @@ AudioClock::end_edit (bool modify)
if (is_duration) {
pos = sample_duration_from_bbt_string (bbt_reference_time, edit_string);
} else {
pos = samples_from_bbt_string (0, edit_string);
pos = samples_from_bbt_string (timepos_t(), edit_string);
}
break;
@ -540,7 +538,7 @@ AudioClock::end_edit (bool modify)
break;
}
AudioClock::set (pos, true);
AudioClock::set (timepos_t (pos), true);
_layout->set_attributes (normal_attributes);
ValueChanged(); /* EMIT_SIGNAL */
}
@ -571,31 +569,32 @@ AudioClock::drop_focus ()
}
}
samplecnt_t
timecnt_t
AudioClock::parse_as_seconds_distance (const std::string& str)
{
float f;
if (sscanf (str.c_str(), "%f", &f) == 1) {
return f * _session->sample_rate();
return timecnt_t (f * _session->sample_rate());
}
return 0;
return timecnt_t (samplecnt_t (0));
}
samplecnt_t
timecnt_t
AudioClock::parse_as_samples_distance (const std::string& str)
{
samplecnt_t f;
samplecnt_t samples = 0;
if (sscanf (str.c_str(), "%" PRId64, &f) == 1) {
return f;
if (sscanf (str.c_str(), "%" PRId64, &samples) == 1) {
return timecnt_t (samples);
}
return 0;
return timecnt_t (samples);
}
samplecnt_t
timecnt_t
AudioClock::parse_as_minsec_distance (const std::string& str)
{
samplecnt_t sr = _session->sample_rate();
@ -603,49 +602,57 @@ AudioClock::parse_as_minsec_distance (const std::string& str)
int secs;
int mins;
int hrs;
samplecnt_t samples = 0;
switch (str.length()) {
case 0:
return 0;
break;
case 1:
case 2:
case 3:
case 4:
sscanf (str.c_str(), "%" PRId32, &msecs);
return msecs * (sr / 1000);
samples = msecs * (sr / 1000);
break;
case 5:
sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &msecs);
return (secs * sr) + (msecs * (sr/1000));
samples = (secs * sr) + (msecs * (sr/1000));
break;
case 6:
sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &msecs);
return (secs * sr) + (msecs * (sr/1000));
samples = (secs * sr) + (msecs * (sr/1000));
break;
case 7:
sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
samples = (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
break;
case 8:
sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
samples = (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
break;
case 9:
sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
samples = (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
break;
case 10:
sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
samples = (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
break;
default:
break;
}
return 0;
return timecnt_t (samples);
}
samplecnt_t
timecnt_t
AudioClock::parse_as_timecode_distance (const std::string& str)
{
double fps = _session->timecode_frames_per_second();
@ -654,53 +661,61 @@ AudioClock::parse_as_timecode_distance (const std::string& str)
int secs;
int mins;
int hrs;
samplecnt_t ret = 0;
switch (str.length()) {
case 0:
return 0;
break;
case 1:
case 2:
sscanf (str.c_str(), "%" PRId32, &samples);
return llrint ((samples/(float)fps) * sr);
ret = llrint ((samples/(float)fps) * sr);
break;
case 3:
sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &samples);
return (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
case 4:
sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &samples);
return (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
case 5:
sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
case 6:
sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
case 7:
sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
case 8:
sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
ret = (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
break;
default:
break;
}
return 0;
return timecnt_t (ret);
}
samplecnt_t
timecnt_t
AudioClock::parse_as_bbt_distance (const std::string&)
{
return 0;
return timecnt_t ();
}
samplecnt_t
timecnt_t
AudioClock::parse_as_distance (const std::string& instr)
{
switch (_mode) {
@ -720,7 +735,7 @@ AudioClock::parse_as_distance (const std::string& instr)
return parse_as_seconds_distance (instr);
break;
}
return 0;
return timecnt_t();
}
void
@ -758,23 +773,23 @@ AudioClock::end_edit_relative (bool add)
return;
}
samplecnt_t samples = parse_as_distance (input_string);
timecnt_t distance = parse_as_distance (input_string);
editing = false;
editing = false;
_layout->set_attributes (normal_attributes);
if (samples != 0) {
if (!distance.zero()) {
if (add) {
AudioClock::set (current_time() + samples, true);
AudioClock::set (current_time() + timepos_t (distance), true);
} else {
samplepos_t c = current_time();
timepos_t c = current_time();
if (c > samples || _negative_allowed) {
AudioClock::set (c - samples, true);
if (c > timepos_t (distance)|| _negative_allowed) {
AudioClock::set (c.earlier (distance), true);
} else {
AudioClock::set (0, true);
AudioClock::set (timepos_t(), true);
}
}
ValueChanged (); /* EMIT SIGNAL */
@ -808,12 +823,12 @@ AudioClock::session_configuration_changed (std::string p)
return;
}
samplecnt_t current;
timepos_t current;
switch (_mode) {
case Timecode:
if (is_duration) {
current = current_duration ();
current = timepos_t (current_duration ());
} else {
current = current_time ();
}
@ -825,15 +840,17 @@ AudioClock::session_configuration_changed (std::string p)
}
void
AudioClock::set (samplepos_t when, bool force, samplecnt_t offset)
AudioClock::set (timepos_t const & w, bool force, timecnt_t const & offset)
{
if ((!force && !is_visible()) || _session == 0) {
timepos_t when (w);
if ((!force && !is_visible()) || _session) {
return;
}
_offset = offset;
if (is_duration) {
when = when - offset;
when = timepos_t (offset - when);
}
if (when > _limit_pos) {
@ -891,80 +908,13 @@ AudioClock::set (samplepos_t when, bool force, samplecnt_t offset)
}
}
finish_set (timepos_t (when), btn_en);
finish_set (when, btn_en);
}
void
AudioClock::set_duration (Temporal::timecnt_t const & d, bool force, Temporal::timecnt_t const & offset)
{
set_time (timepos_t (d), force, offset);
}
void
AudioClock::set_time (Temporal::timepos_t const & w, bool force, Temporal::timecnt_t const & offset)
{
Temporal::timepos_t when (w);
if ((!force && !is_visible()) || _session == 0) {
return;
}
if (is_duration) {
when = when.earlier (offset);
}
if (when > _limit_pos) {
when = _limit_pos;
} else if (when < -_limit_pos) {
when = -_limit_pos;
}
if (when == last_when && !force) {
#if 0 // XXX return if no change and no change forced. verify Aug/2014
if (_mode != Timecode && _mode != MinSec) {
/* may need to force display of TC source
* time, so don't return early.
*/
/* ^^ Why was that?, delta times?
* Timecode FPS, pull-up/down, etc changes
* trigger a 'session_property_changed' which
* eventually calls set(last_when, true)
*
* re-rendering the clock every 40ms or so just
* because we can is not ideal.
*/
return;
}
#else
return;
#endif
}
bool btn_en = false;
if (!editing) {
switch (_mode) {
case Timecode:
set_timecode (when.sample(), force);
break;
case BBT:
_set_bbt (when.bbt(), when.bbt() < Temporal::timepos_t (Temporal::BBT_Time()));
btn_en = true;
break;
case MinSec:
set_minsec (when.sample(), force);
break;
case Samples:
set_samples (when.sample(), force);
break;
}
}
finish_set (when, btn_en);
set (timepos_t (d), force, offset);
}
void
@ -1061,8 +1011,9 @@ AudioClock::set_out_of_bounds (bool negative)
}
void
AudioClock::set_samples (samplepos_t when, bool /*force*/)
AudioClock::set_samples (timepos_t const & w, bool /*force*/)
{
timepos_t when (w);
char buf[32];
bool negative = false;
@ -1073,7 +1024,7 @@ AudioClock::set_samples (samplepos_t when, bool /*force*/)
return;
}
if (when < 0) {
if (when.negative()) {
when = -when;
negative = true;
}
@ -1081,10 +1032,10 @@ AudioClock::set_samples (samplepos_t when, bool /*force*/)
if (when >= _limit_pos) {
set_out_of_bounds (negative);
} else if (negative) {
snprintf (buf, sizeof (buf), "-%10" PRId64, when);
snprintf (buf, sizeof (buf), "-%10" PRId64, when.samples());
_layout->set_text (buf);
} else {
snprintf (buf, sizeof (buf), " %10" PRId64, when);
snprintf (buf, sizeof (buf), " %10" PRId64, when.samples());
_layout->set_text (buf);
}
@ -1111,7 +1062,7 @@ AudioClock::set_samples (samplepos_t when, bool /*force*/)
}
void
AudioClock::set_seconds (samplepos_t when, bool /*force*/)
AudioClock::set_seconds (timepos_t const & when, bool /*force*/)
{
char buf[32];
@ -1123,12 +1074,12 @@ AudioClock::set_seconds (samplepos_t when, bool /*force*/)
}
if (when >= _limit_pos || when <= -_limit_pos) {
set_out_of_bounds (when < 0);
set_out_of_bounds (when.negative());
} else {
if (when < 0) {
snprintf (buf, sizeof (buf), "%12.1f", when / (float)_session->sample_rate());
if (when.negative()) {
snprintf (buf, sizeof (buf), "%12.1f", when.samples() / (float)_session->sample_rate());
} else {
snprintf (buf, sizeof (buf), " %11.1f", when / (float)_session->sample_rate());
snprintf (buf, sizeof (buf), " %11.1f", when.samples() / (float)_session->sample_rate());
}
_layout->set_text (buf);
}
@ -1194,7 +1145,7 @@ AudioClock::print_minsec (samplepos_t when, char* buf, size_t bufsize, float sam
}
void
AudioClock::set_minsec (samplepos_t when, bool /*force*/)
AudioClock::set_minsec (timepos_t const & when, bool /*force*/)
{
char buf[32];
@ -1207,9 +1158,9 @@ AudioClock::set_minsec (samplepos_t when, bool /*force*/)
}
if (when >= _limit_pos || when <= -_limit_pos) {
set_out_of_bounds (when < 0);
set_out_of_bounds (when.negative());
} else {
print_minsec (when, buf, sizeof (buf), _session->sample_rate());
print_minsec (when.samples(), buf, sizeof (buf), _session->sample_rate());
_layout->set_text (buf);
}
@ -1217,8 +1168,9 @@ AudioClock::set_minsec (samplepos_t when, bool /*force*/)
}
void
AudioClock::set_timecode (samplepos_t when, bool /*force*/)
AudioClock::set_timecode (timepos_t const & w, bool /*force*/)
{
timepos_t when (w);
Timecode::Time TC;
bool negative = false;
@ -1229,7 +1181,7 @@ AudioClock::set_timecode (samplepos_t when, bool /*force*/)
return;
}
if (when < 0) {
if (when.negative()) {
when = -when;
negative = true;
}
@ -1240,9 +1192,9 @@ AudioClock::set_timecode (samplepos_t when, bool /*force*/)
}
if (is_duration) {
_session->timecode_duration (when, TC);
_session->timecode_duration (when.samples(), TC);
} else {
_session->timecode_time (when, TC);
_session->timecode_time (when.samples(), TC);
}
TC.negative = TC.negative || negative;
@ -1253,8 +1205,10 @@ AudioClock::set_timecode (samplepos_t when, bool /*force*/)
}
void
AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
AudioClock::set_bbt (timepos_t const & w, timecnt_t const & o, bool /*force*/)
{
timepos_t when (w);
timecnt_t offset (o);
char buf[64];
Temporal::BBT_Time BBT;
bool negative = false;
@ -1266,22 +1220,24 @@ AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
return;
}
if (when < 0) {
if (when.negative()) {
when = -when;
negative = true;
}
/* handle a common case */
#warning NUTEMPO FIXME new tempo map API
#if 0
if (is_duration) {
if (when == 0) {
if (when.zero()) {
BBT.bars = 0;
BBT.beats = 0;
BBT.ticks = 0;
} else {
TempoMap& tmap (_session->tempo_map());
if (offset == 0) {
offset = bbt_reference_time;
if (offset.zero()) {
offset = timecnt_t (bbt_reference_time);
}
const double divisions = tmap.meter_section_at_sample (offset).divisions_per_bar();
@ -1319,7 +1275,7 @@ AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
} else {
BBT = _session->tempo_map().bbt_at_sample (when);
}
#endif
if (negative) {
snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
BBT.bars, BBT.beats, BBT.ticks);
@ -1331,14 +1287,16 @@ AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
_layout->set_text (buf);
if (_with_info) {
samplepos_t pos;
timepos_t pos;
if (bbt_reference_time < 0) {
if (bbt_reference_time.negative()) {
pos = when;
} else {
pos = bbt_reference_time;
}
#warning NUTEMPO FIXME new tempo map API
#if 0
TempoMetric m (_session->tempo_map().metric_at (pos));
#ifndef PLATFORM_WINDOWS
@ -1358,6 +1316,7 @@ AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
snprintf (buf, sizeof(buf), "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
_right_btn.set_text (string_compose ("%1: %2", S_("TimeSignature|TS"), buf), false);
#endif
}
}
@ -1824,13 +1783,15 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
switch (ev->direction) {
#warning NUTEMPO THIS SHOULD BE REVISITED FOR BeatTime
case GDK_SCROLL_UP:
samples = get_sample_step (f, current_time(), 1);
if (samples != 0) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
samples *= 10;
}
AudioClock::set (current_time() + samples, true);
AudioClock::set (current_time() + timepos_t (samples), true);
ValueChanged (); /* EMIT_SIGNAL */
}
break;
@ -1842,10 +1803,10 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
samples *= 10;
}
if (!_negative_allowed && (double)current_time() - (double)samples < 0.0) {
AudioClock::set (0, true);
if (!_negative_allowed && current_time().samples() < samples) {
AudioClock::set (timepos_t (), true);
} else {
AudioClock::set (current_time() - samples, true);
AudioClock::set (current_time().earlier (timepos_t (samples)), true);
}
ValueChanged (); /* EMIT_SIGNAL */
@ -1888,16 +1849,16 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev)
if (floor (drag_accum) != 0) {
samplepos_t samples;
samplepos_t pos;
timepos_t pos;
int dir;
dir = (drag_accum < 0 ? 1:-1);
pos = current_time();
samples = get_sample_step (drag_field, pos, dir);
if (samples != 0 && samples * drag_accum < current_time()) {
AudioClock::set ((samplepos_t) floor (pos - drag_accum * samples), false); // minus because up is negative in GTK
if (samples != 0 && timepos_t (samples * drag_accum) < current_time()) {
AudioClock::set (timepos_t (pos.earlier (drag_accum * samples)), false); // minus because up is negative in GTK
} else {
AudioClock::set (0 , false);
AudioClock::set (timepos_t () , false);
}
drag_accum= 0;
@ -1908,7 +1869,7 @@ AudioClock::on_motion_notify_event (GdkEventMotion *ev)
}
samplepos_t
AudioClock::get_sample_step (Field field, samplepos_t pos, int dir)
AudioClock::get_sample_step (Field field, timepos_t const & pos, int dir)
{
samplecnt_t f = 0;
Temporal::BBT_Time BBT;
@ -1954,19 +1915,22 @@ AudioClock::get_sample_step (Field field, samplepos_t pos, int dir)
BBT.bars = 1;
BBT.beats = 0;
BBT.ticks = 0;
f = _session->tempo_map().bbt_duration_at (pos,BBT,dir);
#warning NUTEMPO FIXME new tempo map API
//f = _session->tempo_map().bbt_duration_at (pos,BBT,dir);
break;
case Beats:
BBT.bars = 0;
BBT.beats = 1;
BBT.ticks = 0;
f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
#warning NUTEMPO FIXME new tempo map API
//f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
break;
case Ticks:
BBT.bars = 0;
BBT.beats = 0;
BBT.ticks = 1;
f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
#warning NUTEMPO FIXME new tempo map API
//f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
break;
default:
error << string_compose (_("programming error: %1"), "attempt to get samples from non-text field!") << endmsg;
@ -1977,16 +1941,16 @@ AudioClock::get_sample_step (Field field, samplepos_t pos, int dir)
return f;
}
samplepos_t
AudioClock::current_time (samplepos_t) const
timepos_t
AudioClock::current_time () const
{
return last_when;
}
samplepos_t
AudioClock::current_duration (samplepos_t pos) const
timecnt_t
AudioClock::current_duration (timepos_t pos) const
{
samplepos_t ret = 0;
timecnt_t ret;
switch (_mode) {
case BBT:
@ -1997,7 +1961,7 @@ AudioClock::current_duration (samplepos_t pos) const
case MinSec:
case Seconds:
case Samples:
ret = last_when;
ret = timecnt_t (last_when, pos);
break;
}
@ -2141,7 +2105,7 @@ AudioClock::samples_from_minsec_string (const string& str) const
}
samplepos_t
AudioClock::samples_from_bbt_string (samplepos_t pos, const string& str) const
AudioClock::samples_from_bbt_string (timepos_t const & pos, const string& str) const
{
if (_session == 0) {
error << "AudioClock::current_time() called with BBT mode but without session!" << endmsg;
@ -2158,7 +2122,9 @@ AudioClock::samples_from_bbt_string (samplepos_t pos, const string& str) const
if (is_duration) {
any.bbt.bars++;
any.bbt.beats++;
return _session->any_duration_to_samples (pos, any);
#warning NUTEMPO new tempo map/session API
//return _session->any_duration_to_samples (pos, any);
return 0;
} else {
return _session->convert_to_samples (any);
}
@ -2166,7 +2132,7 @@ AudioClock::samples_from_bbt_string (samplepos_t pos, const string& str) const
samplepos_t
AudioClock::sample_duration_from_bbt_string (samplepos_t pos, const string& str) const
AudioClock::sample_duration_from_bbt_string (timepos_t const & pos, const string& str) const
{
if (_session == 0) {
error << "AudioClock::sample_duration_from_bbt_string() called with BBT mode but without session!" << endmsg;
@ -2179,7 +2145,9 @@ AudioClock::sample_duration_from_bbt_string (samplepos_t pos, const string& str)
return 0;
}
return _session->tempo_map().bbt_duration_at(pos,bbt,1);
#warning NUTEMPO new tempo map API
//return _session->tempo_map().bbt_duration_at(pos,bbt,1);
return 0;
}
samplepos_t
@ -2246,7 +2214,7 @@ AudioClock::set_from_playhead ()
return;
}
AudioClock::set (_session->transport_sample());
AudioClock::set (timepos_t (_session->transport_sample()));
ValueChanged ();
}
@ -2260,7 +2228,7 @@ AudioClock::locate ()
return;
}
_session->request_locate (current_time());
_session->request_locate (current_time().samples());
}
void
@ -2392,7 +2360,7 @@ AudioClock::set_is_duration (bool yn, timepos_t const & p)
duration_position = timepos_t ();
}
set_time (last_when, true);
set (last_when, true);
}
void

View File

@ -73,8 +73,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
void focus ();
virtual void set (samplepos_t, bool force = false, ARDOUR::samplecnt_t offset = 0);
void set_time (Temporal::timepos_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t());
virtual void set (Temporal::timepos_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t());
void set_duration (Temporal::timecnt_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t());
void set_from_playhead ();
@ -88,8 +87,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
std::string name() const { return _name; }
samplepos_t current_time (samplepos_t position = 0) const;
samplepos_t current_duration (samplepos_t position = 0) const;
Temporal::timepos_t current_time () const;
Temporal::timecnt_t current_duration (Temporal::timepos_t position = Temporal::timepos_t()) const;
void set_session (ARDOUR::Session *s);
void set_negative_allowed (bool yn);
@ -116,7 +115,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
protected:
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
bool get_is_duration () const { return is_duration; }
ARDOUR::samplecnt_t offset () const { return _offset; }
Temporal::timecnt_t offset () const { return _offset; }
virtual void build_ops_menu ();
Gtk::Menu *ops_menu;
@ -142,10 +141,10 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
bool _negative_allowed;
bool edit_is_negative;
samplepos_t _limit_pos;
Temporal::timepos_t _limit_pos;
Temporal::timepos_t duration_position;
ARDOUR::samplecnt_t _offset;
Temporal::timecnt_t _offset;
Glib::RefPtr<Pango::Layout> _layout;
@ -201,8 +200,8 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
std::string pre_edit_string;
std::string input_string;
samplepos_t bbt_reference_time;
samplepos_t last_when;
Temporal::timepos_t bbt_reference_time;
Temporal::timepos_t last_when;
bool last_pdelta;
bool last_sdelta;
@ -222,25 +221,25 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
bool on_focus_out_event (GdkEventFocus*);
void set_slave_info ();
void set_timecode (samplepos_t, bool);
void set_bbt (samplepos_t, ARDOUR::samplecnt_t, bool);
void set_minsec (samplepos_t, bool);
void set_seconds (samplepos_t, bool);
void set_samples (samplepos_t, bool);
void set_timecode (Temporal::timepos_t const &, bool);
void set_bbt (Temporal::timepos_t const &, Temporal::timecnt_t const &, bool);
void set_minsec (Temporal::timepos_t const &, bool);
void set_seconds (Temporal::timepos_t const &, bool);
void set_samples (Temporal::timepos_t const &, bool);
void set_out_of_bounds (bool negative);
void finish_set (Temporal::timepos_t const &, bool);
void set_clock_dimensions (Gtk::Requisition&);
samplepos_t get_sample_step (Field, samplepos_t pos = 0, int dir = 1);
samplepos_t get_sample_step (Field, Temporal::timepos_t const & pos = Temporal::timepos_t (), int dir = 1);
bool timecode_validate_edit (const std::string&);
bool bbt_validate_edit (std::string&);
bool minsec_validate_edit (const std::string&);
samplepos_t samples_from_timecode_string (const std::string&) const;
samplepos_t samples_from_bbt_string (samplepos_t, const std::string&) const;
samplepos_t sample_duration_from_bbt_string (samplepos_t, const std::string&) const;
samplepos_t samples_from_bbt_string (Temporal::timepos_t const &, const std::string&) const;
samplepos_t sample_duration_from_bbt_string (Temporal::timepos_t const &, const std::string&) const;
samplepos_t samples_from_minsec_string (const std::string&) const;
samplepos_t samples_from_seconds_string (const std::string&) const;
samplepos_t samples_from_audiosamples_string (const std::string&) const;
@ -254,13 +253,13 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
void end_edit (bool);
void end_edit_relative (bool);
void edit_next_field ();
ARDOUR::samplecnt_t parse_as_distance (const std::string&);
ARDOUR::samplecnt_t parse_as_timecode_distance (const std::string&);
ARDOUR::samplecnt_t parse_as_minsec_distance (const std::string&);
ARDOUR::samplecnt_t parse_as_bbt_distance (const std::string&);
ARDOUR::samplecnt_t parse_as_seconds_distance (const std::string&);
ARDOUR::samplecnt_t parse_as_samples_distance (const std::string&);
Temporal::timecnt_t parse_as_distance (const std::string&);
Temporal::timecnt_t parse_as_timecode_distance (const std::string&);
Temporal::timecnt_t parse_as_minsec_distance (const std::string&);
Temporal::timecnt_t parse_as_bbt_distance (const std::string&);
Temporal::timecnt_t parse_as_seconds_distance (const std::string&);
Temporal::timecnt_t parse_as_samples_distance (const std::string&);
void set_colors ();
void show_edit_status (int length);

View File

@ -427,9 +427,9 @@ public:
void reset_zoom (samplecnt_t);
void reposition_and_zoom (samplepos_t, double);
samplepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE,
bool use_context_click = false,
bool from_outside_canvas = false);
Temporal::timepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE,
bool use_context_click = false,
bool from_outside_canvas = false);
bool update_mouse_speed ();
bool decelerate_mouse_speed ();
@ -569,10 +569,10 @@ public:
void metric_get_minsec (std::vector<ArdourCanvas::Ruler::Mark>&, gdouble, gdouble, gint);
/* editing operations that need to be public */
void mouse_add_new_marker (samplepos_t where, bool is_cd=false);
void split_regions_at (ARDOUR::MusicSample, RegionSelection&);
void mouse_add_new_marker (Temporal::timepos_t const & where, bool is_cd=false);
void split_regions_at (Temporal::timepos_t const & , RegionSelection&);
void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false);
RegionSelection get_regions_from_selection_and_mouse (samplepos_t);
RegionSelection get_regions_from_selection_and_mouse (Temporal::timepos_t const &);
void do_remove_gaps ();
void remove_gaps (samplecnt_t threshold, samplecnt_t leave, bool markers_too);
@ -1522,7 +1522,7 @@ private:
void set_selection_from_loop ();
void set_selection_from_region ();
void add_location_mark (samplepos_t where);
void add_location_mark (Temporal::timepos_t const & where);
void add_location_from_region ();
void add_locations_from_region ();
void add_location_from_selection ();
@ -1537,8 +1537,8 @@ private:
void set_loop_from_region (bool play);
void set_loop_range (samplepos_t start, samplepos_t end, std::string cmd);
void set_punch_range (samplepos_t start, samplepos_t end, std::string cmd);
void set_loop_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd);
void set_punch_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd);
void toggle_location_at_playhead_cursor ();
void add_location_from_playhead_cursor ();
@ -2230,10 +2230,10 @@ private:
void selected_marker_moved (ARDOUR::Location*);
bool get_edit_op_range (samplepos_t& start, samplepos_t& end) const;
bool get_edit_op_range (Temporal::timepos_t& start, samplepos_t& end) const;
void get_regions_at (RegionSelection&, samplepos_t where, const TrackViewList& ts) const;
void get_regions_after (RegionSelection&, samplepos_t where, const TrackViewList& ts) const;
void get_regions_at (RegionSelection&, Temporal::timepos_t const & where, const TrackViewList& ts) const;
void get_regions_after (RegionSelection&, Temporal::timepos_t const & where, const TrackViewList& ts) const;
RegionSelection get_regions_from_selection_and_edit_point (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE,
bool use_context_click = false,

View File

@ -668,7 +668,7 @@ Editor::LocationMarkers::setup_lines ()
}
void
Editor::mouse_add_new_marker (samplepos_t where, bool is_cd)
Editor::mouse_add_new_marker (timepos_t const & where, bool is_cd)
{
string markername;
int flags = (is_cd ? Location::IsCDMarker|Location::IsMark : Location::IsMark);
@ -712,7 +712,7 @@ Editor::mouse_add_new_loop (samplepos_t where)
samplepos_t const end = where + current_page_samples() / 8;
set_loop_range (where, end, _("set loop range"));
set_loop_range (timepos_t (where), timepos_t (end), _("set loop range"));
}
void
@ -728,7 +728,7 @@ Editor::mouse_add_new_punch (samplepos_t where)
samplepos_t const end = where + current_page_samples() / 8;
set_punch_range (where, end, _("set punch range"));
set_punch_range (timepos_t (where), timepos_t (end), _("set punch range"));
}
void
@ -1421,7 +1421,7 @@ Editor::marker_menu_loop_range ()
if ((l = find_location_from_marker (marker, is_start)) != 0) {
if (l != transport_loop_location()) {
cerr << "Set loop\n";
set_loop_range (l->start().samples(), l->end().samples(), _("loop range from marker"));
set_loop_range (l->start(), l->end(), _("loop range from marker"));
} else {
cerr << " at TL\n";
}
@ -1442,9 +1442,9 @@ Editor::marker_menu_zoom_to_range ()
return;
}
timecnt_t const extra = l->length() * Temporal::ratio_t (5, 100);
timepos_t const extra = timepos_t (l->length() * Temporal::ratio_t (5, 100));
timepos_t a = l->start ();
if (a >= timepos_t (extra)) {
if (a >= extra) {
a.shift_earlier (extra);
}
@ -1750,8 +1750,8 @@ Editor::update_loop_range_view ()
if (_session->get_play_loop() && ((tll = transport_loop_location()) != 0)) {
double x1 = sample_to_pixel (tll->start());
double x2 = sample_to_pixel (tll->end());
double x1 = sample_to_pixel (tll->start_sample());
double x2 = sample_to_pixel (tll->end_sample());
transport_loop_range_rect->set_x0 (x1);
transport_loop_range_rect->set_x1 (x2);
@ -1778,12 +1778,12 @@ Editor::update_punch_range_view ()
double pixel_end;
if (_session->config.get_punch_in()) {
pixel_start = sample_to_pixel (tpl->start());
pixel_start = sample_to_pixel (tpl->start_sample());
} else {
pixel_start = 0;
}
if (_session->config.get_punch_out()) {
pixel_end = sample_to_pixel (tpl->end());
pixel_end = sample_to_pixel (tpl->end_sample());
} else {
pixel_end = sample_to_pixel (max_samplepos);
}
@ -1836,7 +1836,7 @@ Editor::goto_nth_marker (int n)
for (Locations::LocationList::iterator i = ordered.begin(); n >= 0 && i != ordered.end(); ++i) {
if ((*i)->is_mark() && !(*i)->is_hidden() && !(*i)->is_session_range()) {
if (n == 0) {
_session->request_locate ((*i)->start());
_session->request_locate ((*i)->start_sample());
break;
}
--n;
@ -1866,10 +1866,10 @@ Editor::toggle_marker_menu_glue ()
begin_reversible_command (_("change marker lock style"));
XMLNode &before = _session->locations()->get_state();
if (loc->position_lock_style() == MusicTime) {
loc->set_position_lock_style (AudioTime);
if (loc->position_time_domain() == Temporal::BeatTime) {
loc->set_position_time_domain (Temporal::AudioTime);
} else {
loc->set_position_lock_style (MusicTime);
loc->set_position_time_domain (Temporal::BeatTime);
}
XMLNode &after = _session->locations()->get_state();

View File

@ -436,10 +436,9 @@ LoudnessDialog::analyze ()
/* These are ensured in Editor::measure_master_loudness () */
assert (_session->master_out ());
assert (_session->master_volume ());
assert (_session->master_out ()->output ());
assert (_session->master_out ()->output ()->n_ports ().n_audio () == 2);
assert (_range.start < _range.end);
assert (_session->master_out()->output());
assert (_session->master_out()->output()->n_ports().n_audio() == 2);
assert (_range.start() < _range.end());
ExportTimespanPtr tsp = _session->get_export_handler ()->add_timespan ();
@ -458,7 +457,7 @@ LoudnessDialog::analyze ()
fmp->set_analyse (true);
/* setup range */
tsp->set_range (_range.start, _range.end);
tsp->set_range (_range.start().samples(), _range.end().samples());
tsp->set_range_id ("selection");
tsp->set_realtime (_rt_analysis_button.get_active ());
tsp->set_name ("master");

View File

@ -105,7 +105,7 @@ MainClock::absolute_time () const
}
void
MainClock::set (samplepos_t when, bool force, ARDOUR::samplecnt_t /*offset*/)
MainClock::set (timepos_t const & when, bool force, timecnt_t const & /*offset*/)
{
ClockDeltaMode mode;
if (_primary) {

View File

@ -31,7 +31,7 @@ public:
MainClock (const std::string& clock_name, const std::string& widget_name, bool primary);
samplepos_t absolute_time () const;
void set_session (ARDOUR::Session *s);
void set (samplepos_t, bool force = false, ARDOUR::samplecnt_t offset = 0);
void set (Temporal::timepos_t const &, bool force = false, Temporal::timecnt_t const & offset = Temporal::timecnt_t ());
private:

View File

@ -229,11 +229,11 @@ public:
virtual void trigger_script (int nth) = 0;
virtual void add_location_from_playhead_cursor () = 0;
virtual void remove_location_at_playhead_cursor () = 0;
virtual void add_location_mark (samplepos_t where) = 0;
virtual void add_location_mark (Temporal::timepos_t const & where) = 0;
virtual void update_grid () = 0;
virtual void remove_tracks () = 0;
virtual void set_loop_range (samplepos_t start, samplepos_t end, std::string cmd) = 0;
virtual void set_punch_range (samplepos_t start, samplepos_t end, std::string cmd) = 0;
virtual void set_loop_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd) = 0;
virtual void set_punch_range (Temporal::timepos_t const & start, Temporal::timepos_t const & end, std::string cmd) = 0;
virtual void jump_forward_to_mark () = 0;
virtual void jump_backward_to_mark () = 0;
@ -350,11 +350,11 @@ public:
virtual void remove_last_capture () = 0;
virtual void maximise_editing_space () = 0;
virtual void restore_editing_space () = 0;
virtual samplepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE, bool from_context_menu = false, bool from_outside_canvas = false) = 0;
virtual Temporal::timepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE, bool from_context_menu = false, bool from_outside_canvas = false) = 0;
virtual void toggle_meter_updating() = 0;
virtual void split_regions_at (ARDOUR::MusicSample, RegionSelection&) = 0;
virtual void split_regions_at (Temporal::timepos_t const &, RegionSelection&) = 0;
virtual void split_region_at_points (boost::shared_ptr<ARDOUR::Region>, ARDOUR::AnalysisFeatureList&, bool can_ferret, bool select_new = false) = 0;
virtual void mouse_add_new_marker (samplepos_t where, bool is_cd=false) = 0;
virtual void mouse_add_new_marker (Temporal::timepos_t const & where, bool is_cd=false) = 0;
virtual void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>) = 0;
virtual void add_to_idle_resize (TimeAxisView*, int32_t) = 0;
virtual Temporal::timecnt_t get_nudge_distance (Temporal::timepos_t const & pos, Temporal::timecnt_t& next) = 0;
@ -503,9 +503,9 @@ public:
virtual void set_snapped_cursor_position (samplepos_t pos) = 0;
virtual void get_regions_at (RegionSelection &, samplepos_t where, TrackViewList const &) const = 0;
virtual void get_regions_after (RegionSelection&, samplepos_t where, const TrackViewList& ts) const = 0;
virtual RegionSelection get_regions_from_selection_and_mouse (samplepos_t) = 0;
virtual void get_regions_at (RegionSelection &, Temporal::timepos_t const & where, TrackViewList const &) const = 0;
virtual void get_regions_after (RegionSelection&, Temporal::timepos_t const & where, const TrackViewList& ts) const = 0;
virtual RegionSelection get_regions_from_selection_and_mouse (Temporal::timepos_t const &) = 0;
virtual void get_regionviews_by_id (PBD::ID const id, RegionSelection & regions) const = 0;
virtual void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<boost::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const = 0;

View File

@ -188,7 +188,7 @@ RegionLayeringOrderEditor::refill ()
}
void
RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, TimeAxisView* tav, boost::shared_ptr<Playlist> pl, samplepos_t pos)
RegionLayeringOrderEditor::set_context (const string& a_name, Session* s, TimeAxisView* tav, boost::shared_ptr<Playlist> pl, timepos_t const & pos)
{
track_name_label.set_text (a_name);

View File

@ -44,14 +44,14 @@ public:
RegionLayeringOrderEditor (PublicEditor&);
virtual ~RegionLayeringOrderEditor ();
void set_context (const std::string &, ARDOUR::Session *, TimeAxisView *, boost::shared_ptr<ARDOUR::Playlist>, ARDOUR::samplepos_t);
void set_context (const std::string &, ARDOUR::Session *, TimeAxisView *, boost::shared_ptr<ARDOUR::Playlist>, Temporal::timepos_t const &);
void maybe_present ();
protected:
virtual bool on_key_press_event (GdkEventKey* event);
private:
samplepos_t position;
Temporal::timepos_t position;
bool in_row_change;
uint32_t regions_at_position;

View File

@ -206,7 +206,7 @@ RegionSelection::add_to_layer (RegionView * rv)
struct RegionSortByTime {
bool operator() (const RegionView* a, const RegionView* b) const {
return a->region()->position() < b->region()->position();
return a->region()->nt_position() < b->region()->nt_position();
}
};
@ -235,7 +235,7 @@ struct RegionSortByTrack {
/* really, track and position */
if (a->get_time_axis_view().order() == b->get_time_axis_view().order()) {
return a->region()->position() < b->region()->position();
return a->region()->nt_position() < b->region()->nt_position();
} else {
return a->get_time_axis_view().order() < b->get_time_axis_view().order();
}

View File

@ -55,7 +55,7 @@ using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, samplecnt_t oldlen, samplecnt_t new_length, samplepos_t position)
TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, timecnt_t const & oldlen, timecnt_t const & new_length, timepos_t const & position)
: ArdourDialog (X_("time fx dialog"))
, editor (e)
, pitching (pitch)
@ -145,9 +145,10 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, samplecnt_t oldlen, samplecnt
vector<string> strings;
duration_clock = manage (new AudioClock (X_("stretch"), true, X_("stretch"), true, false, true, false, true));
duration_clock->set_session (e.session());
duration_clock->set (new_length, true);
duration_clock->set (timepos_t (new_length), true);
duration_clock->set_mode (AudioClock::BBT);
duration_clock->set_bbt_reference (position);
#warning NUTEMPO FIXME figure out what we are doing here
// duration_clock->set_bbt_reference (position);
Gtk::Alignment* clock_align = manage (new Gtk::Alignment);
clock_align->add (*duration_clock);
@ -158,7 +159,7 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, samplecnt_t oldlen, samplecnt
table->attach (*clock_align, 1, 2, row, row+1, Gtk::AttachOptions (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 0, 0);
row++;
const double fract = ((double) new_length) / original_length;
const double fract = (double) (new_length / original_length);
/* note the *100.0 to convert fract into a percentage */
duration_adjustment.set_value (fract*100.0);
Gtk::SpinButton* spinner = manage (new Gtk::SpinButton (duration_adjustment, 1.0, 3));
@ -301,7 +302,7 @@ TimeFXDialog::duration_adjustment_changed ()
PBD::Unwinder<bool> uw (ignore_clock_change, true);
duration_clock->set ((samplecnt_t) (original_length * (duration_adjustment.get_value()/ 100.0)));
duration_clock->set_duration (original_length * Temporal::ratio_t (1.0, (duration_adjustment.get_value() / 100.0)));
}
void
@ -313,5 +314,5 @@ TimeFXDialog::duration_clock_changed ()
PBD::Unwinder<bool> uw (ignore_adjustment_change, true);
duration_adjustment.set_value (100.0 * (duration_clock->current_duration() / (double) original_length));
duration_adjustment.set_value (100.0 * (double) (duration_clock->current_duration() / original_length));
}

View File

@ -42,7 +42,7 @@ class TimeFXDialog : public ArdourDialog, public ProgressReporter
{
public:
/* We need a position so that BBT mode in the clock can function */
TimeFXDialog (Editor& e, bool for_pitch, ARDOUR::samplecnt_t old_length, ARDOUR::samplecnt_t new_length, ARDOUR::samplepos_t position);
TimeFXDialog (Editor& e, bool for_pitch, Temporal::timecnt_t const & old_length, Temporal::timecnt_t const & new_length, Temporal::timepos_t const & position);
ARDOUR::TimeFXRequest request;
Editor& editor;
@ -86,7 +86,7 @@ public:
}
private:
ARDOUR::samplecnt_t original_length;
Temporal::timecnt_t original_length;
Gtk::Adjustment pitch_octave_adjustment;
Gtk::Adjustment pitch_semitone_adjustment;
Gtk::Adjustment pitch_cent_adjustment;

View File

@ -106,12 +106,12 @@ TransportControlProvider::TransportControllable::get_value () const
return (!_session->transport_rolling() ? 1.0 : 0.0);
case GotoStart:
if ((rloc = _session->locations()->session_range_location()) != 0) {
return (_session->transport_sample() == rloc->start() ? 1.0 : 0.0);
return (_session->transport_sample() == rloc->start_sample() ? 1.0 : 0.0);
}
return 0.0;
case GotoEnd:
if ((rloc = _session->locations()->session_range_location()) != 0) {
return (_session->transport_sample() == rloc->end() ? 1.0 : 0.0);
return (_session->transport_sample() == rloc->end_sample() ? 1.0 : 0.0);
}
return 0.0;
case AutoLoop: