Exemplo n.º 1
0
        public static int Init(Int32Buffer buffers)
        {
            Channel.buffers = buffers;
            int sourceId;

            numChannels = 0;
            for (int i = 0; i < MAX_CHANNELS; i++)
            {
                try
                {
                    AL10.AlGenSources(tmp);
                    sourceId = tmp.Get(0);
                    if (sourceId <= 0)
                    {
                        break;
                    }
                }
                catch (OpenALException e)
                {
                    break;
                }

                sources.Put(i, sourceId);
                channels[i] = new Channel(sourceId);
                numChannels++;
                AL10.AlSourcef(sourceId, AL10.AL_GAIN, 1F);
                AL10.AlSourcef(sourceId, AL10.AL_PITCH, 1F);
                AL10.AlSourcei(sourceId, AL10.AL_SOURCE_RELATIVE, AL10.AL_FALSE);
                AL10.AlSource(sourceId, AL10.AL_VELOCITY, NULLVECTOR);
                AL10.AlSourcei(sourceId, AL10.AL_LOOPING, AL10.AL_FALSE);
                AL10.AlSourcef(sourceId, AL10.AL_REFERENCE_DISTANCE, 200F);
                AL10.AlSourcef(sourceId, AL10.AL_MIN_GAIN, 0.0005F);
                AL10.AlSourcef(sourceId, AL10.AL_MAX_GAIN, 1F);
            }

            sources.Limit = numChannels;
            return(numChannels);
        }