ofSoundStream

Hi all,

I’ve just started using ofSoundStream and have a few questions if anyone can help:

(1) What does stream over/underflow detected mean and what causes it?

(2) When I try to call ofSoundStreamEnd() it always seems to result in an out of scope compiler error - how should I be using it? (I can output zeros to mute the stream once the soundfile has ended but I’d like to be able to actually stop the stream)

Any help would be much appreciated!

OK - Have had another look at this and although the online documentation says ofSoundStreamEnd() ends the audio stream, actually this function does not exist in ofSoundStream.cpp (at least not on my windows version of openFrameworks).

Need to use ofSoundStreamClose() instead.

Stream or buffer under/overflow means that you are sending not enough/too many samples to your sound card. You don’t have that much control over this aside from trying not doing too much audio processing at any one time.

The most common is the stream underflow…this means that the system wasn’t able to feed the sound card buffers with enough data, meaning that there is a interruption in the stream (which usually translates as a pop or click in your speakers). Generally I think this is caused by the CPU being too busy processing stuff, or perhaps bad drivers. You can avoid this by having good hardware (integrated sound cards in the motherboard are usually bad), and up to date drivers. Also look up information on how to optimise your system for audio. It is operating system dependent, but generally involves removing background processes and tweaking other system settings.

Overflow is when you are sending too much data to the sound card and it’s buffers have to drop data because it can’t keep up.

Thanks grimus!

That makes sense - the laptop I’m working on isn’t optimised for audio at all, and just has an integrated sound card in the motherboard. Plays back fine most of the time but probably explains the odd glitch.

I just started working with this class and came across the same error. I was getting it because my bufferSize was too small and my computer could not keep up - i have to go with a minimum of 256. Anything less give me an over/underflow :frowning: