- Home /
How to calculate buffer size of OnAudioFilterRead?
I want to store the data that is passed in OnAudioFilterRead
over two minutes. To do that I'm initialising the full data array at start but I can't figure out a way to find the exact size. To do that I would need to know the size of data passed in the function, number of channels, and frequency of that functions ie how many time a second is it called. The unity documentation has not been helpful for this case.
Data I can find:
From GetDPSBufferSize:
bufferSize = 1024
numOfBuffers = 4
From AudioSettings:
outputSampleRate = 48000
speakerMode = 2
What I want to calculate:
bufferSize = 2048
What I cannot find:
frequency O fOnAudioFilterRead = ???
I need to be able to calculate this at runtime since the app will run on various devices with different capabilities.
Answer by rbeldessi · Sep 20, 2018 at 12:15 AM
Since the output sample rate is the number of samples played per second if you want to calculate what it would be for 2 minutes of audio you can just do AudioSettings.outputSampleRate * 120;