Initialize() public method

Initializes the OpenALAudioBuffer class.
public Initialize ( byte audioData, WaveFormat format ) : void
audioData byte The Buffer.
format WaveFormat The WaveFormat.
return void
コード例 #1
0
        /// <summary>
        /// Initializes the audio provider with the given audio source.
        /// </summary>
        /// <param name="audioSource">The AudioSource.</param>
        public void Initialize(IAudioSource audioSource)
        {
            var openALAudioSource = audioSource as OpenALAudioSource;

            if (openALAudioSource == null)
            {
                throw new InvalidOperationException("The specified audio source does not match the AudioProvider type.");
            }

            //clean old playback if existent
            if (_audioBuffer != null)
            {
                _audioBuffer.Dispose();
            }

            _audioSource = audioSource;
            var audioFormat = DetectAudioFormat(openALAudioSource.WaveFormat);

            _audioBuffer = OpenALDevice.DefaultDevice.CreateAudioBuffer(audioFormat);
            _audioBuffer.PlaybackChanged += AudioBufferPlaybackChanged;
            Volume = _volume;
            Pan    = _pan;
            _audioBuffer.Initialize(openALAudioSource.WaveData, openALAudioSource.WaveFormat);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the audio provider with the given audio source.
        /// </summary>
        /// <param name="audioSource">The AudioSource.</param>
        public void Initialize(IAudioSource audioSource)
        {
            var openALAudioSource = audioSource as OpenALAudioSource;
            if (openALAudioSource == null)
            {
                throw new InvalidOperationException("The specified audio source does not match the AudioProvider type.");
            }

            //clean old playback if existent
            if (_audioBuffer != null)
            {
                _audioBuffer.Dispose();
            }

            _audioSource = audioSource;
            var audioFormat = DetectAudioFormat(openALAudioSource.WaveFormat);
            _audioBuffer = OpenALDevice.DefaultDevice.CreateAudioBuffer(audioFormat);
            _audioBuffer.PlaybackChanged += AudioBufferPlaybackChanged;
            Volume = _volume;
            Pan = _pan;
            _audioBuffer.Initialize(openALAudioSource.WaveData, openALAudioSource.WaveFormat);
        }