Saving the results of inverse FFT as an audio file

edited October 2017 in Library Questions

Hi there, I have just recently (last night, really) started using Processing and the Minim library with the intention to do some sound processing. The idea is to load an audio file (both for live and offline analysis), use FFT, adjust some frequencies, use inverse FFT and produce and audio file both for immediate playback and writing to disk. I'm really struggling with saving the results of the buffer that the IFFT populates! I can see in the spectrum visualization that the right frequencies are adjusted and all seems fine, but this is the part where I'm not exactly sure what to do. Currently I am mostly looking into the offlineAnalysis example, because doing these things offline is a bit more important for now than doing them live.

Edit------ The issue with live playback still stands - what I have done is create a huge float array containing data from the IFFT. I have a MultiChannelBuffer and using setSample I replace the original samples with the ones from the float array and then it black using a sampler. I know this works because the audio is just fine, but the moment I modify something using scaleFreq or so, I hear a lot of clicking noise. I'm not exactly sure what I am doing wrong, I'm sure there is some common practice how people would approach this?

Tagged:

Answers

  • So, are you asking...?

    1. how do I play back a buffer produced by minim's IFFT?
    2. how do I save an IFFT buffer to a sound file?

    Can you share an MCVE / example code where you have created the IFFT buffer?

  • edited October 2017

    Pardon if I wasn't clear, I'm really asking for both. And my code is not even half working to show, I know I'm really off tracks. The example code I am looking at can be found here: https://github.com/ddf/Minim/blob/master/examples/Analysis/offlineAnalysis/offlineAnalysis.pde In the analyzeUsingAudioRecordingStream() method I simply created a float array as large as there are samples in the original file and for each "chunk" which is the size of the FFT I made a temporary buffer which would hold the IFFT data and add it to the big float array. So I just end up with a really long float array and am unsure how to use it. I tried modifying the MultiChannelBuffer based on this array and then playing it back, but it was also an utter disaster. I'm either being extremely silly or I'm missing some key info. (and to be more specific that approach plays it back super quickly)

  • Okay, it really is me being silly - I've nearly sorted out the live playback. I would still appreciate input on saving it offline and will update this accordingly once I'm done sorting this out in case this could help others.

Sign In or Register to comment.