rory
YaBB Newbies
Offline
Posts: 12
Re: "merging" two audio samples
Reply #2 - Mar 29th , 2008, 4:26pm
Hi ddf, Could you maybe help me out a bit more with this? ie, walk me through the pseudo code needed. Basically, I'm trying to load an audio file, modify it somehow in the frequency domain, and play it back. Is that possible with minim? I guess I'd have to continually update the buffer and do forward FFT's on that? And if I could do all this in an Effect, in generate I could do the inverse transform and stuff that back into a buffer for playback. I tried modifying the ForwardFFT example in the following way, thinking that TestSignal should hopefully be generating a signal that sounds the same or similar to the AudioPlayer being looped ... but the results are noise. any advice? thanks so much R import ddf.minim.*; import ddf.minim.analysis.*; import ddf.minim.signals.*; AudioPlayer jingle; FFT fft; String windowName; TestSignal test; AudioOutput out; void setup() { size(512, 200); // always start Minim before you do anything with it Minim.start(this); jingle = Minim.loadFile("jingle.mp3"); jingle.loop(); fft = new FFT(jingle.left.size(), 44100); textFont(createFont("Arial", 16)); windowName = "None"; out = Minim.getLineOut(Minim.STEREO, 512); test = new TestSignal(); out.addSignal(test); } void draw() { background(0); stroke(255); fft.forward(jingle.left); for(int i = 0; i < fft.specSize(); i++) { line(i, height, i, height - fft.getBand(i)*4); } fill(255); // keep us informed about the window being used text("The window being used is: " + windowName, 5, 20); } void keyReleased() { if ( key == 'w' ) { fft.window(FFT.HAMMING); windowName = "Hamming"; } if ( key == 'e' ) { fft.window(FourierTransform.NONE); windowName = "None"; } } void stop() { // always close Minim audio classes when you finish with them out.close(); jingle.close(); super.stop(); } class TestSignal implements AudioSignal { void generate(float[] samp) { fft.inverse(samp); } void generate(float[] left, float[] right) { generate(left); generate(right); } }