public IClydeBufferedAudioSource CreateBufferedAudioSource(int buffers)
        {
            var source = (uint)AL.GenSource();
            // ReSharper disable once PossibleInvalidOperationException
            var bufferHandles         = AL.GenBuffers(buffers);
            var unsignedBufferHandles = new uint[bufferHandles.Length];

            for (var i = 0; i < bufferHandles.Length; i++)
            {
                unsignedBufferHandles[i] = (uint)bufferHandles[i];
            }

            var audioSource = new BufferedAudioSource(this, source, unsignedBufferHandles);

            _bufferedAudioSources.Add(source, new WeakReference <BufferedAudioSource>(audioSource));
            return(audioSource);
        }
Beispiel #2
0
        internal SoundPlayer()
        {
            _alDevice = ALC.OpenDevice(null);

            var contextAttributes = new ALContextAttributes();

            _alContext = ALC.CreateContext(_alDevice, contextAttributes);

            ALC.MakeContextCurrent(_alContext);

            _bufferedAudioSources = new BufferedAudioSource[4];
            for (int i = 0; i < ChannelCount; i++)
            {
                _bufferedAudioSources[i] = new BufferedAudioSource();
            }

            //noise and wave channel are panned left initially
            _bufferedAudioSources[2].SetPosition(SoundOutputTerminal.Left);
            _bufferedAudioSources[3].SetPosition(SoundOutputTerminal.Left);

            //TODO: Start/restart the sources synchronously
        }
    private static IEnumerator OnClickEnd(BufferedAudioSource bufferedAudioSource, float time)
    {
        yield return(new WaitForSeconds(time));

        bufferedAudioSources.Buffer(bufferedAudioSource);
    }
 private void BufferBufferedAudioSource(BufferedAudioSource bufferedAudioSource, bool state)
 {
 }