Inheritance: IMusicEngine, IAudioStream
 public void Init(Player_AppleII player, byte[] args)
 {
     _player = player;
     _index = 0;
     _param0 = args[0];
     Debug.Assert(_param0 > 0);
 }
 public void Init(Player_AppleII player, byte[] args)
 {
     _player = player;
     _params = args;
     _updateRemain1 = 80;
     _updateRemain2 = 10;
     _count = 0;
 }
 public void Init(Player_AppleII player, byte[] args)
 {
     _player = player;
     _delta = args[0];
     _count = args[1];
     _interval = args[2];
     _limit = args[3];
     _decInterval = (args[4] >= 0x40);
 }
 public void Init(Player_AppleII player, byte[] args)
 {
     _player = player;
     _params = args;
     _pos = 1;
 }
Example #5
0
        void SetupMusic()
        {
            var selectedDevice = Settings.AudioDevice;
            var deviceHandle = MidiDriver.DetectDevice(Game.Music, selectedDevice);

            switch (MidiDriver.GetMusicType(deviceHandle))
            {
                case MusicType.Null:
                    Sound.MusicType = MusicDriverTypes.None;
                    break;
                case MusicType.PCSpeaker:
                    Sound.MusicType = MusicDriverTypes.PCSpeaker;
                    break;
                case MusicType.PCjr:
                    Sound.MusicType = MusicDriverTypes.PCjr;
                    break;
                case MusicType.CMS:
                    Sound.MusicType = MusicDriverTypes.CMS;
                    break;
                case MusicType.FMTowns:
                    Sound.MusicType = MusicDriverTypes.FMTowns;
                    break;
                case MusicType.AdLib:
                    Sound.MusicType = MusicDriverTypes.AdLib;
                    break;
                case MusicType.C64:
                    Sound.MusicType = MusicDriverTypes.C64;
                    break;
                case MusicType.AppleIIGS:
                    Sound.MusicType = MusicDriverTypes.AppleIIGS;
                    break;
                default:
                    Sound.MusicType = MusicDriverTypes.Midi;
                    break;
            }

            // Init iMuse
            if (Game.Version >= 7)
            {
                // Setup for digital iMuse is performed in another place

                // HACK: don't know why I have to keep this to work
                var adlibMidiDriver = (MidiDriver)MidiDriver.CreateMidi(Mixer, MidiDriver.DetectDevice(MusicDriverTypes.AdLib, "adlib"));
                // Setup for digital iMuse is performed in another place
                Audio.IMuse.IMuse.Create(null, adlibMidiDriver);
            }
            else if (Game.Platform == Platform.Apple2GS && Game.Version == 0)
            {
                MusicEngine = new Player_AppleII(this, Mixer);
            }
            else if (Game.Platform == Platform.C64 && Game.Version <= 1)
            {
                var sid = new SID();
                MusicEngine = new Player_SID(this, Mixer, sid);
            }
            else if (_game.Platform == Platform.Amiga && Game.Version == 2)
            {
                var modPlayer = new Player_MOD(Mixer);
                MusicEngine = new Player_V2A(this, modPlayer);
            }
            else if (Game.Platform == Platform.Amiga && Game.Version == 3)
            {
                var modPlayer = new Player_MOD(Mixer);
                MusicEngine = new Player_V3A(this, modPlayer);
            }
            else if (Game.Platform == Platform.Amiga && Game.Version <= 4)
            {
                MusicEngine = new Player_V4A(this, Mixer);
            }
            else if (Game.Platform == Platform.Macintosh && Game.GameId == GameId.Loom)
            {
                MusicEngine = new Player_V3M(this, Mixer);
            }
            else if (Game.Platform == Platform.Macintosh && Game.GameId == GameId.Monkey1)
            {
                MusicEngine = new Player_V5M(this, Mixer);
            }
            else if (Game.GameId == GameId.Maniac && Game.Version == 1)
            {
                MusicEngine = new Player_V1(this, Mixer, Sound.MusicType == MusicDriverTypes.PCjr);
            }
            else if ((Sound.MusicType == MusicDriverTypes.PCSpeaker || Sound.MusicType == MusicDriverTypes.PCjr) && (Game.Version >= 2 && Game.Version <= 4))
            {
                MusicEngine = new Player_V2(this, Mixer, Sound.MusicType == MusicDriverTypes.PCjr);
            }
            else if (Sound.MusicType == MusicDriverTypes.CMS)
            {
                MusicEngine = new Player_V2CMS(this, Mixer);
            }
            else if (Game.Platform == Platform.FMTowns && (Game.Version == 3 || Game.GameId == GameId.Monkey1))
            {
                MusicEngine = TownsPlayer = new Player_Towns_v1(this, Mixer);
                if (!TownsPlayer.Init())
                    Debug.WriteLine("Failed to initialize FM-Towns audio driver");
            }
            else if (Game.GameId == GameId.Loom || Game.GameId == GameId.Indy3)
            {
                MusicEngine = new Player_AD(this, Mixer);
            }
            else
            {
                MidiDriver nativeMidiDriver = null;
                MidiDriver adlibMidiDriver = null;
                if (Sound.MusicType == MusicDriverTypes.AdLib || Sound.MusicType == MusicDriverTypes.FMTowns)
                {
                    adlibMidiDriver = (MidiDriver)MidiDriver.CreateMidi(Mixer,
                        MidiDriver.DetectDevice(Sound.MusicType == MusicDriverTypes.FMTowns
                            ? MusicDriverTypes.FMTowns : MusicDriverTypes.AdLib, selectedDevice));
                    adlibMidiDriver.Property(AdlibMidiDriver.PropertyOldAdLib, (Game.Version < 5) ? 1 : 0);
                    adlibMidiDriver.Property(AdlibMidiDriver.PropertyScummOPL3, (Game.GameId == GameId.SamNMax) ? 1 : 0);
                }
                else if (Sound.MusicType == MusicDriverTypes.PCSpeaker)
                {
                    adlibMidiDriver = new PCSpeakerDriver(Mixer);
                }

                IMuse = Audio.IMuse.IMuse.Create(nativeMidiDriver, adlibMidiDriver);

                if (Game.Platform == Platform.FMTowns)
                {
                    MusicEngine = TownsPlayer = new Player_Towns_v2(this, Mixer, IMuse, true);
                    if (!TownsPlayer.Init())
                        throw new InvalidOperationException("ScummEngine::setupMusic(): Failed to initialize FM-Towns audio driver");
                }
                else
                {
                    MusicEngine = IMuse;
                }

                if (IMuse != null)
                {
                    IMuse.AddSysexHandler(0x7D, Game.GameId == GameId.SamNMax ? new SysExFunc(new SamAndMaxSysEx().Do) : new SysExFunc(new ScummSysEx().Do));
                    IMuse.Property(ImuseProperty.GameId, (uint)Game.GameId);
                    //                    IMuse.Property(ImuseProperty.NativeMt32, _native_mt32);
                    //                    if (MidiDriver.GetMusicType(deviceHandle) != MusicType.MT32) // MT-32 Emulation shouldn't be GM/GS initialized
                    //                        IMuse.Property(ImuseProperty.Gs, _enable_gs);
                    if (Sound.MusicType == MusicDriverTypes.PCSpeaker)
                        IMuse.Property(ImuseProperty.PcSpeaker, 1);
                }
            }

            if (MusicEngine != null)
            {
                MusicEngine.SetMusicVolume(192);
            }
        }