From 8f5840027893e17eb864bc045cb8afb3a27d686c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 17 Apr 2010 18:44:00 +0000 Subject: add config parameter to control missing-region-channel behaviour. not controllable from GUI in this commit. default behaviour is as in ardour 2.8.7 git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6923 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/configuration_vars.h | 1 + libs/ardour/audioregion.cc | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index 2a81541e92..31a2ae9140 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -146,6 +146,7 @@ CONFIG_VARIABLE (nframes_t, over_length_long, "over-length-long", 10) /* miscellany */ +CONFIG_VARIABLE (bool, replicate_missing_region_channels, "replicate-missing-region-channels", false) CONFIG_VARIABLE (bool, hiding_groups_deactivates_groups, "hiding-groups-deactivates-groups", true) CONFIG_VARIABLE (bool, verify_remove_last_capture, "verify-remove-last-capture", true) CONFIG_VARIABLE (bool, no_new_session_dialog, "no-new-session-dialog", false) diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index a25ac839be..301e605a3e 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -537,6 +537,10 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit, nframes_t to_read; bool raw = (rops == ReadOpsNone); + if (n_channels() == 0) { + return 0; + } + if (muted() && !raw) { return 0; /* read nothing */ } @@ -583,18 +587,23 @@ AudioRegion::_read_at (const SourceList& srcs, nframes_t limit, } else { - /* track is N-channel, this region has less channels, so use a relevant channel - */ - - uint32_t channel = n_channels() % chan_n; - - if (srcs[channel]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) { - return 0; /* "read nothing" */ - } - - /* adjust read data count appropriately since this was a duplicate read */ - srcs[channel]->dec_read_data_count (to_read); - + if (Config->get_replicate_missing_region_channels()) { + /* track is N-channel, this region has less channels, so use a relevant channel + */ + + uint32_t channel = n_channels() % chan_n; + + if (srcs[channel]->read (mixdown_buffer, _start + internal_offset, to_read) != to_read) { + return 0; /* "read nothing" */ + } + + /* adjust read data count appropriately since this was a duplicate read */ + srcs[channel]->dec_read_data_count (to_read); + + } else { + /* region has no data for requested channel, so make it silent */ + memset (mixdown_buffer, 0, to_read * sizeof (Sample)); + } } if (rops & ReadOpsFades) { -- cgit v1.2.3