public void SaveOrLoad(Serializer ser) { var playerEntries = new [] { LoadAndSaveEntry.Create(r => _active = r.ReadBoolean(), w => w.Write(_active), 8), LoadAndSaveEntry.Create(r => _id = r.ReadUInt16(), w => w.WriteUInt16(_id), 8), LoadAndSaveEntry.Create(r => _priority = r.ReadByte(), w => w.WriteByte(_priority), 8), LoadAndSaveEntry.Create(r => _volume = r.ReadByte(), w => w.WriteByte(_volume), 8), LoadAndSaveEntry.Create(r => _pan = r.ReadSByte(), w => w.Write(_pan), 8), LoadAndSaveEntry.Create(r => _transpose = r.ReadSByte(), w => w.Write(_transpose), 8), LoadAndSaveEntry.Create(r => _detune = r.ReadSByte(), w => w.Write(_detune), 8), LoadAndSaveEntry.Create(r => VolChan = r.ReadUInt16(), w => w.WriteUInt16(VolChan), 8), LoadAndSaveEntry.Create(r => _vol_eff = r.ReadByte(), w => w.WriteByte(_vol_eff), 8), LoadAndSaveEntry.Create(r => _speed = r.ReadByte(), w => w.WriteByte(_speed), 8), LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 19), //_song_index LoadAndSaveEntry.Create(r => _track_index = r.ReadUInt16(), w => w.WriteUInt16(_track_index), 8), LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_timer_counter LoadAndSaveEntry.Create(r => _loop_to_beat = r.ReadUInt16(), w => w.WriteUInt16(_loop_to_beat), 8), LoadAndSaveEntry.Create(r => _loop_from_beat = r.ReadUInt16(), w => w.WriteUInt16(_loop_from_beat), 8), LoadAndSaveEntry.Create(r => _loop_counter = r.ReadUInt16(), w => w.WriteUInt16(_loop_counter), 8), LoadAndSaveEntry.Create(r => _loop_to_tick = r.ReadUInt16(), w => w.WriteUInt16(_loop_to_tick), 8), LoadAndSaveEntry.Create(r => _loop_from_tick = r.ReadUInt16(), w => w.WriteUInt16(_loop_from_tick), 8), LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 19), //_tempo LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_cur_pos LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_next_pos LoadAndSaveEntry.Create(r => r.ReadUInt32(), w => w.WriteUInt32(0), 8, 17), //_song_offset LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_tick_index LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), //_beat_index LoadAndSaveEntry.Create(r => r.ReadUInt16(), w => w.WriteUInt16(0), 8, 17), // _ticks_per_beat LoadAndSaveEntry.Create(r => _music_tick = r.ReadUInt32(), w => w.WriteUInt32(_music_tick), 19), }; if (ser.IsLoading && _parser != null) { _parser = null; } _music_tick = _parser != null ? (uint)_parser.Tick : 0; int num; if (!ser.IsLoading) { num = _parts != null ? Array.IndexOf(_se._parts, _parts) + 1 : 0; ser.Writer.WriteUInt16(num); } else { num = ser.Reader.ReadUInt16(); _parts = num != 0 ? _se._parts[num - 1] : null; } playerEntries.ForEach(e => e.Execute(ser)); _hook.SaveOrLoad(ser); _parameterFaders.ForEach(pf => pf.SaveOrLoad(ser)); }
public void RemovePart(Part part) { // Unlink if (part.Next != null) part.Next.Previous = part.Previous; if (part.Previous != null) part.Previous.Next = part.Next; else _parts = part.Next; part.Next = part.Previous = null; }
public bool StartSound(int sound, MidiDriver midi) { // Not sure what the old code was doing, // but we'll go ahead and do a similar check. var ptr = _se.FindStartOfSound(sound); if (ptr == null) { // Console.Error.WriteLine("Player::startSound(): Couldn't find start of sound {0}", sound); return false; } _isMT32 = _se.IsMT32(sound); _isMIDI = _se.IsMIDI(sound); _supportsPercussion = _se.SupportsPercussion(sound); _parts = null; _active = true; _midi = midi; _id = sound; LoadStartParameters(sound); for (var i = 0; i < _parameterFaders.Length; ++i) { _parameterFaders[i].Init(); } HookClear(); if (StartSeqSound(sound) != 0) { _active = false; _midi = null; return false; } Debug.WriteLine("Starting music {0}", sound); return true; }
public Part GetPart(byte chan) { var part = GetActivePart(chan); if (part != null) return part; part = _se.AllocatePart(_priority, _midi); if (part == null) { Debug.WriteLine("No parts available"); return null; } // Insert part into front of parts list part.Previous = null; part.Next = _parts; if (_parts != null) _parts.Previous = part; _parts = part; part.Channel = chan; part.Setup(this); return part; }
public IMuseInternal() { _snm_triggers = new ImTrigger[16]; for (int i = 0; i < _snm_triggers.Length; i++) { _snm_triggers[i] = new ImTrigger(); } _channel_volume = new ushort[8]; _channel_volume_eff = new ushort[8]; _volchan_table = new ushort[8]; _players = new Player[8]; for (int i = 0; i < _players.Length; i++) { _players[i] = new Player(); } _player_limit = _players.Length; _parts = new Part[32]; for (int i = 0; i < _parts.Length; i++) { _parts[i] = new Part(); } _global_instruments = new Instrument[32]; for (int i = 0; i < _global_instruments.Length; i++) { _global_instruments[i] = new Instrument(); } _cmd_queue = new CommandQueue[64]; for (int i = 0; i < _cmd_queue.Length; i++) { _cmd_queue[i] = new CommandQueue(); } _deferredCommands = new DeferredCommand[4]; for (int i = 0; i < _deferredCommands.Length; i++) { _deferredCommands[i] = new DeferredCommand(); } _timer_info_adlib = new TimerCallbackInfo(); _timer_info_native = new TimerCallbackInfo(); }