[FFmpeg-devel] [PATCH] lavfi: add audio eval signal source
Nicolas George
nicolas.george at normalesup.org
Thu Oct 13 10:04:34 CEST 2011
Le duodi 22 vendémiaire, an CCXX, Stefano Sabatini a écrit :
> + at section aevalsrc
Cool idea, thanks.
> +Generate an audio signal generated by an expression.
The Department of Redundancy Department wants to thank you for having
generated such an awesome introduction line.
> +This source accepts in input an expression, which is evaluated and
> +used for generating a mono audio signal.
"to generate", I believe.
> + at table @option
> + at item E, PI, PHI
> +the corresponding mathematical approximated values for e
> +(euler number), pi (greek PI), PHI (golden ratio)
Shouldn't it be made part of the eval system once and for all?
> + at item n
> +the number of sample, starting from 0
> +
> + at item t
> +time of the sample expressed in second, starting from 0
The place of "the" is moving. I fond the second one easier to understand.
> +Generate a sin signal with frequence 4400 Hz:
> + at example
> +aevalsrc="sin(4400*t)"
sin(4400*t*2*PI), or it will be 700 Hz.
> + int64_t chlayouts[] = { AV_CH_LAYOUT_MONO, -1 };
As Michael said, the possibility to generate several channels would be cool.
OTOH, it could be left to a separate amerge filter: (n channels, p channels)
-> n+p channels.
> + eval->var_values[VAR_N] = eval->n;
> +
> + /* evaluate expression for each single sample */
> + for (i = 0; i < eval->nb_samples; i++) {
> + eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate;
> + *((double *) samplesref->data[0] + i) =
> + av_expr_eval(eval->expr, eval->var_values, NULL);
> + eval->var_values[VAR_N] = eval->n++;
> + }
The computation for VAR_N is wrong by one except on the first round because
n++ is postincrementation, not preincrementation. I believe it could be more
clearly written as:
for (i = 0; i < eval->nb_samples; i++) {
eval->var_values[VAR_N] = eval->n;
eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate;
*((double *) samplesref->data[0] + i) =
av_expr_eval(eval->expr, eval->var_values, NULL);
eval->n++;
}
with possibly the eval->n++ part of the third for clause.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111013/1ebecbd7/attachment.asc>
More information about the ffmpeg-devel
mailing list