[vlc-devel] audio_filter_patch

jpd at videolan.org jpd at videolan.org
Wed Aug 12 09:40:42 CEST 2009


On Wed, Aug 12, 2009 at 11:08:48AM +0800, wangxiang wrote:
> 

A bit of text describing the patch and so on would be helpful.

You'll want to double-check your sources since the patch appears to be
reversed, the copyright seems a bit out of date, and, well, the spelling
could stand some improvements (eg. `emphisize', `emphsized'). I have a
few more quibbles on form but let's look at the code first.


> -void Allpass :: Initialize (void)
> -{
> -  int bufferLength = int(delay*samplingRate/1000);
> -  bufferStart = new float[bufferLength];

Not too sure what a bad_alloc exception will do when it gets back to the
(C) core but I think it's reasonable to assume it won't be good. So it's
probably a better idea to use new (nothrow) and do something useful if
you get a 0 pointer back.

#include <new>
using std::nothrow;

float *buffer = new (nothrow) float[buflen];
if( !buffer )
    /* report the error, bail out */;

You'll also want to make sure the rounding for your bufferLength
calculations does what you expect. What happens if (delay*rate)%1000!=0 ?


> -public:
> -  Allpass(float delay, float gain);  //delay in milliseconds
> -  void Initialize(void);
> -  void Process(void);
> -  void Cleanup(void);
> -  void SetParam(float delayTime, float feedbackGain,int numsamples);
> -  void SetSignal(float * inputs, float * outputs);
> -
> -  ~Allpass(){;}

Why do you have a separate constructor and _then_ call Initialize?
Same with Cleanup and the destructor.


> -#define samplingRate 441000
> -#define f_delay 30
> -#define f_feedback 0.6

Please use all-caps to identify macros or use a const variable to hold
the value. Either is fine.




More information about the vlc-devel mailing list