change Session::convert_to_frames_at() to Session::convert_to_frames() to reflect the fact that its argument is a position, not a duration; add Session::any_duration_to_frames(), which converts AnyTime representing a duration to frames; alter callers to use the right one of the two previously mentioned methods
git-svn-id: svn://localhost/ardour2/branches/3.0@8386 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
1f87006509
commit
75ede0dd6b
@ -1916,9 +1916,10 @@ AudioClock::bbt_frame_from_display (framepos_t pos) const
|
||||
if (is_duration) {
|
||||
any.bbt.bars++;
|
||||
any.bbt.beats++;
|
||||
}
|
||||
|
||||
return _session->convert_to_frames_at (pos, any);
|
||||
return _session->any_duration_to_frames (pos, any);
|
||||
} else {
|
||||
return _session->convert_to_frames (any);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -732,7 +732,7 @@ void
|
||||
ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
|
||||
{
|
||||
// TODO position
|
||||
clock.set (_session->convert_to_frames_at (0, time), true);
|
||||
clock.set (_session->convert_to_frames (time), true);
|
||||
|
||||
AudioClock::Mode mode(AudioClock::Timecode);
|
||||
|
||||
|
@ -460,7 +460,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
void timecode_duration (framecnt_t, Timecode::Time&) const;
|
||||
void timecode_duration_string (char *, framecnt_t) const;
|
||||
|
||||
framecnt_t convert_to_frames_at (framepos_t position, AnyTime const &);
|
||||
framecnt_t convert_to_frames (AnyTime const & position);
|
||||
framecnt_t any_duration_to_frames (framepos_t position, AnyTime const & duration);
|
||||
|
||||
static PBD::Signal1<void, framepos_t> StartTimeChanged;
|
||||
static PBD::Signal1<void, framepos_t> EndTimeChanged;
|
||||
|
@ -49,7 +49,7 @@ ExportFormatSpecification::Time::operator= (AnyTime const & other)
|
||||
framecnt_t
|
||||
ExportFormatSpecification::Time::get_frames_at (framepos_t position, framecnt_t target_rate) const
|
||||
{
|
||||
framecnt_t duration = session.convert_to_frames_at (position, *this);
|
||||
framecnt_t duration = session.any_duration_to_frames (position, *this);
|
||||
return ((double) target_rate / session.frame_rate()) * duration + 0.5;
|
||||
}
|
||||
|
||||
|
@ -547,21 +547,21 @@ Session::jack_timebase_callback (jack_transport_state_t /*state*/,
|
||||
}
|
||||
|
||||
ARDOUR::framecnt_t
|
||||
Session::convert_to_frames_at (framepos_t /*position*/, AnyTime const & any)
|
||||
Session::convert_to_frames (AnyTime const & position)
|
||||
{
|
||||
double secs;
|
||||
|
||||
switch (any.type) {
|
||||
switch (position.type) {
|
||||
case AnyTime::BBT:
|
||||
return _tempo_map->frame_time (any.bbt);
|
||||
return _tempo_map->frame_time (position.bbt);
|
||||
break;
|
||||
|
||||
case AnyTime::Timecode:
|
||||
/* XXX need to handle negative values */
|
||||
secs = any.timecode.hours * 60 * 60;
|
||||
secs += any.timecode.minutes * 60;
|
||||
secs += any.timecode.seconds;
|
||||
secs += any.timecode.frames / timecode_frames_per_second();
|
||||
secs = position.timecode.hours * 60 * 60;
|
||||
secs += position.timecode.minutes * 60;
|
||||
secs += position.timecode.seconds;
|
||||
secs += position.timecode.frames / timecode_frames_per_second();
|
||||
if (config.get_timecode_offset_negative()) {
|
||||
return (framecnt_t) floor (secs * frame_rate()) - config.get_timecode_offset();
|
||||
} else {
|
||||
@ -570,13 +570,48 @@ Session::convert_to_frames_at (framepos_t /*position*/, AnyTime const & any)
|
||||
break;
|
||||
|
||||
case AnyTime::Seconds:
|
||||
return (framecnt_t) floor (any.seconds * frame_rate());
|
||||
return (framecnt_t) floor (position.seconds * frame_rate());
|
||||
break;
|
||||
|
||||
case AnyTime::Frames:
|
||||
return any.frames;
|
||||
return position.frames;
|
||||
break;
|
||||
}
|
||||
|
||||
return any.frames;
|
||||
return position.frames;
|
||||
}
|
||||
|
||||
ARDOUR::framecnt_t
|
||||
Session::any_duration_to_frames (framepos_t position, AnyTime const & duration)
|
||||
{
|
||||
double secs;
|
||||
|
||||
switch (duration.type) {
|
||||
case AnyTime::BBT:
|
||||
return (framecnt_t) ( _tempo_map->framepos_plus_bbt (position, duration.bbt) - position);
|
||||
break;
|
||||
|
||||
case AnyTime::Timecode:
|
||||
/* XXX need to handle negative values */
|
||||
secs = duration.timecode.hours * 60 * 60;
|
||||
secs += duration.timecode.minutes * 60;
|
||||
secs += duration.timecode.seconds;
|
||||
secs += duration.timecode.frames / timecode_frames_per_second();
|
||||
if (config.get_timecode_offset_negative()) {
|
||||
return (framecnt_t) floor (secs * frame_rate()) - config.get_timecode_offset();
|
||||
} else {
|
||||
return (framecnt_t) floor (secs * frame_rate()) + config.get_timecode_offset();
|
||||
}
|
||||
break;
|
||||
|
||||
case AnyTime::Seconds:
|
||||
return (framecnt_t) floor (duration.seconds * frame_rate());
|
||||
break;
|
||||
|
||||
case AnyTime::Frames:
|
||||
return duration.frames;
|
||||
break;
|
||||
}
|
||||
|
||||
return duration.frames;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user