©2003 Kåre Sjölander and Jonas Beskow
Introduction Download Documentation Links Forum
WaveSurfer user forum

FAQ  FAQ
Search  Search
Memberlist  Memberlist
Register  Register
Profile  Profile
Login  Login

Snack "fade" filter upgrade request

 
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer
View previous topic :: View next topic  
Author Message
dzach



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

PostPosted: Wed Mar 03, 2004 10:34 pm    Post subject: Snack "fade" filter upgrade request Reply with quote

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

Code:
f(t)=at+b


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
Code:

float   a,b

are the new coefficients. Their default values:
Code:

a = 1.0
b = 0.0

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
Back to top
View users profile Send private message Send email Visit posters website
kare



Joined: 16 Aug 2002
Posts: 371
Location: KTH, Centre for Speech Technology

PostPosted: Fri Mar 12, 2004 3:40 pm    Post subject: Reply with quote

Thanks for the code, seems straighforward. I'll have a look at this when I have a chance.

Thanks!

Kåre
Back to top
View users profile Send private message Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.1 © 2001, 2002 phpBB Group