Fork me on GitHub


The SoLoud::WavStream class represents a wave sound effect that is streamed off disk while it's playing. The source files may be in various RIFF WAV file formats, FLAC, MP3 or Ogg Vorbis files.

The sounds are loaded in pieces while they are playing, which takes more processing power than playing samples from memory, but they require much less memory.

For short or often used samples, you may want to use SoLoud::Wav instead.


The wav loader takes just one parameter, the file name:

result load(const char *aFilename); // File to load

If loading fails, the function will return an error code.

SoLoud::WavStream muzak;

If the loading function is called while there are instances playing, the result is undefined (most likely a crash).


The loadFile() can be used to load audio from a SoLoud::File object. This is useful for integrating with virtual filesystems / packfiles, such as PhysFS.


Alternate way of loading samples is to read from a memory buffer.

result loadMem(unsigned char *aMem, int aLength, 
               bool aCopy, bool aTakeOwnership);

If loading fails, the sample will be silent.

SoLoud::WavStream boom;
boom.loadMem(boomMemoryResource, boomMemoryResourceLength);

SoLoud function assumes that the pointer and the data pointed will be valid as long as SoLoud needs them. You can use the aCopy parameter to tell SoLoud to take a copy of the data instead of using the pointers directly, and the aTakeOwnership parameter to tell SoLoud to free the pointer when the object is being destroyed.


The loadToMem() tells SoLoud to load the whole file to a memory buffer and stream it from there. This is similar as to using the Wav object, except that the data is not decoded to raw samples on load.

This can be useful if you expect the media the data resides on to be slow or busy, but don't want to spend the memory for the completely decoded audio data.


The loadFileToMem() function performs the memory loading of loadToMem() using SoLoud::File objects, same way as loadFile() does.


This function can be used to set the wav stream to loop.


Calling this function will not affect "live" sound sources.


As with any other audio source, you can attach filters to wav stream audio sources.

gHipster.setFilter(0, &gLofi);


You can stop all instances of a wav stream sound source with stop(). This is equivalent of calling soloud.stopAudioSource() with the sound source.



The length, in seconds, of this wav stream can be queried with this function.

double t = gRecord.getLength();


Set the inaudible behavior of the sound. By default, if a sound is inaudible, it's paused, and will resume when it becomes audible again. With this function you can tell SoLoud to either kill the sound if it becomes inaudible, or to keep ticking the sound even if it's inaudible.

// Keep on talking even if I'm not around
gSpeech.setInaudibleBehavior(true, false);


Set the default volume of the instances created from this audio source.


WavStream.setLoopPoint(), WavStream.getLoopPoint()

If looping is enabled, the loop point is, by default, the start of the stream. The loop point can be changed, and current loop point can be queried with these functions.

double t = snd.getLoopPoint();
snd.setLoopPoint(t + 1); // skip 1 second more when looping
snd.setLoopPoint(0); // loop from start

Inherited 3d audio interfaces

Like all other audio sources, WavStream inherits the 3d audio interfaces. Please refer to the 3d audio chapter for details on:

Copyright©2013-2020 Jari Komppa