Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change the frequency using the ResamplingFilter? #20

Open
mx2012 opened this issue Jan 20, 2012 · 3 comments
Open

How to change the frequency using the ResamplingFilter? #20

mx2012 opened this issue Jan 20, 2012 · 3 comments

Comments

@mx2012
Copy link

mx2012 commented Jan 20, 2012

I'm trying to change the frequency of a Wav file,but the ResamplingFilter doesn't work correctly.
I made a simple case for test.I used the StandardizeFilter at first and then I used the ResamplingFilter.
I tried and it worked at first,but it stopped soon.

Here's something about the error:

Error: Fill called beyond the bounds of an unresizable CacheFilter
at com.noteflight.standingwave3.filters::CacheFilter/fill()
at com.noteflight.standingwave3.filters::ResamplingFilter/getSampleRange()
at com.noteflight.standingwave3.filters::ResamplingFilter/getSample()
at com.noteflight.standingwave3.output::AudioSampleHandler/handleSampleData()
at com.noteflight.standingwave3.output::AudioPlayer/handleSampleData()

and this is my code:

import com.noteflight.standingwave3.formats.WaveFile;
import flash.events.Event;
import flash.net.FileFilter;
import flash.net.FileReference;
import com.noteflight.standingwave3.output.AudioPlayer;
import com.noteflight.standingwave3.filters.StandardizeFilter;
import com.noteflight.standingwave3.filters.ResamplingFilter;

var file:FileReference;
var player:AudioPlayer;
function init() {
file=new FileReference();
file.addEventListener(Event.COMPLETE,complete);
file.addEventListener(Event.SELECT,select);
file.browse();
}
function select(e:Event):void {
file.load();
}
function complete(e:Event):void {
player=new AudioPlayer();
var fil:StandardizeFilter = new StandardizeFilter(WaveFile.createSample(file.data));
var rfil:ResamplingFilter= new ResamplingFilter(fil,1.01);
player.play(rfil);
}
init();

@maxl0rd
Copy link
Owner

maxl0rd commented Jan 25, 2012

This should work if you go

Sample -> ResamplingFilter -> StandardizeFilter

ResamplingFilter only works against a RandomAccessAudioSource, and so it is inserting a CacheFilter in there. Just swap the order and it should work.

StandardizeFilter is generally the absolute last item in the chain, and is only needed if the signal chain is not stereo/44.1k.

@mx2012
Copy link
Author

mx2012 commented Feb 5, 2012

Thanks!

@jbaudanza
Copy link
Contributor

@mx2012 Might want to checkout #25 It looks like there was some problems with the ResamplingFilter for stereo samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants