dzach
Joined: 03 Jul 2003 Posts: 41 Location: Athens, Greece

Posted: Wed Mar 03, 2004 10:34 pm Post subject: Snack "fade" filter upgrade request 


Kare
I am currently doing some sound envelope manipulations. The existing snack filter "fade" could be used as the basis for a piecewise envelope filter. The problem is that fade always starts or ends at zero, so no matter what I do, I get a zeroed sound at some point.
I had a look in the C source code of the Snack library, file jkFilter.c, trying to modify the file in order to achieve the desired result.
It seems to me that a generic equation of the type
whould be the simplest form for such a filter. In such a case, the additional computational cost would be one addition and one multiplication per loop.
The code changes I propose to jkFilter.c are (lines 1341  1363):
Code: 
case LINEAR:
if (mf>in) {
factor = (float) (a * mf>pos / mf>length + b);
} else {
factor = (float) (1.0  (float) (a * mf>pos / mf>length + b));
}
break;
case EXPONENTIAL:
if (mf>in) {
factor = (float) exp(10.0+10.0 * (a * mf>pos / mf>length + b));
} else {
factor = (float) exp(10.0 * (a * mf>pos / mf>length + b));
}
break;
case LOGARITHMIC:
if (mf>in) {
factor = (float) (0.5 + 0.5 * log(EXP_MINUS_1 + (EULER  EXP_MINUS_1)
* ((float) (a * mf>pos / mf>length + b))));
} else {
factor = (float) (0.5 + 0.5 * log(EXP_MINUS_1 + (EULER  EXP_MINUS_1)
* (1.0(float) (a * mf>pos / mf>length + b))));
}
break;

that is, replace the term
Code: 
mf>pos / mf> length

with the term
Code: 
(a * mf>pos / mf>length + b)

where
are the new coefficients. Their default values:
would result to exactly the same behaviour as before. There should be no need to change any existing application code, since coefficients a and b can be optional to the filter. New applications can take advantage of the new functionality.
I hope I've not made some rediculus mistake in the code...
I could do the compilation myself, but there are a myriad of things that I don't know about the API for the filters (i.e. how to introduce the two new coefficients a and b into the C code for the filter command options) and the snack library itself.
Is it possible to give it a try? There might, of course, be many other ways to implement such a filter; this is just a straight forward one.
Thank you very much. _________________ Dimitrios 
