/* BBT TIME*/
void
-Session::bbt_time (framepos_t when, BBT_Time& bbt)
+Session::bbt_time (framepos_t when, Timecode::BBT_Time& bbt)
{
_tempo_map->bbt_time (when, bbt);
}
jack_position_t* pos,
int /*new_position*/)
{
- BBT_Time bbt;
+ Timecode::BBT_Time bbt;
- if (pos->frame != _transport_frame) {
- cerr << "ARDOUR says " << _transport_frame << " JACK says " << pos->frame << endl;
- }
+ if (pos->frame != _transport_frame) {
+ cerr << "ARDOUR says " << _transport_frame << " JACK says " << pos->frame << endl;
+ }
/* BBT info */
pos->beats_per_bar = metric.meter().beats_per_bar();
pos->beat_type = metric.meter().note_divisor();
- pos->ticks_per_beat = Meter::ticks_per_beat;
+ pos->ticks_per_beat = Timecode::BBT_Time::ticks_per_beat;
pos->beats_per_minute = metric.tempo().beats_per_minute();
pos->valid = jack_position_bits_t (pos->valid | JackPositionBBT);
}
ARDOUR::framecnt_t
-Session::convert_to_frames_at (framepos_t /*position*/, AnyTime const & any)
+Session::convert_to_frames (AnyTime const & position)
+{
+ double secs;
+
+ switch (position.type) {
+ case AnyTime::BBT:
+ return _tempo_map->frame_time (position.bbt);
+ break;
+
+ case AnyTime::Timecode:
+ /* XXX need to handle negative values */
+ 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 {
+ return (framecnt_t) floor (secs * frame_rate()) + config.get_timecode_offset();
+ }
+ break;
+
+ case AnyTime::Seconds:
+ return (framecnt_t) floor (position.seconds * frame_rate());
+ break;
+
+ case AnyTime::Frames:
+ return position.frames;
+ break;
+ }
+
+ return position.frames;
+}
+
+ARDOUR::framecnt_t
+Session::any_duration_to_frames (framepos_t position, AnyTime const & duration)
{
double secs;
- switch (any.type) {
+ switch (duration.type) {
case AnyTime::BBT:
- return _tempo_map->frame_time (any.bbt);
+ return (framecnt_t) ( _tempo_map->framepos_plus_bbt (position, duration.bbt) - position);
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 = 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 {
break;
case AnyTime::Seconds:
- return (framecnt_t) floor (any.seconds * frame_rate());
+ return (framecnt_t) floor (duration.seconds * frame_rate());
break;
case AnyTime::Frames:
- return any.frames;
+ return duration.frames;
break;
}
- return any.frames;
+ return duration.frames;
}