summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-04-09 18:07:15 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-04-09 18:07:15 +0000
commitb4b891b6ab4741b132d306188f47a275e6119a5b (patch)
treeb72ff459ef330e8f0752f41f9592290fee889b28 /libs/ardour
parenta3741ccac8946e5e69810e614e5ef28ab86ed548 (diff)
make region opacity work again; fix several other region context menu items that may have been messing with region state in unforeseen ways
git-svn-id: svn://localhost/ardour2/trunk@1691 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/audioregion.h4
-rw-r--r--libs/ardour/audioregion.cc66
-rw-r--r--libs/ardour/session_butler.cc2
3 files changed, 52 insertions, 20 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h
index 92f678a1a2..a450d90008 100644
--- a/libs/ardour/ardour/audioregion.h
+++ b/libs/ardour/ardour/audioregion.h
@@ -65,7 +65,7 @@ class AudioRegion : public Region
void normalize_to (float target_in_dB = 0.0f);
- uint32_t n_channels() { return sources.size(); }
+ uint32_t n_channels() const { return sources.size(); }
vector<string> master_source_names();
bool envelope_active () const { return _flags & Region::EnvelopeActive; }
@@ -95,6 +95,8 @@ class AudioRegion : public Region
int set_state (const XMLNode&);
static void set_default_fade (float steepness, nframes_t len);
+ bool fade_in_is_default () const;
+ bool fade_out_is_default () const;
enum FadeShape {
Linear,
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index db6e5fc089..1d3032c1e0 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -452,12 +452,12 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
nframes_t buf_offset;
nframes_t to_read;
- /* precondition: caller has verified that we cover the desired section */
-
- if (chan_n >= sources.size()) {
+ if (muted()) {
return 0; /* read nothing */
}
-
+
+ /* precondition: caller has verified that we cover the desired section */
+
if (position < _position) {
internal_offset = 0;
buf_offset = _position - position;
@@ -482,17 +482,29 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
mixdown_buffer += buf_offset;
}
- if (muted()) {
- return 0; /* read nothing */
- }
-
_read_data_count = 0;
- if (srcs[chan_n]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
- return 0; /* "read nothing" */
- }
+ if (chan_n < n_channels()) {
+
+ if (srcs[chan_n]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) {
+
+ return 0; /* "read nothing" */
+ }
+
+ _read_data_count += srcs[chan_n]->read_data_count();
- _read_data_count += srcs[chan_n]->read_data_count();
+ } else {
+
+ /* track is N-channel, this region has less channels; silence the ones
+ we don't have.
+ */
+
+ memset (mixdown_buffer, 0, sizeof (Sample) * cnt);
+
+ /* no fades required */
+
+ goto merge;
+ }
/* fade in */
@@ -503,7 +515,7 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
/* see if this read is within the fade in */
if (internal_offset < fade_in_length) {
-
+
nframes_t limit;
limit = min (to_read, fade_in_length - internal_offset);
@@ -577,13 +589,15 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
Session::apply_gain_to_buffer (mixdown_buffer, to_read, _scale_amplitude);
}
+ merge:
+
if (!opaque()) {
/* gack. the things we do for users.
*/
buf += buf_offset;
-
+
for (nframes_t n = 0; n < to_read; ++n) {
buf[n] += mixdown_buffer[n];
}
@@ -946,6 +960,18 @@ AudioRegion::set_fade_out_active (bool yn)
send_change (FadeOutActiveChanged);
}
+bool
+AudioRegion::fade_in_is_default () const
+{
+ return _fade_in_shape == Linear && _fade_in.back()->when == 64;
+}
+
+bool
+AudioRegion::fade_out_is_default () const
+{
+ return _fade_out_shape == Linear && _fade_out.back()->when == 64;
+}
+
void
AudioRegion::set_default_fade_in ()
{
@@ -1310,14 +1336,16 @@ void
AudioRegion::suspend_fade_in ()
{
if (++_fade_in_disabled == 1) {
- set_fade_in_active (false);
+ if (fade_in_is_default()) {
+ set_fade_in_active (false);
+ }
}
}
void
AudioRegion::resume_fade_in ()
{
- if (_fade_in_disabled && --_fade_in_disabled == 0) {
+ if (--_fade_in_disabled == 0 && _fade_in_disabled) {
set_fade_in_active (true);
}
}
@@ -1326,14 +1354,16 @@ void
AudioRegion::suspend_fade_out ()
{
if (++_fade_out_disabled == 1) {
- set_fade_out_active (false);
+ if (fade_out_is_default()) {
+ set_fade_out_active (false);
+ }
}
}
void
AudioRegion::resume_fade_out ()
{
- if (_fade_out_disabled && --_fade_out_disabled == 0) {
+ if (--_fade_out_disabled == 0 &&_fade_out_disabled) {
set_fade_out_active (true);
}
}
diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc
index 16c8d9cffa..afb284b0f4 100644
--- a/libs/ardour/session_butler.cc
+++ b/libs/ardour/session_butler.cc
@@ -248,7 +248,7 @@ Session::butler_thread_work ()
gettimeofday (&begin, 0);
boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
-
+
for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
boost::shared_ptr<Diskstream> ds = *i;