public AdLibMusic(Mixer mixer, Disk disk) : base(mixer, disk) { _driverFileBase = 60202; _sampleRate = mixer.OutputRate; _opl = new DosBoxOPL(OplType.Opl2); _opl.Init(_sampleRate); _soundHandle = _mixer.PlayStream(SoundType.Music, this, -1, Mixer.MaxChannelVolume, 0, false, true); }
public Player_AD(ScummEngine scumm, IMixer mixer) { _vm = scumm; _mixer = mixer; _rate = mixer.OutputRate; // TODO: vs OPL // _opl2 = OPL::Config::create(); _opl2 = new DosBoxOPL(OplType.Opl2); _opl2.Init(_rate); _samplesPerCallback = _rate / AD_CALLBACK_FREQUENCY; _samplesPerCallbackRemainder = _rate % AD_CALLBACK_FREQUENCY; _samplesTillCallback = 0; _samplesTillCallbackRemainder = 0; WriteReg(0x01, 0x00); WriteReg(0xBD, 0x00); WriteReg(0x08, 0x00); WriteReg(0x01, 0x20); _soundHandle = _mixer.PlayStream(SoundType.Plain, this, -1, Mixer.MaxChannelVolume, 0, false, true); _engineMusicTimer = 0; _soundPlaying = -1; _curOffset = 0; _sfxTimer = 4; _rndSeed = 1; for (int i = 0; i < _sfx.Length; ++i) { _sfx[i] = new SfxSlot(); _sfx[i].Resource = -1; for (int j = 0; j < _sfx[i].Channels.Length; ++j) { _sfx[i].Channels[j].HardwareChannel = -1; } } _numHWChannels = _hwChannels.Length; _musicVolume = _sfxVolume = 255; _isSeeking = false; }
public override MidiDriverError Open() { if (IsOpen) return MidiDriverError.AlreadyOpen; base.Open(); byte i = 0; foreach (var voice in _voices) { voice.Channel = i++; voice.S11a.S10 = voice.S10b; voice.S11b.S10 = voice.S10a; } // Try to use OPL3 when requested. #if ENABLE_OPL3 if (_opl3Mode) { _opl = OPL::Config::create(OPL::Config::kOpl3); } // Initialize plain OPL2 when no OPL3 is intiailized already. if (!_opl) { #endif // TODO: vs OPL // _opl = OPL::Config::create(); _opl = new DosBoxOPL(OplType.Opl2); #if ENABLE_OPL3 _opl3Mode = false; } #endif _opl.Init(Rate); _regCache = new byte[256]; AdlibWrite(8, 0x40); AdlibWrite(0xBD, 0x00); #if ENABLE_OPL3 if (!_opl3Mode) { #endif AdlibWrite(1, 0x20); CreateLookupTable(); #if ENABLE_OPL3 } else { _regCacheSecondary = (byte *)calloc(256, 1); adlibWriteSecondary(5, 1); } #endif _mixerSoundHandle = _mixer.PlayStream(SoundType.Plain, this, -1, Mixer.MaxChannelVolume, 0, false, true); return 0; }