Ejemplo n.º 1
0
        /// <summary>
        /// Updates the XNA FrameworkDispatcher and updates the playing state
        /// if sound has stopped playing.
        /// </summary>
        /// <param name="sender">DispatcherTimer.</param>
        /// <param name="e">Event arguments.</param>
        void dt_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch { }

            if (true == App.AudioModel.IsPlaying)
            {
                if (!wasapiInUse)
                {
                    if (!xnaAudio.SoundIsPlaying())
                    {
                        xnaAudio.StopPlayback();
                        App.AudioModel.IsPlaying = false;
                    }
                }
                else
                {
                    App.AudioModel.IsPlaying = wasapiAudio.Update();
                }
            }
            else if (true == App.AudioModel.IsRecording && wasapiInUse)
            {
                // XnaAudio stores the buffer in callback method.
                // Buffer is retrieved manually when recording using WASAPI.
                byte[] bytes = null;
                int    size  = wasapiAudio.ReadBytes(out bytes);

                if (size > 0)
                {
                    App.AudioModel.AudioBuffer = bytes;
                    App.AudioModel.stream.Write(bytes, 0, size);
                }
            }
        }
Ejemplo n.º 2
0
        void intervalTimer_Tick(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch { }

            if (wasapiIsEnabled)
            {
                // XnaAudio stores the buffer in callback method.
                // Buffer is retrieved manually when recording using WASAPI.
                byte[] bytes = null;
                int    size  = wasapiAudio.ReadBytes(out bytes);

                if (size > 0)
                {
                    OnBufferReady(bytes);
                }
            }
        }
Ejemplo n.º 3
0
        private void RetrieveAudio(object sender, EventArgs e)
        {
            try { FrameworkDispatcher.Update(); }
            catch
            {
                // ignored
            }

            if (!wasapiIsEnabled)
            {
                return;
            }

            // XnaAudio stores the buffer in callback method.
            // Buffer is retrieved manually when recording using WASAPI.
            byte[] bytes;
            var    size = wasapiAudio.ReadBytes(out bytes);

            if (size > 0)
            {
                OnAudioReported(bytes);
            }
        }