virtualize audioregion, make crossfade IS-A audioregion

git-svn-id: svn://localhost/ardour2/trunk@1889 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-05-21 22:12:06 +00:00
parent b99c6c6e1d
commit 48d078b975
19 changed files with 526 additions and 134 deletions

View file

@ -75,7 +75,7 @@ class AudioPlaylist : public ARDOUR::Playlist
Crossfades _crossfades;
Crossfades _pending_xfade_adds;
void crossfade_invalidated (boost::shared_ptr<Crossfade>);
void crossfade_invalidated (boost::shared_ptr<Region>);
XMLNode& state (bool full_state);
void dump () const;

View file

@ -77,14 +77,14 @@ class AudioRegion : public Region
virtual nframes_t read_at (Sample *buf, Sample *mixdown_buf,
float *gain_buf, nframes_t position, nframes_t cnt,
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0) const;
uint32_t chan_n = 0) const;
virtual nframes_t master_read_at (Sample *buf, Sample *mixdown_buf,
float *gain_buf,
nframes_t position, nframes_t cnt, uint32_t chan_n=0) const;
virtual nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;
XMLNode& state (bool);
int set_state (const XMLNode&);
@ -137,11 +137,11 @@ class AudioRegion : public Region
AudioRegion (boost::shared_ptr<AudioSource>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (SourceList &, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (boost::shared_ptr<const AudioRegion>, nframes_t start, nframes_t length, const string& name, layer_t = 0, Region::Flag flags = Region::DefaultFlags);
AudioRegion (boost::shared_ptr<const AudioRegion>);
AudioRegion (boost::shared_ptr<AudioSource>, const XMLNode&);
AudioRegion (SourceList &, const XMLNode&);
private:
void init ();
void set_default_fades ();
void set_default_fade_in ();
void set_default_fade_out ();
@ -150,10 +150,8 @@ class AudioRegion : public Region
void recompute_gain_at_start ();
nframes_t _read_at (const SourceList&, Sample *buf, Sample *mixdown_buffer,
float *gain_buffer, nframes_t position, nframes_t cnt,
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0) const;
float *gain_buffer, nframes_t position, nframes_t cnt,
uint32_t chan_n = 0) const;
void recompute_at_start ();
void recompute_at_end ();
@ -174,6 +172,11 @@ class AudioRegion : public Region
uint32_t _fade_out_disabled;
protected:
/* default constructor for derived (compound) types */
AudioRegion (nframes_t, nframes_t, std::string name);
AudioRegion (boost::shared_ptr<const AudioRegion>);
int set_live_state (const XMLNode&, Change&, bool send);
virtual bool verify_start (nframes_t);
@ -182,8 +185,6 @@ class AudioRegion : public Region
virtual bool verify_length (nframes_t);
/*virtual void recompute_at_start () = 0;
virtual void recompute_at_end () = 0;*/
virtual nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;
};
} /* namespace ARDOUR */

View file

@ -199,7 +199,7 @@ class AutomationList : public PBD::StatefulDestructible
std::pair<AutomationList::iterator,AutomationList::iterator> range;
};
LookupCache lookup_cache;
mutable LookupCache lookup_cache;
AutoState _state;
AutoStyle _style;

View file

@ -23,7 +23,6 @@
#include <vector>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <sigc++/signal.h>
@ -40,7 +39,7 @@ namespace ARDOUR {
class AudioRegion;
class Playlist;
class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_from_this<ARDOUR::Crossfade>
class Crossfade : public ARDOUR::AudioRegion
{
public:
@ -66,7 +65,7 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
/* copy constructor to copy a crossfade with new regions. used (for example)
when a playlist copy is made
*/
Crossfade (const Crossfade &, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
Crossfade (boost::shared_ptr<Crossfade>, boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>);
/* the usual XML constructor */
@ -82,10 +81,8 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
boost::shared_ptr<ARDOUR::AudioRegion> out() const { return _out; }
nframes_t read_at (Sample *buf, Sample *mixdown_buffer,
float *gain_buffer, nframes_t position, nframes_t cnt,
uint32_t chan_n,
nframes_t read_frames = 0,
nframes_t skip_frames = 0);
float *gain_buffer, nframes_t position, nframes_t cnt,
uint32_t chan_n) const;
bool refresh ();
@ -105,13 +102,11 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
return (_in == a && _out == b) || (_in == b && _out == a);
}
nframes_t length() const { return _length; }
nframes_t overlap_length() const;
nframes_t position() const { return _position; }
void invalidate();
sigc::signal<void,boost::shared_ptr<Crossfade> > Invalidated;
sigc::signal<void,boost::shared_ptr<Region> > Invalidated;
sigc::signal<void,Change> StateChanged;
bool covers (nframes_t frame) const {
@ -133,6 +128,11 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
Curve& fade_out() { return _fade_out; }
nframes_t set_length (nframes_t);
bool is_dependent() const { return true; }
bool depends_on (boost::shared_ptr<Region> other) const {
return other == _in || other == _out;
}
static nframes_t short_xfade_length() { return _short_xfade_length; }
static void set_short_xfade_length (nframes_t n);
@ -151,14 +151,14 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
bool _active;
bool _in_update;
OverlapType overlap_type;
nframes_t _length;
nframes_t _position;
AnchorPoint _anchor_point;
bool _follow_overlap;
bool _fixed;
int32_t layer_relation;
Curve _fade_in;
Curve _fade_out;
mutable Curve _fade_in;
mutable Curve _fade_out;
static Sample* crossfade_buffer_out;
static Sample* crossfade_buffer_in;
@ -166,6 +166,9 @@ class Crossfade : public PBD::StatefulDestructible, public boost::enable_shared_
void initialize ();
int compute (boost::shared_ptr<ARDOUR::AudioRegion>, boost::shared_ptr<ARDOUR::AudioRegion>, CrossfadeModel);
bool update ();
protected:
nframes_t read_raw_internal (Sample*, nframes_t, nframes_t) const;
};

View file

@ -51,11 +51,9 @@ class MidiRegion : public Region
boost::shared_ptr<MidiSource> midi_source (uint32_t n=0) const;
nframes_t read_at (MidiRingBuffer& dst,
nframes_t position,
nframes_t dur,
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0) const;
nframes_t position,
nframes_t dur,
uint32_t chan_n = 0) const;
nframes_t master_read_at (MidiRingBuffer& dst,
nframes_t position,
@ -85,11 +83,9 @@ class MidiRegion : public Region
private:
nframes_t _read_at (const SourceList&, MidiRingBuffer& dst,
nframes_t position,
nframes_t dur,
uint32_t chan_n = 0,
nframes_t read_frames = 0,
nframes_t skip_frames = 0) const;
nframes_t position,
nframes_t dur,
uint32_t chan_n = 0) const;
void recompute_at_start ();
void recompute_at_end ();

View file

@ -177,7 +177,9 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
uint32_t n_channels() const { return _sources.size(); }
std::vector<string> master_source_names();
const SourceList& sources() const { return _sources; }
const SourceList& master_sources() const { return _master_sources; }
/* serialization */
@ -191,6 +193,9 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
uint64_t last_layer_op() const { return _last_layer_op; }
void set_last_layer_op (uint64_t when);
virtual bool is_dependent() const { return false; }
virtual bool depends_on (boost::shared_ptr<Region> other) const { return false; }
protected:
friend class RegionFactory;
@ -204,6 +209,10 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
Region (boost::shared_ptr<Source> src, const XMLNode&);
Region (SourceList& srcs, const XMLNode&);
/* this one is for derived types of derived types */
Region (nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags);
protected:
XMLNode& get_short_state (); /* used only by Session */
@ -221,9 +230,7 @@ class Region : public PBD::StatefulDestructible, public boost::enable_shared_fro
virtual bool verify_length (nframes_t);
virtual void recompute_at_start () = 0;
virtual void recompute_at_end () = 0;
PBD::ID _id;
string _name;
DataType _type;
Flag _flags;

View file

@ -79,7 +79,7 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr<const AudioPlaylist> other, stri
if ((*xfades)->out() == ar2) {
boost::shared_ptr<AudioRegion>in = boost::dynamic_pointer_cast<AudioRegion>(*in_n);
boost::shared_ptr<AudioRegion>out = boost::dynamic_pointer_cast<AudioRegion>(*out_n);
boost::shared_ptr<Crossfade> new_fade = boost::shared_ptr<Crossfade> (new Crossfade (*(*xfades), in, out));
boost::shared_ptr<Crossfade> new_fade = boost::shared_ptr<Crossfade> (new Crossfade (*xfades, in, out));
add_crossfade(new_fade);
break;
}
@ -125,8 +125,6 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf
{
nframes_t ret = cnt;
nframes_t end;
nframes_t read_frames;
nframes_t skip_frames;
/* optimizing this memset() away involves a lot of conditionals
that may well cause more of a hit due to cache misses
@ -151,8 +149,6 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf
end = start + cnt - 1;
read_frames = 0;
skip_frames = 0;
_read_data_count = 0;
map<uint32_t,vector<boost::shared_ptr<Region> > > relevant_regions;
@ -191,7 +187,7 @@ AudioPlaylist::read (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nf
for (vector<boost::shared_ptr<Region> >::iterator i = r.begin(); i != r.end(); ++i) {
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>(*i);
assert(ar);
ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n, read_frames, skip_frames);
ar->read_at (buf, mixdown_buffer, gain_buffer, start, cnt, chan_n);
_read_data_count += ar->read_data_count();
}
@ -309,19 +305,19 @@ AudioPlaylist::finalize_split_region (boost::shared_ptr<Region> o, boost::shared
if ((*x)->_in == orig) {
if (! (*x)->covers(right->position())) {
fade = boost::shared_ptr<Crossfade> (new Crossfade (**x, left, (*x)->_out));
fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, left, (*x)->_out));
} else {
// Overlap, the crossfade is copied on the left side of the right region instead
fade = boost::shared_ptr<Crossfade> (new Crossfade (**x, right, (*x)->_out));
fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, right, (*x)->_out));
}
}
if ((*x)->_out == orig) {
if (! (*x)->covers(right->position())) {
fade = boost::shared_ptr<Crossfade> (new Crossfade (**x, (*x)->_in, right));
fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, (*x)->_in, right));
} else {
// Overlap, the crossfade is copied on the right side of the left region instead
fade = boost::shared_ptr<Crossfade> (new Crossfade (**x, (*x)->_in, left));
fade = boost::shared_ptr<Crossfade> (new Crossfade (*x, (*x)->_in, left));
}
}
@ -478,9 +474,10 @@ void AudioPlaylist::notify_crossfade_added (boost::shared_ptr<Crossfade> x)
}
void
AudioPlaylist::crossfade_invalidated (boost::shared_ptr<Crossfade> xfade)
AudioPlaylist::crossfade_invalidated (boost::shared_ptr<Region> r)
{
Crossfades::iterator i;
boost::shared_ptr<Crossfade> xfade = boost::dynamic_pointer_cast<Crossfade> (r);
xfade->in()->resume_fade_in ();
xfade->out()->resume_fade_out ();

View file

@ -59,6 +59,27 @@ Change AudioRegion::EnvelopeActiveChanged = ARDOUR::new_change();
Change AudioRegion::ScaleAmplitudeChanged = ARDOUR::new_change();
Change AudioRegion::EnvelopeChanged = ARDOUR::new_change();
void
AudioRegion::init ()
{
_scale_amplitude = 1.0;
set_default_fades ();
set_default_envelope ();
listen_to_my_curves ();
}
/* constructor for use by derived types only */
AudioRegion::AudioRegion (nframes_t start, nframes_t length, string name)
: Region (start, length, name, DataType::AUDIO),
_fade_in (0.0, 2.0, 1.0, false),
_fade_out (0.0, 2.0, 1.0, false),
_envelope (0.0, 2.0, 1.0, false)
{
init ();
}
/** Basic AudioRegion constructor (one channel) */
AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, nframes_t length)
: Region (src, start, length, PBD::basename_nosuffix(src->name()), DataType::AUDIO, 0, Region::Flag(Region::DefaultFlags|Region::External)),
@ -71,12 +92,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n
afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
}
_scale_amplitude = 1.0;
set_default_fades ();
set_default_envelope ();
listen_to_my_curves ();
init ();
}
/* Basic AudioRegion constructor (one channel) */
@ -91,12 +107,7 @@ AudioRegion::AudioRegion (boost::shared_ptr<AudioSource> src, nframes_t start, n
afs->HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioRegion::source_offset_changed));
}
_scale_amplitude = 1.0;
set_default_fades ();
set_default_envelope ();
listen_to_my_curves ();
init ();
}
/* Basic AudioRegion constructor (many channels) */
@ -106,12 +117,7 @@ AudioRegion::AudioRegion (SourceList& srcs, nframes_t start, nframes_t length, c
, _fade_out (0.0, 2.0, 1.0, false)
, _envelope (0.0, 2.0, 1.0, false)
{
_scale_amplitude = 1.0;
set_default_fades ();
set_default_envelope ();
listen_to_my_curves ();
init ();
}
@ -308,24 +314,21 @@ AudioRegion::read_peaks (PeakData *buf, nframes_t npeaks, nframes_t offset, nfra
}
ARDOUR::nframes_t
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position,
nframes_t cnt,
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position, nframes_t cnt, uint32_t chan_n) const
{
return _read_at (_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, read_frames, skip_frames);
return _read_at (_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n);
}
ARDOUR::nframes_t
AudioRegion::master_read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer, nframes_t position,
nframes_t cnt, uint32_t chan_n) const
{
return _read_at (_master_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n, 0, 0);
return _read_at (_master_sources, buf, mixdown_buffer, gain_buffer, position, cnt, chan_n);
}
ARDOUR::nframes_t
AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
nframes_t position, nframes_t cnt,
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
nframes_t position, nframes_t cnt, uint32_t chan_n) const
{
// cerr << _name << "._read_at(" << position << ") - " << _position << endl;

View file

@ -28,6 +28,7 @@
#include <ardour/playlist.h>
#include <ardour/utils.h>
#include <ardour/session.h>
#include <ardour/source.h>
#include "i18n.h"
#include <locale.h>
@ -76,26 +77,26 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<Audio
nframes_t length,
nframes_t position,
AnchorPoint ap)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
: AudioRegion (position, length, "foobar"),
_fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
_in = in;
_out = out;
_length = length;
_position = position;
_anchor_point = ap;
_follow_overlap = false;
_active = Config->get_xfades_active ();
_fixed = true;
initialize ();
}
Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model, bool act)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
: AudioRegion (0, 0, "foobar"),
_fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
_in_update = false;
@ -108,11 +109,15 @@ Crossfade::Crossfade (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioR
_active = act;
initialize ();
}
Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
: _fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
: AudioRegion (0, 0, "foobar"),
_fade_in (0.0, 2.0, 1.0), // linear (gain coefficient) => -inf..+6dB
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
boost::shared_ptr<Region> r;
XMLProperty* prop;
@ -162,17 +167,16 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
}
}
Crossfade::Crossfade (const Crossfade &orig, boost::shared_ptr<AudioRegion> newin, boost::shared_ptr<AudioRegion> newout)
: _fade_in(orig._fade_in),
_fade_out(orig._fade_out)
Crossfade::Crossfade (boost::shared_ptr<Crossfade> orig, boost::shared_ptr<AudioRegion> newin, boost::shared_ptr<AudioRegion> newout)
: AudioRegion (boost::dynamic_pointer_cast<const AudioRegion> (orig)),
_fade_in (orig->_fade_in),
_fade_out (orig->_fade_out)
{
_active = orig._active;
_in_update = orig._in_update;
_length = orig._length;
_position = orig._position;
_anchor_point = orig._anchor_point;
_follow_overlap = orig._follow_overlap;
_fixed = orig._fixed;
_active = orig->_active;
_in_update = orig->_in_update;
_anchor_point = orig->_anchor_point;
_follow_overlap = orig->_follow_overlap;
_fixed = orig->_fixed;
_in = newin;
_out = newout;
@ -199,6 +203,13 @@ Crossfade::~Crossfade ()
void
Crossfade::initialize ()
{
/* merge source lists from regions */
_sources = _in->sources();
_sources.insert (_sources.end(), _out->sources().begin(), _out->sources().end());
_master_sources = _in->master_sources();
_master_sources.insert(_master_sources.end(), _out->master_sources().begin(), _out->master_sources().end());
_in_update = false;
_out->suspend_fade_out ();
@ -228,10 +239,27 @@ Crossfade::initialize ()
layer_relation = (int32_t) (_in->layer() - _out->layer());
}
nframes_t
Crossfade::read_raw_internal (Sample* buf, nframes_t start, nframes_t cnt) const
{
#if 0
Sample* mixdown = new Sample[cnt];
float* gain = new float[cnt];
nframes_t ret;
ret = read_at (buf, mixdown, gain, start, cnt, chan_n, cnt);
delete [] mixdown;
delete [] gain;
return ret;
#endif
return cnt;
}
nframes_t
Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n,
nframes_t read_frames, nframes_t skip_frames)
float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n) const
{
nframes_t offset;
nframes_t to_write;
@ -266,8 +294,8 @@ Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
offset = start - _position;
_out->read_at (crossfade_buffer_out, mixdown_buffer, gain_buffer, start, to_write, chan_n, read_frames, skip_frames);
_in->read_at (crossfade_buffer_in, mixdown_buffer, gain_buffer, start, to_write, chan_n, read_frames, skip_frames);
_out->read_at (crossfade_buffer_out, mixdown_buffer, gain_buffer, start, to_write, chan_n);
_in->read_at (crossfade_buffer_in, mixdown_buffer, gain_buffer, start, to_write, chan_n);
float* fiv = new float[to_write];
float* fov = new float[to_write];
@ -326,7 +354,7 @@ Crossfade::refresh ()
/* crossfades must be between non-muted regions */
if (_out->muted() || _in->muted()) {
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
@ -335,14 +363,14 @@ Crossfade::refresh ()
int32_t new_layer_relation = (int32_t) (_in->layer() - _out->layer());
if (new_layer_relation * layer_relation < 0) { // different sign, layers rotated
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
OverlapType ot = _in->coverage (_out->first_frame(), _out->last_frame());
if (ot == OverlapNone) {
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
@ -357,7 +385,7 @@ Crossfade::refresh ()
}
catch (NoCrossfadeHere& err) {
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
@ -365,7 +393,7 @@ Crossfade::refresh ()
} else {
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
@ -395,7 +423,7 @@ Crossfade::update ()
}
if (newlen == 0) {
Invalidated (shared_from_this());
Invalidated (shared_from_this ());
return false;
}
@ -856,5 +884,5 @@ Crossfade::set_short_xfade_length (nframes_t n)
void
Crossfade::invalidate ()
{
Invalidated (shared_from_this()); /* EMIT SIGNAL */
Invalidated (shared_from_this ()); /* EMIT SIGNAL */
}

View file

@ -130,8 +130,6 @@ MidiPlaylist::read (MidiRingBuffer& dst, nframes_t start,
nframes_t ret = 0;
nframes_t end = start + dur - 1;
//nframes_t read_frames = 0;
//nframes_t skip_frames = 0;
//_read_data_count = 0;
@ -151,7 +149,7 @@ MidiPlaylist::read (MidiRingBuffer& dst, nframes_t start,
for (vector<boost::shared_ptr<Region> >::iterator i = regs.begin(); i != regs.end(); ++i) {
// FIXME: ensure time is monotonic here
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(*i);
mr->read_at (dst, start, dur, chan_n, 0, 0);// FIXME read_frames, skip_frames);
mr->read_at (dst, start, dur, chan_n);
ret += mr->read_data_count();
}

View file

@ -109,24 +109,19 @@ MidiRegion::~MidiRegion ()
}
nframes_t
MidiRegion::read_at (MidiRingBuffer& out, nframes_t position,
nframes_t dur,
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
MidiRegion::read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n) const
{
return _read_at (_sources, out, position, dur, chan_n, read_frames, skip_frames);
return _read_at (_sources, out, position, dur, chan_n);
}
nframes_t
MidiRegion::master_read_at (MidiRingBuffer& out, nframes_t position,
nframes_t dur, uint32_t chan_n) const
MidiRegion::master_read_at (MidiRingBuffer& out, nframes_t position, nframes_t dur, uint32_t chan_n) const
{
return _read_at (_master_sources, out, position, dur, chan_n, 0, 0);
return _read_at (_master_sources, out, position, dur, chan_n);
}
nframes_t
MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst,
nframes_t position, nframes_t dur,
uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst, nframes_t position, nframes_t dur, uint32_t chan_n) const
{
// cerr << _name << "._read_at(" << position << ") - " << _position << endl;

View file

@ -1598,12 +1598,17 @@ Playlist::relayer ()
/* we want to go through regions from desired lowest to desired highest layer,
which depends on the layer model
*/
RegionList copy = regions;
/* sort according to the model */
if (Config->get_layer_model() == MoveAddHigher || Config->get_layer_model() == AddHigher) {
RegionSortByLastLayerOp cmp;
copy.sort (cmp);
}
for (RegionList::iterator i = copy.begin(); i != copy.end(); ++i) {
/* find the lowest layer that this region can go on */
@ -1636,7 +1641,7 @@ Playlist::relayer ()
layers[j].push_back (*i);
}
/* set up the layer numbers in the regions */
/* first pass: set up the layer numbers in the regions */
for (size_t j = 0; j < layers.size(); ++j) {
for (RegionList::iterator i = layers[j].begin(); i != layers[j].end(); ++i) {
(*i)->set_layer (j);

View file

@ -49,6 +49,27 @@ Change Region::LockChanged = ARDOUR::new_change ();
Change Region::LayerChanged = ARDOUR::new_change ();
Change Region::HiddenChanged = ARDOUR::new_change ();
/* derived-from-derived constructor (no sources in constructor) */
Region::Region (nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags)
: _name(name)
, _type(type)
, _flags(flags)
, _start(start)
, _length(length)
, _position(0)
, _sync_position(_start)
, _layer(layer)
, _first_edit(EditChangesNothing)
, _frozen(0)
, _read_data_count(0)
, _pending_changed(Change (0))
, _last_layer_op(0)
{
/* no sources at this point */
}
/** Basic Region constructor (single source) */
Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length, const string& name, DataType type, layer_t layer, Region::Flag flags)
: _name(name)
@ -67,6 +88,7 @@ Region::Region (boost::shared_ptr<Source> src, nframes_t start, nframes_t length
{
_sources.push_back (src);
_master_sources.push_back (src);
src->GoingAway.connect (bind (mem_fun (*this, &Region::source_deleted), src));
assert(_sources.size() > 0);
@ -245,7 +267,6 @@ Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
{
_sources.push_back (src);
if (set_state (node)) {
throw failed_constructor();
}
@ -909,7 +930,6 @@ Region::state (bool full_state)
fe = X_("id");
break;
default: /* should be unreachable but makes g++ happy */
cerr << "Odd region property found\n";
fe = X_("nothing");
break;
}