Master Crouch
Master Crouch

Reputation: 131

How to stream audio as data is downloaded?

How can I take data as it is being downloaded/received by my device and then play it through the iPhone speaker? I do not want to wait until the audio is fully downloaded.

Platform: iOS 8.0 +

File type: WAV

Sample Rate: 4000 Hz

Audio Type: PCM, 16 bit

Audio Channels: 1

Upvotes: 1

Views: 90

Answers (1)

hotpaw2
hotpaw2

Reputation: 70673

To minimize latency, pre-enable the apps audio session and request very short buffer durations. Start the RemoteIO Audio Unit output running with the output callback polling a circular buffer, otherwise playing a bit of silence. Then format (resample if needed) and store samples of the wave file, as any portions of the wave file are received, in the circular buffer.

Upvotes: 1

Related Questions