ref: 2b0c994d72b4c2e8ddfdf1aa7aeea3e175b22bdb
parent: f43e5e352291d69d2a4dad8e3fb11d66f8dc938c
author: Ulrich Klauer <ulrich@chirlu.de>
date: Fri Jan 13 17:31:46 EST 2012
fade/gain/remix: drain only complete wide samples Let the fade, gain, and repeat effects be drain()ed only in complete wide samples. Fixes bug 3420899 (gain -n truncates output if number of channels not a power of two). Probably silence needs to be changed, too, but it is broken anyway.
--- a/ChangeLog
+++ b/ChangeLog
@@ -80,6 +80,8 @@
o Stricter syntax checking for several effects (might reveal bugs hidden
in existing scripts). (Ulrich Klauer)
o Calculate output audio length for most effects. (Ulrich Klauer)
+ o Fix problems with several effects when the buffer size was not evenly
+ divisible by the number of channels. [3420899] (Ulrich Klauer)
Misc:
--- a/src/fade.c
+++ b/src/fade.c
@@ -285,6 +285,7 @@
size_t t_chan = 0;
len = *osamp;
+ len -= len % effp->in_signal.channels;
*osamp = 0;
if (fade->do_out && fade->samplesdone < fade->out_stop &&
--- a/src/gain.c
+++ b/src/gain.c
@@ -78,7 +78,7 @@
}
effp->out_signal.mult = p->make_headroom? &p->fixed_gain : NULL;
if (!p->do_equalise && !p->do_balance && !p->do_balance_no_clip)
- effp->flows = 1;
+ effp->flows = 1; /* essentially a conditional SOX_EFF_MCHAN */
}
p->mult = p->max = p->min = 0;
if (p->do_scan) {
@@ -194,6 +194,8 @@
priv_t * p = (priv_t *)effp->priv;
size_t len;
int result = SOX_SUCCESS;
+
+ *osamp -= *osamp % effp->in_signal.channels;
if (p->do_scan) {
if (!p->mult)
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -69,6 +69,8 @@
priv_t * p = (priv_t *)effp->priv;
size_t odone = 0, n;
+ *osamp -= *osamp % effp->in_signal.channels;
+
while ((p->remaining_samples || p->remaining_repeats) && odone < *osamp) {
if (!p->remaining_samples) {
p->remaining_samples = p->num_samples;