maxl0rd / standingwave3

Flash ActionScript3 dynamic audio library
http://www.noteflight.com
160 stars 25 forks source link

Lower rates problem #1

Closed hankpillow closed 14 years ago

hankpillow commented 14 years ago

Hi, I've read the the README and some comments inside the packages about lower rates ( less then 22050) and I realise we just don't have any code to cope with it.

I'm using the StandardFilter as recommended but still not working.

I'm doing something like this: sound_source = new StandardizeFilter( new SoundSource( new sound_class, new AudioDescriptor(AudioDescriptor.RATE_11025) ) );

But, looking inside the StandardizeFilter.as I checked that there isn't any condition to modify the samples (getSample) when rates are lower.

if (source.descriptor.rate == AudioDescriptor.RATE_44100) { sample = _source.getSample(numFrames); } else if (source.descriptor.rate == AudioDescriptor.RATE_22050) { sample = _source.getSample(Math.floor(numFrames/2)); }

And, following my "logic" I did something like this:

if (source.descriptor.rate == AudioDescriptor.RATE_44100) { sample = _source.getSample(numFrames); } else if (source.descriptor.rate == AudioDescriptor.RATE_22050) { sample = _source.getSample(Math.floor(numFrames/2)); }else if (source.descriptor.rate == AudioDescriptor.RATE_11025) { sample = _source.getSample(Math.floor(numFrames/4)); }

And I also changed position and frameCount methods.

But the result still mute.

Am I doing something wrong or this condition (lower rates) aren't working well yet?

cheers igor

maxl0rd commented 14 years ago

Hi Igor

Yes, StandardizeFilter actually only upsamples from 22k right now. It doesn't work with arbitrary sample rates. If you need to work with 11k, I would suggest writing your own Filter that quadruples the sample rate, perhaps with some interpolation, which would be fairly straightforward.