summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-12-30 15:45:48 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-12-30 15:45:48 +0000
commit75ede0dd6bda0136aef612b0e427ae25b208d0d0 (patch)
treedb20717fe56bd77ac352f7f218bf53b1a0f1e926 /libs/ardour
parent1f87006509e024c430f24358bd85c748f10b82eb (diff)
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
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/session.h3
-rw-r--r--libs/ardour/export_format_specification.cc2
-rw-r--r--libs/ardour/session_time.cc55
3 files changed, 48 insertions, 12 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 393c9d1356..7abeabd647 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -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;
diff --git a/libs/ardour/export_format_specification.cc b/libs/ardour/export_format_specification.cc
index b85d060e2f..bf2585a281 100644
--- a/libs/ardour/export_format_specification.cc
+++ b/libs/ardour/export_format_specification.cc
@@ -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;
}
diff --git a/libs/ardour/session_time.cc b/libs/ardour/session_time.cc
index 7bd0ad1164..d9c612fbee 100644
--- a/libs/ardour/session_time.cc
+++ b/libs/ardour/session_time.cc
@@ -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;
}