Remove Session dependency from BeatsFramesConverter.
More constey TempoMap accessors. git-svn-id: svn://localhost/ardour2/branches/3.0@5916 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -574,7 +574,7 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||
gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
|
||||
rect->property_x2() = xend;
|
||||
|
||||
ARDOUR::BeatsFramesConverter tconv(_trackview.session(), region->position());
|
||||
ARDOUR::BeatsFramesConverter tconv(_trackview.session().tempo_map(), region->position());
|
||||
const MidiModel::TimeType start_beats = tconv.from(start);
|
||||
|
||||
/* draw events */
|
||||
|
||||
@@ -78,7 +78,7 @@ RegionView::RegionView (ArdourCanvas::Group* parent,
|
||||
, _pixel_width(1.0)
|
||||
, in_destructor(false)
|
||||
, wait_for_data(false)
|
||||
, _time_converter(r->session(), r->position())
|
||||
, _time_converter(r->session().tempo_map(), r->position())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ RegionView::RegionView (ArdourCanvas::Group* parent,
|
||||
, _pixel_width(1.0)
|
||||
, in_destructor(false)
|
||||
, wait_for_data(false)
|
||||
, _time_converter(r->session(), r->position())
|
||||
, _time_converter(r->session().tempo_map(), r->position())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -27,24 +27,24 @@
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class Session;
|
||||
class TempoMap;
|
||||
|
||||
class BeatsFramesConverter : public Evoral::TimeConverter<double,sframes_t> {
|
||||
public:
|
||||
BeatsFramesConverter(Session& session, sframes_t origin)
|
||||
: _session(session)
|
||||
BeatsFramesConverter(const TempoMap& tempo_map, sframes_t origin)
|
||||
: _tempo_map(tempo_map)
|
||||
, _origin(origin)
|
||||
{}
|
||||
|
||||
sframes_t to(double beats) const;
|
||||
double from(sframes_t frames) const;
|
||||
|
||||
sframes_t origin() const { return _origin; }
|
||||
void set_origin(sframes_t origin) { _origin = origin; }
|
||||
sframes_t origin() const { return _origin; }
|
||||
void set_origin(sframes_t origin) { _origin = origin; }
|
||||
|
||||
private:
|
||||
Session& _session;
|
||||
sframes_t _origin;
|
||||
const TempoMap& _tempo_map;
|
||||
sframes_t _origin;
|
||||
};
|
||||
|
||||
} /* namespace ARDOUR */
|
||||
|
||||
@@ -184,8 +184,8 @@ class TempoMap : public PBD::StatefulDestructible
|
||||
static const Tempo& default_tempo() { return _default_tempo; }
|
||||
static const Meter& default_meter() { return _default_meter; }
|
||||
|
||||
const Tempo& tempo_at (nframes_t);
|
||||
const Meter& meter_at (nframes_t);
|
||||
const Tempo& tempo_at (nframes_t) const;
|
||||
const Meter& meter_at (nframes_t) const;
|
||||
|
||||
const TempoSection& tempo_section_at (nframes_t);
|
||||
|
||||
@@ -253,6 +253,8 @@ class TempoMap : public PBD::StatefulDestructible
|
||||
int n_tempos () const;
|
||||
int n_meters () const;
|
||||
|
||||
nframes_t frame_rate () const { return _frame_rate; }
|
||||
|
||||
sigc::signal<void,ARDOUR::Change> StateChanged;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
$Id: midiregion.h 733 2006-08-01 17:19:38Z drobilla $
|
||||
*/
|
||||
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/beats_frames_converter.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/tempo.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
@@ -30,10 +28,10 @@ sframes_t
|
||||
BeatsFramesConverter::to(double beats) const
|
||||
{
|
||||
// FIXME: assumes tempo never changes after origin
|
||||
const Tempo& tempo = _session.tempo_map().tempo_at(_origin);
|
||||
const Tempo& tempo = _tempo_map.tempo_at(_origin);
|
||||
const double frames_per_beat = tempo.frames_per_beat(
|
||||
_session.engine().frame_rate(),
|
||||
_session.tempo_map().meter_at(_origin));
|
||||
_tempo_map.frame_rate(),
|
||||
_tempo_map.meter_at(_origin));
|
||||
|
||||
return lrint(beats * frames_per_beat);
|
||||
}
|
||||
@@ -42,10 +40,10 @@ double
|
||||
BeatsFramesConverter::from(sframes_t frames) const
|
||||
{
|
||||
// FIXME: assumes tempo never changes after origin
|
||||
const Tempo& tempo = _session.tempo_map().tempo_at(_origin);
|
||||
const Tempo& tempo = _tempo_map.tempo_at(_origin);
|
||||
const double frames_per_beat = tempo.frames_per_beat(
|
||||
_session.engine().frame_rate(),
|
||||
_session.tempo_map().meter_at(_origin));
|
||||
_tempo_map.frame_rate(),
|
||||
_tempo_map.meter_at(_origin));
|
||||
|
||||
return frames / frames_per_beat;
|
||||
}
|
||||
|
||||
@@ -58,23 +58,22 @@
|
||||
#include "midi++/manager.h"
|
||||
#include "midi++/mmc.h"
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/analyser.h"
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/audio_library.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/profile.h"
|
||||
#include "ardour/plugin_manager.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/audiosource.h"
|
||||
#include "ardour/utils.h"
|
||||
#include "ardour/control_protocol_manager.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/filesystem_paths.h"
|
||||
#include "ardour/mix.h"
|
||||
#include "ardour/plugin_manager.h"
|
||||
#include "ardour/profile.h"
|
||||
#include "ardour/rc_configuration.h"
|
||||
#include "ardour/runtime_functions.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/source_factory.h"
|
||||
#include "ardour/control_protocol_manager.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/filesystem_paths.h"
|
||||
|
||||
#include "ardour/mix.h"
|
||||
#include "ardour/runtime_functions.h"
|
||||
#include "ardour/utils.h"
|
||||
|
||||
#if defined (__APPLE__)
|
||||
#include <Carbon/Carbon.h> // For Gestalt
|
||||
|
||||
@@ -360,7 +360,7 @@ write_midi_data_to_new_files (Evoral::SMF* source, Session::ImportStatus& status
|
||||
|
||||
const nframes64_t pos = 0;
|
||||
const double length_beats = ceil(t / (double)source->ppqn());
|
||||
BeatsFramesConverter converter(smfs->session(), pos);
|
||||
BeatsFramesConverter converter(smfs->session().tempo_map(), pos);
|
||||
smfs->update_length(pos, converter.to(length_beats));
|
||||
smfs->end_write();
|
||||
|
||||
|
||||
@@ -119,12 +119,12 @@ MidiRegion::~MidiRegion ()
|
||||
void
|
||||
MidiRegion::set_position_internal (nframes_t pos, bool allow_bbt_recompute)
|
||||
{
|
||||
BeatsFramesConverter old_converter(_session, _position - _start);
|
||||
BeatsFramesConverter old_converter(_session.tempo_map(), _position - _start);
|
||||
double length_beats = old_converter.from(_length);
|
||||
|
||||
Region::set_position_internal(pos, allow_bbt_recompute);
|
||||
|
||||
BeatsFramesConverter new_converter(_session, pos - _start);
|
||||
BeatsFramesConverter new_converter(_session.tempo_map(), pos - _start);
|
||||
|
||||
set_length(new_converter.to(length_beats), 0);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ MidiSource::set_state (const XMLNode& node, int /*version*/)
|
||||
sframes_t
|
||||
MidiSource::length (sframes_t pos) const
|
||||
{
|
||||
BeatsFramesConverter converter(_session, pos);
|
||||
BeatsFramesConverter converter(_session.tempo_map(), pos);
|
||||
return converter.to(_length_beats);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ MidiSource::midi_read (Evoral::EventSink<nframes_t>& dst, sframes_t source_start
|
||||
{
|
||||
Glib::Mutex::Lock lm (_lock);
|
||||
|
||||
BeatsFramesConverter converter(_session, source_start);
|
||||
BeatsFramesConverter converter(_session.tempo_map(), source_start);
|
||||
|
||||
if (_model) {
|
||||
Evoral::Sequence<double>::const_iterator& i = _model_iter;
|
||||
|
||||
@@ -120,7 +120,7 @@ SMFSource::read_unlocked (Evoral::EventSink<nframes_t>& destination, sframes_t s
|
||||
|
||||
size_t scratch_size = 0; // keep track of scratch to minimize reallocs
|
||||
|
||||
BeatsFramesConverter converter(_session, source_start);
|
||||
BeatsFramesConverter converter(_session.tempo_map(), source_start);
|
||||
|
||||
const uint64_t start_ticks = (uint64_t)(converter.from(start) * ppqn());
|
||||
|
||||
@@ -316,7 +316,7 @@ SMFSource::append_event_unlocked_frames (const Evoral::Event<nframes_t>& ev, sfr
|
||||
return;
|
||||
}
|
||||
|
||||
BeatsFramesConverter converter(_session, position);
|
||||
BeatsFramesConverter converter(_session.tempo_map(), position);
|
||||
|
||||
_length_beats = max(_length_beats, converter.from(ev.time()));
|
||||
|
||||
|
||||
@@ -1469,7 +1469,7 @@ TempoMap::tempo_section_at (nframes_t frame)
|
||||
}
|
||||
|
||||
const Tempo&
|
||||
TempoMap::tempo_at (nframes_t frame)
|
||||
TempoMap::tempo_at (nframes_t frame) const
|
||||
{
|
||||
Metric m (metric_at (frame));
|
||||
return m.tempo();
|
||||
@@ -1477,7 +1477,7 @@ TempoMap::tempo_at (nframes_t frame)
|
||||
|
||||
|
||||
const Meter&
|
||||
TempoMap::meter_at (nframes_t frame)
|
||||
TempoMap::meter_at (nframes_t frame) const
|
||||
{
|
||||
Metric m (metric_at (frame));
|
||||
return m.meter();
|
||||
|
||||
Reference in New Issue
Block a user