RegionFX: fix replicated channels

This commit is contained in:
Robin Gareus
2024-08-15 18:36:31 +02:00
parent a2a9ceab92
commit d9752bb2c5

View File

@@ -775,7 +775,16 @@ AudioRegion::read_at (Sample* buf,
/* for mono regions without plugins, mixdown_buffer is valid as-is */
if (n_chn > 1 || have_fx) {
/* copy data for current channel */
copy_vector (mixdown_buffer, _readcache.get_audio (chan_n).data (), to_read);
if (chan_n < n_channels()) {
copy_vector (mixdown_buffer, _readcache.get_audio (chan_n).data (), to_read);
} else {
if (Config->get_replicate_missing_region_channels()) {
chan_n = chan_n % n_channels ();
copy_vector (mixdown_buffer, _readcache.get_audio (chan_n).data (), to_read);
} else {
memset (mixdown_buffer, 0, sizeof (Sample) * to_read);
}
}
}
_cache_start = internal_offset;