/*
- Copyright (C) 2003 Paul Davis
+ Copyright (C) 2003-2006 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
using namespace ARDOUR;
using namespace PBD;
-jack_nframes_t Crossfade::_short_xfade_length = 0;
-Change Crossfade::ActiveChanged = ARDOUR::new_change();
+nframes_t Crossfade::_short_xfade_length = 0;
+Change Crossfade::ActiveChanged = new_change();
/* XXX if and when we ever implement parallel processing of the process()
callback, these will need to be handled on a per-thread basis.
Sample* Crossfade::crossfade_buffer_in = 0;
void
-Crossfade::set_buffer_size (jack_nframes_t sz)
+Crossfade::set_buffer_size (nframes_t sz)
{
if (crossfade_buffer_out) {
delete [] crossfade_buffer_out;
return (_in == other._in) && (_out == other._out);
}
-Crossfade::Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out,
- jack_nframes_t length,
- jack_nframes_t position,
+Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<AudioRegion> out,
+ nframes_t length,
+ nframes_t position,
AnchorPoint ap)
: _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 = ∈
- _out = &out;
+ _in = in;
+ _out = out;
_length = length;
_position = position;
_anchor_point = ap;
initialize ();
}
-Crossfade::Crossfade (ARDOUR::AudioRegion& a, ARDOUR::AudioRegion& b, CrossfadeModel model, bool act)
+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
_fade_out (0.0, 2.0, 1.0) // linear (gain coefficient) => -inf..+6dB
{
: _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
{
- Region* r;
+ boost::shared_ptr<Region> r;
XMLProperty* prop;
LocaleGuard lg (X_("POSIX"));
throw failed_constructor();
}
- if ((_in = dynamic_cast<AudioRegion*> (r)) == 0) {
+ if ((_in = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
throw failed_constructor();
}
throw failed_constructor();
}
- if ((_out = dynamic_cast<AudioRegion*> (r)) == 0) {
+ if ((_out = boost::dynamic_pointer_cast<AudioRegion> (r)) == 0) {
throw failed_constructor();
}
save_state ("initial");
}
-Crossfade::Crossfade (const Crossfade &orig, ARDOUR::AudioRegion *newin, ARDOUR::AudioRegion *newout)
+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)
{
}
int
-Crossfade::compute (AudioRegion& a, AudioRegion& b, CrossfadeModel model)
+Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioRegion> b, CrossfadeModel model)
{
- AudioRegion* top;
- AudioRegion* bottom;
- jack_nframes_t short_xfade_length;
+ boost::shared_ptr<AudioRegion> top;
+ boost::shared_ptr<AudioRegion> bottom;
+ nframes_t short_xfade_length;
short_xfade_length = _short_xfade_length;
- if (a.layer() < b.layer()) {
- top = &b;
- bottom = &a;
+ if (a->layer() < b->layer()) {
+ top = b;
+ bottom = a;
} else {
- top = &a;
- bottom = &b;
+ top = a;
+ bottom = b;
}
/* first check for matching ends */
return 0;
}
-jack_nframes_t
+nframes_t
Crossfade::read_at (Sample *buf, Sample *mixdown_buffer,
- float *gain_buffer, char * workbuf, jack_nframes_t start, jack_nframes_t cnt, uint32_t chan_n,
- jack_nframes_t read_frames, jack_nframes_t skip_frames)
+ float *gain_buffer, nframes_t start, nframes_t cnt, uint32_t chan_n,
+ nframes_t read_frames, nframes_t skip_frames)
{
- jack_nframes_t offset;
- jack_nframes_t to_write;
+ nframes_t offset;
+ nframes_t to_write;
if (!_active) {
return 0;
offset = start - _position;
- _out->read_at (crossfade_buffer_out, mixdown_buffer, gain_buffer, workbuf, start, to_write, chan_n, read_frames, skip_frames);
- _in->read_at (crossfade_buffer_in, mixdown_buffer, gain_buffer, workbuf, start, to_write, chan_n, read_frames, skip_frames);
+ _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);
float* fiv = new float[to_write];
float* fov = new float[to_write];
position and length, and so we know precisely how much data they could return.
*/
- for (jack_nframes_t n = 0; n < to_write; ++n) {
+ for (nframes_t n = 0; n < to_write; ++n) {
buf[n] = (crossfade_buffer_out[n] * fov[n]) + (crossfade_buffer_in[n] * fiv[n]);
}
}
OverlapType
-Crossfade::coverage (jack_nframes_t start, jack_nframes_t end) const
+Crossfade::coverage (nframes_t start, nframes_t end) const
{
- jack_nframes_t my_end = _position + _length;
+ nframes_t my_end = _position + _length;
if ((start >= _position) && (end <= my_end)) {
return OverlapInternal;
bool
Crossfade::update (bool force)
{
- jack_nframes_t newlen;
+ nframes_t newlen;
bool save = false;
if (_follow_overlap) {
{
Change what_we_care_about = Change (Region::MuteChanged|
Region::LayerChanged|
- ARDOUR::BoundsChanged);
+ BoundsChanged);
if (what_changed & what_we_care_about) {
refresh ();
pnode = new XMLNode ("point");
- snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when));
+ snprintf (buf, sizeof (buf), "%" PRIu32, (nframes_t) floor ((*ii)->when));
pnode->add_property ("x", buf);
- snprintf (buf, sizeof (buf), "%f", (*ii)->value);
+ snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf);
child->add_child_nocopy (*pnode);
}
pnode = new XMLNode ("point");
- snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*ii)->when));
+ snprintf (buf, sizeof (buf), "%" PRIu32, (nframes_t) floor ((*ii)->when));
pnode->add_property ("x", buf);
- snprintf (buf, sizeof (buf), "%f", (*ii)->value);
+ snprintf (buf, sizeof (buf), "%.12g", (*ii)->value);
pnode->add_property ("y", buf);
child->add_child_nocopy (*pnode);
}
for (i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == "point") {
- jack_nframes_t x;
+ nframes_t x;
float y;
prop = (*i)->property ("x");
for (i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == "point") {
- jack_nframes_t x;
+ nframes_t x;
float y;
XMLProperty* prop;
}
}
-jack_nframes_t
-Crossfade::set_length (jack_nframes_t len)
+nframes_t
+Crossfade::set_length (nframes_t len)
{
- jack_nframes_t limit;
+ nframes_t limit;
switch (_anchor_point) {
case StartOfIn:
return len;
}
-jack_nframes_t
+nframes_t
Crossfade::overlap_length () const
{
if (_fixed) {
}
void
-Crossfade::set_short_xfade_length (jack_nframes_t n)
+Crossfade::set_short_xfade_length (nframes_t n)
{
_short_xfade_length = n;
}