limit on sources?

I’m working on a game and Sometimes when I have around 30 sounds playing at the same time i start to get errors and the sounds eventually stop playing all together. I devised a way to fix this problem by clearing the sources and making sure it doesn’t get over 30 sources at one time, but I want to know if there is anyway I can increase the number of sound sources I can play at once and if not then whats the limit?

As I get further along in my game project I can Imagine that I will eventually need more than 30 sounds playing at once. Thanks!

you can check out my project at www.wingsofapocalypse.blogspot.com if you are curious.

The number of sources available to you is hardware dependant. There is an OpenAL function to let you know how many sources are available… but I currently don’t have the OpenAL SDK and it’s docs installed ::slight_smile: I’m guessing it’ll be one of the alGet() or alcGet() functions, when passed one of the constants, named something like NUM_SOURCES.

(will edit this post once I re-install SDK and find the appropriate functions/constants)

[EDIT]: Maybe I’m going crazy, but I can’t seem to find what needs to be done to get the number of sources. I’m sure you can keep calling alGenSources() until it starts returning errors, but that doesn’t seem like a nice solution.

[EDIT again]: This site (http://btanks.sourceforge.net/blog/2007/08/28/openal-programming-faq/) lists it as something like the following (my rough translation from the C/C++ code on the site):


// Get size/number of attributes
int[] attributesSize = new int[1];
alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, attributesSize, 0);
int numAttributes = attributesSize[0];

// Get values of attributes
int[] attributes = new int[numAttributes];
alcGetIntegerv(device, ALC_ALL_ATTRIBUTES, numAttributes, attributes, 0);

The values in attributes[] will be ordered as follows:
ALCint attrs[] = {
ALC_STEREO_SOURCES, stereo_sources,
ALC_MONO_SOURCES, mono_sources,
ALC_INVALID, ALC_INVALID
};

So I guess the number of (mono) sources will be in attributes[3].

Thanks man! I haven’t tried it yet but I will get back to you and let you know if it works