Design: 16bit PCM stream to playback considerations

I receive a 'live' PCM stream (16bit, 8K, mono) from a device driver (it arrives in 512-2048 byte 'chunks').  I'd like to use JUCE to provide (minmal) buffering and playback (with mute/unmute capabilities).

Given the large number of Audio interfaces in JUCE, I'm not sure exactly what approach to take.

Though after looking through the Demo code and a few searches on this forum, I think I should create a new AudioSouce implementation and have its GetNextAudioBlock method read samples from the incoming feed.  Possibly using a BufferingAudioSource on 'top' of this newly created AudioSource to buffer 1.5-3s of audio as a means to smooth out possible CPU/networking hiccups?  The BufferingAudioSource would, then, be given to the transport for playback.

Do I even need to create my own, newly derived class as I have proposed, or is there a native JUCE class that could be fed the 'chunks' as they arrive?

Thanks in advance for your suggestions...

After a bit more research, for my needs, I think I'll take this approach...

  1. Create a ciruclar buffer class (specifiy size as a constructor parameter).  This class will manage the head/tail/length references protected by a lock.  FWIW,  I don't see one in JUCE so I'll go grab an implementation elsewhere.
  2. Create a new AudioSouce (BufferedAudioSource?) that uses the above Circular buffer and also exposes play, stop and an addData method.
  3. might have to make use of the ResamplingAudioSouce, but that's TBD.

Given the above prerequisites, as new PCM data is received I will call BufferedAudioSource.addData(byte *data, int dataLength).  The same BufferedAudioSource instance will be linked to the AudioDeviceManger via an AudioSourcePlayer to provide playback.

As I don't have a full grasp on the whole JUCE library, I have a feeling that a large part of what I described above may already exists within JUCE.  If it does, please let me know.  As there is no point in duplicating effort.


Thanks for reading along...smiley