Exemple #1
0
 protected override void Dispose(bool disposeManagedResources)
 {
     if (_handle > 0)
     {
         AL10.alDeleteBuffers(1, ref _handle);
         AudioSystem.alCheckError();
         _handle = 0;
     }
     base.Dispose(disposeManagedResources);
 }
Exemple #2
0
        public AudioBuffer(WavFile wavFile) : this()
        {
            int format = 0;

            switch (wavFile.Channels)
            {
            case 1:
            {
                switch (wavFile.BitsPerSample)
                {
                case 8:
                    format = AL10.AL_FORMAT_MONO8;
                    break;

                case 16:
                    format = AL10.AL_FORMAT_MONO16;
                    break;

                default:
                    throw new NotSupportedException("Invalid audio format!");
                }
            }
            break;

            case 2:
            {
                switch (wavFile.BitsPerSample)
                {
                case 8:
                    format = AL10.AL_FORMAT_STEREO8;
                    break;

                case 16:
                    format = AL10.AL_FORMAT_STEREO16;
                    break;

                default:
                    throw new NotSupportedException("Invalid audio format!");
                }
            }
            break;
            }


            AL10.alBufferData(_handle, format, wavFile.Buffer, wavFile.Size, wavFile.Fequency);
            AudioSystem.alCheckError();
        }
Exemple #3
0
 public AudioBuffer()
 {
     AL10.alGenBuffers(1, out _handle);
     AudioSystem.alCheckError();
 }
Exemple #4
0
 public AudioSource()
 {
     AL10.alGenSources(1, out _handle);
     AudioSystem.alCheckError();
 }