ref: d4164a575e6809ad69000ef289f5b678c489e3fb
parent: 4dd9b89576ac56095b0b0fac58be49636617fe4b
author: Ulrich Klauer <ulrich@chirlu.de>
date: Mon Feb 11 21:07:10 EST 2013
tempo: calculate output length
--- a/src/tempo.c
+++ b/src/tempo.c
@@ -251,6 +251,7 @@
static int start(sox_effect_t * effp)
{
priv_t * p = (priv_t *)effp->priv;
+
if (p->factor == 1)
return SOX_EFF_NULL;
@@ -257,7 +258,14 @@
p->tempo = tempo_create((size_t)effp->in_signal.channels);
tempo_setup(p->tempo, effp->in_signal.rate, p->quick_search, p->factor,
p->segment_ms, p->search_ms, p->overlap_ms);
- effp->out_signal.length = SOX_UNKNOWN_LEN; /* TODO: calculate actual length */
+
+ effp->out_signal.length = SOX_UNKNOWN_LEN;
+ if (effp->in_signal.length != SOX_UNKNOWN_LEN) {
+ uint64_t in_length = effp->in_signal.length / effp->in_signal.channels;
+ uint64_t out_length = in_length / p->factor + .5;
+ effp->out_signal.length = out_length * effp->in_signal.channels;
+ }
+
return SOX_SUCCESS;
}