How to play live audio data using playback #639
Replies: 2 comments 5 replies
-
This should be fairly simple. The device and decoder are fully decoupled. I just use the decoder for the sake of the example so some kind of sound is output. The device will run continuously until you stop it. When there is no data to output you can just not copy anything to the output buffer of the data callback and it'll just output silence. In your case, set the sample rate of the device (via the device config) to 32400. Also set your channel count and sample format. Then in the data callback simply copy over your data into the output buffer. I suppose you'll want to receive your data into some intermediate buffer and then from the data callback read from that buffer which you then output to the output buffer provided by the data callback. That part is just standard buffer management. Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Yes I hearing some sound but it is not good may be missing some data or may be problem of sync the data, I write a code in python for reading the socket data and play the sound using pyaudio library so its look clear but as you know I want to do this in c code but when I use miniaudio the sound the totally deferent. in pyaudio i use queue to put reading the chunks since my data coming in chunks (324 frames in one time) |
Beta Was this translation helpful? Give feedback.
-
Hi @mackron,
I am new in audio programing and not have a good understanding of audio data.
but as per your example, I saw that we use a decoder for play a file and send the decoder reference to the data callback and play until the data of decoder is not NULL. (its my understanding)
I am working on UDP live audio streaming I get the audio data in frames from UDP socket and I want to play that data using miniaudio. can you suggest me the helpful API with working information of function (What should I use).
I am getting data in frames like 324 frames per 10ms (1296 bytes per 10ms) because my audio frame rate is 32400 frame/s
Beta Was this translation helpful? Give feedback.
All reactions