0

I have an Android application in Unity, which visualizes the audio that is played in AudioSource. It works very well in the editor and in building for desktop, but after building for Android, it lowers the resolution of the frequencies, and also the fps of the audio, and as a result, the visualization looks terrible.. If anyone knows how to get the full spectrum data as it happens in the editor and on the desktop, I would appreciate a solution 🙏

My code: audioSource.GetSpectrumData(spectrumData, 0, FFTWindow.Blackman);

I tried using FFTWindow's Rectangular, Triangle, Hamming, Blackman, BlackmanHarris mode, and it didn't help.

4
  • What exactly do you mean by resolution? How large do you define your spectrumData array? The array should have a size that is a power of two and the max size is 8192. The window just changes the leakage between the frequencies. Note that the quality is directly linked to the output device's sample rate since the FFT works on samples. So for debugging purposes you may want to print the AudioSettings.outputSampleRate for both cases. Commented Sep 6, 2024 at 16:35
  • Yes, that solved the problem. Thank you very much 🙏 Commented Sep 7, 2024 at 18:03
  • Not sure what I said may have solved the issue since I mainly asked clarifying questions :) It would be great to know what the actual issue or misconception was so others don't run into the same issue. Commented Sep 7, 2024 at 20:20
  • 1
    The problem was that Unity on Android for some reason samples at a lower rate than the editor, and this leads to visualization with low FPS. The 'AudioSettings.outputSampleRate = 48000;' solution worked great! Commented Sep 14, 2024 at 23:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.