# Audio playback buffering in background thread

**URL:** <https://forum.juce.com/t/audio-playback-buffering-in-background-thread/1502>\
**Category:** Audio Plugins\
**Created:** [February 27, 2007, 1:37pm UTC](https://forum.juce.com/t/audio-playback-buffering-in-background-thread/1502 "2007-02-27T13:37:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cialz](https://avatars.discourse-cdn.com/v4/letter/c/8c91f0/32.png) [@cialz](https://forum.juce.com/u/cialz)\
**Post date:** [February 27, 2007, 1:37pm UTC](https://forum.juce.com/t/audio-playback-buffering-in-background-thread/1502/1 "2007-02-27T13:37:28Z")

</div>

Hi to all,  
I’m writing a simple VST plugin, one of its purposes is to play N audio files, with N \>=1 && N \< 32, it can play mono, stereo or multichannel files.

My previous version reads audio data directly inside the process callback (I know it is a bad idea but it was very easy to code)

Now I would improve the processing moving the reading stuff inside a background thread witch can read many frames ahead (for example 2sec). This can solve problems with higher sample rate and tiny host block sizes.

Unfortunately I don’t have so much experience in thread programming, I took a look at BufferingAudioSource code.

I need to support many audio file formats so I’m using libsndfile and could not use juce classes to do this task.

Any suggestion on where I can start developing this slice of code?

thanx in advance  
c.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 8:57pm UTC](https://forum.juce.com/t/audio-playback-buffering-in-background-thread/1502/2 "2017-05-12T20:57:45Z")

</div>

Closed on May 12, 2017, 8:57pm UTC


