Example #1
0
        private Sound LoadSoundDirect([NotNull] string fileName, [NotNull] byte[] data, [NotNull] WaveFormat format, bool cloneData, bool manageResult)
        {
            var buffer = new AudioBuffer(_context);

            buffer.BufferData(data, format.SampleRate);

            var source = new AudioSource(_context);

            source.Bind(buffer);

            var sound = new Sound(source, buffer, format);

            if (manageResult)
            {
                if (cloneData)
                {
                    sound.Data = (byte[])data.Clone();
                }
                else
                {
                    sound.Data = data;
                }

                _loadedSounds.Add((fileName, sound));
            }

            return(sound);
        }
Example #2
0
 public void Dispose()
 {
     AudioSource?.Bind(null);
     AudioSource?.Dispose();
     AudioBuffer?.Dispose();
     AudioSource = null;
     AudioBuffer = null;
 }