So I am trying to do a cross synthesis program that takes two files and process them using the fft library. I have encountered several issues that bugged me for a while:
1. How to read two audio files and store them in buffer for fft calculation? Shall I make seperate buffer for each one?
2. I have to do fft for the two audio files and only take the real part of one and the imaginary part of another for calculating the magnitude and phase for the output signal. Thus, another ifft caulculation is needed for the out put signal. Does that mean I have to create three fft objects and three seperate threads to perform this?
3. Currently I am just loading samples for cross synth, but I am eventually thinking of doing live cross synth. Is it doable?

I have program the code but the terminal says :
Bela stopped
Building project ...
Build finished
Running project ...
Loaded the audio file 'theme.wav' with 360000 frames (8.2 seconds)
Loaded the audio file 'voice.wav' with 1501975 frames (34.1 seconds)
Segmentation fault
Makefile:613: recipe for target 'runide' failed
make: *** [runide] Error 139
Bela stopped
root@bela ~/Bela#

I guess part of the reason is because of using monofile player object for reading two files.

These are the main questions that I am concerning about at this point. I really appreciate if someone could help me with it! I can attach my code if it would help!

New Post: I noticed that the object for ifft of the output is not initialized. After that, the program runs. However, the sound is very clicky and the cpu reaches 90% after a few secs. I have to stop running it for just testing a few secs.

Running the two FFTs and one IFFT in the same auxiliary task is the right approach. If CPU time goes too high you'll need to reduce it by increasing the fft size or the hop size or both. You can also get some benefits from increasing the project's blocksize to 64 or 128 samples (not more).

Hi Giuliomoro! Thank you very much for the reply! But how can I get access to the real and imaginary values produced by the ffts and ifft( I mean how to index them)?

Also, I am not sure if reading two audio files into one buffer would help with the performance of it, like storing them interleaved in one array or seperately in one 2d array. Now I have seperate monofile play objects for each. And I am a bit confusing about how to extracting each file's informations from the bela context. Thank you!

Thank you giuliomoro ! Also, is it possible to dynamically change the fft size while performing?

Not while processing but you should be able to call setup() again between calls to fft/ifft. Note that the state won't be preserved

Note that the call to setup() is "slow" so if you need several different fft lengths available at the same time ,you are better off with having different objects,each with a fixed length

  • Keyi replied to this.

    giuliomoro Got it, thank you very much! I am trying to implementing it and will post if new issue comes up.