Beispiel #1
0
        private IBufferedSoundProvider _bufferedProvider;                                 // One of the preceding buffers, or null if no source is set

        public Sound(IntPtr mainWindowHandle)
        {
            if (OSTailoredCode.IsUnixHost)
            {
                // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config)
                _outputDevice = new OpenALSoundOutput(this);
            }
            else
            {
                if (Global.Config.SoundOutputMethod == ESoundOutputMethod.OpenAL)
                {
                    _outputDevice = new OpenALSoundOutput(this);
                }
                if (Global.Config.SoundOutputMethod == ESoundOutputMethod.DirectSound)
                {
                    _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle, Global.Config.SoundDevice);
                }
                if (Global.Config.SoundOutputMethod == ESoundOutputMethod.XAudio2)
                {
                    _outputDevice = new XAudio2SoundOutput(this);
                }
            }

            if (_outputDevice == null)
            {
                _outputDevice = new DummySoundOutput(this);
            }
        }
Beispiel #2
0
        private IBufferedSoundProvider _bufferedProvider;                                 // One of the preceding buffers, or null if no source is set

        public Sound(IntPtr mainWindowHandle)
        {
            // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config)
            if (PlatformLinkedLibSingleton.RunningOnUnix)
            {
                _outputDevice = new OpenALSoundOutput(this);
            }
            else
            {
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
                {
                    _outputDevice = new OpenALSoundOutput(this);
                }
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
                {
                    _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle);
                }
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
                {
                    _outputDevice = new XAudio2SoundOutput(this);
                }
            }

            if (_outputDevice == null)
            {
                _outputDevice = new DummySoundOutput(this);
            }
        }
Beispiel #3
0
        private IBufferedSoundProvider _bufferedProvider;                                 // One of the preceding buffers, or null if no source is set

        public Sound(IntPtr mainWindowHandle)
        {
            if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
            {
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
                {
                    _outputDevice = new OpenALSoundOutput(this);
                }
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
                {
                    _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle);
                }
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
                {
                    _outputDevice = new XAudio2SoundOutput(this);
                }
            }
            else
            {
                _outputDevice = new OpenALSoundOutput(this);              // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config)
            }
            if (_outputDevice == null)
            {
                _outputDevice = new DummySoundOutput(this);
            }
        }
        public Sound(IntPtr mainWindowHandle, Config config, Func <double> getCoreVsyncRateCallback)
        {
            BlockAlign = BytesPerSample * ChannelCount;

            _getCoreVsyncRateCallback = getCoreVsyncRateCallback;
            _outputProvider           = new SoundOutputProvider(_getCoreVsyncRateCallback);
            Config = config;

            if (OSTailoredCode.IsUnixHost)
            {
                // if DirectSound or XAudio is chosen, use OpenAL, otherwise comply with the user's choice
                _outputDevice = config.SoundOutputMethod == ESoundOutputMethod.Dummy
                                        ? (ISoundOutput) new DummySoundOutput(this)
                                        : new OpenALSoundOutput(this, config.SoundDevice);
            }
            else
            {
                _outputDevice = config.SoundOutputMethod switch
                {
                    ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, config.SoundDevice),
                    ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this, config.SoundDevice),
                    ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this, config.SoundDevice),
                    _ => new DummySoundOutput(this)
                };
            }
        }
Beispiel #5
0
        public Gameboy(
            GameboyOptions options,
            Cartridge rom,
            IDisplay display,
            IController controller,
            ISoundOutput soundOutput,
            SerialEndpoint serialEndpoint)
        {
            _display  = display;
            _gbc      = rom.Gbc;
            SpeedMode = new SpeedMode();

            var interruptManager = new InterruptManager(_gbc);

            _timer = new Timer(interruptManager, SpeedMode);
            Mmu    = new Mmu();

            var oamRam = new Ram(0xfe00, 0x00a0);

            _dma        = new Dma(Mmu, oamRam, SpeedMode);
            _gpu        = new Gpu(display, interruptManager, _dma, oamRam, _gbc);
            _hdma       = new Hdma(Mmu);
            _sound      = new Sound(soundOutput, _gbc);
            _serialPort = new SerialPort(interruptManager, serialEndpoint, SpeedMode);

            Mmu.AddAddressSpace(rom);
            Mmu.AddAddressSpace(_gpu);
            Mmu.AddAddressSpace(new Joypad(interruptManager, controller));
            Mmu.AddAddressSpace(interruptManager);
            Mmu.AddAddressSpace(_serialPort);
            Mmu.AddAddressSpace(_timer);
            Mmu.AddAddressSpace(_dma);
            Mmu.AddAddressSpace(_sound);

            Mmu.AddAddressSpace(new Ram(0xc000, 0x1000));
            if (_gbc)
            {
                Mmu.AddAddressSpace(SpeedMode);
                Mmu.AddAddressSpace(_hdma);
                Mmu.AddAddressSpace(new GbcRam());
                Mmu.AddAddressSpace(new UndocumentedGbcRegisters());
            }
            else
            {
                Mmu.AddAddressSpace(new Ram(0xd000, 0x1000));
            }

            Mmu.AddAddressSpace(new Ram(0xff80, 0x7f));
            Mmu.AddAddressSpace(new ShadowAddressSpace(Mmu, 0xe000, 0xc000, 0x1e00));

            Cpu = new Cpu(Mmu, interruptManager, _gpu, display, SpeedMode);

            interruptManager.DisableInterrupts(false);

            if (!options.UseBootstrap)
            {
                InitiliseRegisters();
            }
        }
Beispiel #6
0
 public Sound(ISoundOutput output, bool gbc)
 {
     _allModes[0] = new SoundMode1(gbc);
     _allModes[1] = new SoundMode2(gbc);
     _allModes[2] = new SoundMode3(gbc);
     _allModes[3] = new SoundMode4(gbc);
     _output      = output;
 }
        public SpotifySessionFactory(IBus bus, ISoundOutput soundOutput, ISpotifyLogProcessor spotifyLogProcessor)
        {
            if (bus == null) throw new ArgumentNullException("bus");
            if (soundOutput == null) throw new ArgumentNullException("soundOutput");
            if (spotifyLogProcessor == null) throw new ArgumentNullException("spotifyLogProcessor");

            _bus = bus;
            _soundOutput = soundOutput;
            _spotifyLogProcessor = spotifyLogProcessor;
        }
Beispiel #8
0
		public void Dispose()
		{
			if (_disposed) return;

			StopSound();

			_soundOutput.Dispose();
			_soundOutput = null;

			_disposed = true;
		}
Beispiel #9
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            StopSound();

            _soundOutput.Dispose();
            _soundOutput = null;

            _disposed = true;
        }
Beispiel #10
0
        public PauseCommandHandler(ISoundOutput soundOutput, ISession session)
        {
            if (soundOutput == null)
            {
                throw new ArgumentNullException("soundOutput");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            _soundOutput = soundOutput;
            _session     = session;
        }
Beispiel #11
0
        public Sound(IntPtr mainWindowHandle)
        {
            #if WINDOWS
            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
                _soundOutput = new DirectSoundSoundOutput(this, mainWindowHandle);

            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
                _soundOutput = new XAudio2SoundOutput(this);
            #endif

            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
                _soundOutput = new OpenALSoundOutput(this);

            if (_soundOutput == null)
                _soundOutput = new DummySoundOutput(this);
        }
 private void RetroThreadFinished(object sender, EventArgs e)
 {
     _retroEmulator.Dispose();
     _retroEmulator = null;
     if (_textureOutput != null)
     {
         _textureOutput.Dispose();
         _textureOutput = null;
     }
     if (_soundOutput != null)
     {
         _soundOutput.Dispose();
         _soundOutput = null;
     }
     Logger.Debug("LibRetroFrontend: Libretro thread finished");
 }
Beispiel #13
0
        public Device(Cartridge.Cartridge cartridge, DeviceType type, IRenderer renderer, ISoundOutput soundOutput, byte[] bootRom)
        {
            Log = new LoggerConfiguration()
                  .MinimumLevel.Information()
                  .CreateLogger();

            // A bit of double checking that we're loading a valid cartridge for the device type
            if (cartridge.CGBSupportCode == CGBSupportCode.CGBExclusive && type == DeviceType.DMG)
            {
                Log.Error("Cartridge can't be loaded because it's CGB only and this device was created as DMG");
                throw new ApplicationException("Cartridge can't be loaded because it's CGB only and this device was created as DMG");
            }

            Type = type;
            Mode = cartridge.CGBSupportCode switch
            {
                CGBSupportCode.CGBExclusive => DeviceType.CGB,
                CGBSupportCode.CGBCompatible => type,
                CGBSupportCode.CGBIncompatible => DeviceType.DMG,
                _ => throw new ArgumentOutOfRangeException()
            };

            Renderer    = renderer;
            SoundOutput = soundOutput;

            InterruptRegisters = new InterruptRegisters();
            ControlRegisters   = new ControlRegisters();
            APU           = new APU(this);
            LCDRegisters  = new LCDRegisters(this);
            Cartridge     = cartridge;
            MMU           = new MMU(bootRom, this);
            CPU           = new CPU.CPU(this);
            _cpuGenerator = CPU.GetEnumerator();
            LCDDriver     = new LCDDriver(this);
            Timer         = new Timer(this);
            DMAController = new DMAController(this);
            JoypadHandler = new JoypadHandler(this);

            // Set default values if there was no passed in boot rom
            if (bootRom == null)
            {
                SkipBootRom();
            }
        }
Beispiel #14
0
        public StopCommandHandler(ISpotifySession spotifySession, ISoundOutput soundOutput, ISession session)
        {
            if (spotifySession == null)
            {
                throw new ArgumentNullException("spotifySession");
            }
            if (soundOutput == null)
            {
                throw new ArgumentNullException("soundOutput");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            _spotifySession = spotifySession;
            _soundOutput    = soundOutput;
            _session        = session;
        }
Beispiel #15
0
        public SpotifySessionFactory(IBus bus, ISoundOutput soundOutput, ISpotifyLogProcessor spotifyLogProcessor)
        {
            if (bus == null)
            {
                throw new ArgumentNullException("bus");
            }
            if (soundOutput == null)
            {
                throw new ArgumentNullException("soundOutput");
            }
            if (spotifyLogProcessor == null)
            {
                throw new ArgumentNullException("spotifyLogProcessor");
            }

            _bus                 = bus;
            _soundOutput         = soundOutput;
            _spotifyLogProcessor = spotifyLogProcessor;
        }
        protected void InitializeLibRetro()
        {
            _textureOutput = new TextureOutput(SkinContext.Device);
            //_soundOutput = new LibRetroDirectSound(SkinContext.Form.Handle, _settings.AudioDeviceId, _settings.AudioBufferSize);
            _soundOutput   = new LibRetroXAudio(_settings.AudioDeviceId);
            _retroEmulator = new LibRetroEmulator(_corePath)
            {
                SaveDirectory   = _settings.SavesDirectory,
                SystemDirectory = _settings.SystemDirectory,
                LogDelegate     = RetroLogDlgt,
                Controller      = _controllerWrapper,
                AudioOutput     = _soundOutput as IAudioOutput,
                VideoOutput     = _textureOutput
            };

            SetCoreVariables();
            _retroEmulator.Init();
            Logger.Debug("LibRetroFrontend: Libretro initialized");
        }
Beispiel #17
0
        private IBufferedSoundProvider _bufferedProvider;                                 // One of the preceding buffers, or null if no source is set

        public Sound(IntPtr mainWindowHandle)
        {
            if (OSTailoredCode.IsUnixHost)
            {
                // if DirectSound or XAudio is chosen, use OpenAL, otherwise comply with the user's choice
                _outputDevice = GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.Dummy
                                        ? (ISoundOutput) new DummySoundOutput(this)
                                        : new OpenALSoundOutput(this);
            }
            else
            {
                _outputDevice = GlobalWin.Config.SoundOutputMethod switch
                {
                    ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, GlobalWin.Config.SoundDevice),
                    ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this),
                    ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this),
                    _ => new DummySoundOutput(this)
                };
            }
        }
Beispiel #18
0
        private IBufferedSoundProvider _bufferedProvider;                                 // One of the preceding buffers, or null if no source is set

        public Sound(IntPtr mainWindowHandle)
        {
            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
            {
                _outputDevice = new OpenALSoundOutput(this);
            }
            if (!PlatformLinkedLibSingleton.RunningOnUnix)
            {
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
                {
                    _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle);
                }
                if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
                {
                    _outputDevice = new XAudio2SoundOutput(this);
                }
            }
            if (_outputDevice == null)
            {
                _outputDevice = new DummySoundOutput(this);
            }
        }
Beispiel #19
0
        public Sound(IntPtr mainWindowHandle)
        {
#if WINDOWS
            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
            {
                _soundOutput = new DirectSoundSoundOutput(this, mainWindowHandle);
            }

            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2)
            {
                _soundOutput = new XAudio2SoundOutput(this);
            }
#endif

            if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
            {
                _soundOutput = new OpenALSoundOutput(this);
            }

            if (_soundOutput == null)
            {
                _soundOutput = new DummySoundOutput(this);
            }
        }
Beispiel #20
0
        public static void Initialise(IKeyboardInput keyboardInput, IWindow window, IMouseInput mouseInput, ISoundOutput soundOutput, long seed)
        {
            if (_instance != null)
            {
                throw new System.InvalidOperationException("Already Created");
            }

            Keyboard.Initialise(keyboardInput);
            _instance              = new Engine();
            _instance._root        = new Ent(null);
            _instance._time        = new Time();
            _instance._window      = window;
            _instance._toBeUpdated = new Stack <IEnt>();
            _instance._mouse       = mouseInput;
            _instance._sound       = soundOutput;
            _instance.Seed         = seed;

            _instance._window.OnStart();
            _instance._time.Start();
        }