anarchuser / mic_stream

Flutter plugin to get an infinite audio stream from the microphone
https://pub.dev/packages/mic_stream
GNU General Public License v3.0
103 stars 70 forks source link

Splitting the audio into chunks #17

Closed AMPAlves closed 3 years ago

AMPAlves commented 3 years ago

Hi , I'm new to flutter and I was looking for a library that could help me record sound into a stream. I found your library and was pleased to see that it looks pretty promising.

I'm having some problems trying to understand everything within your example , so I would like to know If you have any idea on how I could split the audio stream into 0.5s chunks , for them to be sent to an external server.

anarchuser commented 3 years ago

You know your sample rate, right? A sample rate of x means there are x samples per second, i.e., you have a frequency of x Hz. If x samples make up one second then half a second contains 0.5 x* samples.

So to split your audio stream into chunks of 0.5s length, read out every 0.5 x* samples to send to your server.

I.e., if you have a sample rate of 44100 Hz, send packets with 22050 samples each to the server