Exemple #1
0
        public override void LoadContent()
        {
            if (!contentLoaded)
            {
                contentLoaded = true;
                spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);

                font = ScreenManager.Content.Load<SpriteFont>("Fonts/MenuFont");
                inputManager = new XnaInputManager(ScreenManager.Game, info.Game);
                gfx = new XnaGraphicsManager(info.Game.Width, info.Game.Height, info.Game.PixelFormat, game.Window, ScreenManager.GraphicsDevice);
                ScreenManager.Game.Services.AddService<Core.Graphics.IGraphicsManager>(gfx);
                var saveFileManager = ServiceLocator.SaveFileManager;
#if WINDOWS_UWP
                audioDriver = new XAudio2Mixer();
#else
                audioDriver = new XnaAudioDriver();
#endif
                audioDriver.Play();

                // init engines
                engine = info.MetaEngine.Create(info, gfx, inputManager, audioDriver, saveFileManager);
                engine.ShowMenuDialogRequested += OnShowMenuDialogRequested;
                game.Services.AddService(engine);

                Task.Factory.StartNew(() =>
                {
                    UpdateGame();
                });
            }
        }
        /** Adds a single frame of sound data to the buffer */
        public void OutputSound(IAudioOutput audioOutput)
        {
            if (soundEnabled)
            {
                return;
            }

            int numChannels = 2;             // Always stereo for Game Boy
            int numSamples  = audioOutput.GetSamplesAvailable();

            byte[] b = new byte[numChannels * numSamples];

            if (channel1Enable)
            {
                channel1.Play(b, numSamples, numChannels);
            }
            if (channel2Enable)
            {
                channel2.Play(b, numSamples, numChannels);
            }
            if (channel3Enable)
            {
                channel3.Play(b, numSamples, numChannels);
            }
            if (channel4Enable)
            {
                channel4.Play(b, numSamples, numChannels);
            }

            audioOutput.Play(b);
        }
Exemple #3
0
        /// <summary>
        ///   Plays the recorded audio stream.
        /// </summary>
        ///
        private void btnPlay_Click(object sender, EventArgs e)
        {
            // First, we rewind the stream
            stream.Seek(0, SeekOrigin.Begin);

            // Then we create a decoder for it
            decoder = new WaveDecoder(stream);

            // Configure the track bar so the cursor
            // can show the proper current position
            if (trackBar1.Value < decoder.Frames)
            {
                decoder.Seek(trackBar1.Value);
            }
            trackBar1.Maximum = decoder.Samples;

            // Here we can create the output audio device that will be playing the recording
            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);

            // Wire up some events
            output.FramePlayingStarted += output_FramePlayingStarted;
            output.NewFrameRequested   += output_NewFrameRequested;
            output.Stopped             += output_PlayingFinished;

            // Start playing!
            output.Play();

            updateButtons();
        }
Exemple #4
0
        public override void LoadContent()
        {
            if (!contentLoaded)
            {
                contentLoaded = true;
                spriteBatch   = new SpriteBatch(ScreenManager.GraphicsDevice);

                font         = ScreenManager.Content.Load <SpriteFont>("Fonts/MenuFont");
                inputManager = new XnaInputManager(ScreenManager.Game, info.Game);
                gfx          = new XnaGraphicsManager(info.Game.Width, info.Game.Height, info.Game.PixelFormat, game.Window, ScreenManager.GraphicsDevice);
                ScreenManager.Game.Services.AddService <Core.Graphics.IGraphicsManager>(gfx);
                var saveFileManager = ServiceLocator.SaveFileManager;
#if WINDOWS_UWP
                audioDriver = new XAudio2Mixer();
#else
                audioDriver = new XnaAudioDriver();
#endif
                audioDriver.Play();

                // init engines
                engine = info.MetaEngine.Create(info, gfx, inputManager, audioDriver, saveFileManager);
                engine.ShowMenuDialogRequested += OnShowMenuDialogRequested;
                game.Services.AddService(engine);

                Task.Factory.StartNew(() =>
                {
                    UpdateGame();
                });
            }
        }
Exemple #5
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            stream.Seek(0, SeekOrigin.Begin);
            decoder = new WaveDecoder(stream);

            if (trackBar1.Value < decoder.Frames)
            {
                decoder.Seek(trackBar1.Value);
            }
            trackBar1.Maximum = decoder.Samples;

            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);
            output.NewFrameRequested   += new EventHandler <NewFrameRequestedEventArgs>(output_NewFrameRequested);
            output.Stopped             += new EventHandler(output_PlayingFinished);
            output.FramePlayingStarted += new EventHandler <PlayFrameEventArgs>(output_FramePlayingStarted);
            output.Play();

            updateButtons();
        }
        /** Adds a single frame of sound data to the buffer */
        public void OutputSound(IAudioOutput audioOutput)
        {
            if (soundEnabled)
                return;

            int numChannels = 2; // Always stereo for Game Boy
            int numSamples = audioOutput.GetSamplesAvailable();

            byte[] b = new byte[numChannels * numSamples];

            if (channel1Enable)
                channel1.Play(b, numSamples, numChannels);
            if (channel2Enable)
                channel2.Play(b, numSamples, numChannels);
            if (channel3Enable)
                channel3.Play(b, numSamples, numChannels);
            if (channel4Enable)
                channel4.Play(b, numSamples, numChannels);

            audioOutput.Play(b);
        }
Exemple #7
0
        /// <summary>
        ///   Plays the recorded audio stream.
        /// </summary>
        /// 
        private void btnPlay_Click(object sender, EventArgs e)
        {
            // First, we rewind the stream
            stream.Seek(0, SeekOrigin.Begin);

            // Then we create a decoder for it
            decoder = new WaveDecoder(stream);

            // Configure the track bar so the cursor
            // can show the proper current position
            if (trackBar1.Value < decoder.Frames)
                decoder.Seek(trackBar1.Value);
            trackBar1.Maximum = decoder.Samples;

            // Here we can create the output audio device that will be playing the recording
            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);

            // Wire up some events
            output.FramePlayingStarted += output_FramePlayingStarted;
            output.NewFrameRequested += output_NewFrameRequested;
            output.Stopped += output_PlayingFinished;

            // Start playing!
            output.Play();

            updateButtons();
        }
Exemple #8
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            stream.Seek(0, SeekOrigin.Begin);
            decoder = new WaveDecoder(stream);

            if (trackBar1.Value < decoder.Frames)
                decoder.Seek(trackBar1.Value);
            trackBar1.Maximum = decoder.Samples;

            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);

            output.FramePlayingStarted += output_FramePlayingStarted;
            output.NewFrameRequested += output_NewFrameRequested;
            output.Stopped += output_PlayingFinished;

            output.Play();

            updateButtons();
        }