public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long position = clipReader.BaseStream.Position; clipReader.BaseStream.Seek((long)clipOffset, SeekOrigin.Begin); byte num1 = clipReader.ReadByte(); this.events = new XactClip.ClipEvent[(int)num1]; for (int index = 0; index < (int)num1; ++index) { if ((int)(clipReader.ReadUInt32() & 31U) != 1) { throw new NotImplementedException(); } XactClip.EventPlayWave eventPlayWave = new XactClip.EventPlayWave(); int num2 = (int)clipReader.ReadUInt32(); uint trackIndex = (uint)clipReader.ReadUInt16(); byte waveBankIndex = clipReader.ReadByte(); int num3 = (int)clipReader.ReadByte(); int num4 = (int)clipReader.ReadUInt16(); int num5 = (int)clipReader.ReadUInt16(); eventPlayWave.wave = soundBank.GetWave(waveBankIndex, trackIndex); this.events[index] = (XactClip.ClipEvent)eventPlayWave; this.events[index].clip = this; } clipReader.BaseStream.Seek(position, SeekOrigin.Begin); }
public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset) { long oldPosition = soundReader.BaseStream.Position; soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin); byte flags = soundReader.ReadByte(); complexSound = (flags & 1) != 0; uint category = soundReader.ReadUInt16(); soundReader.ReadByte(); //unkn uint volume = soundReader.ReadUInt16(); //maybe pitch? soundReader.ReadByte(); //unkn uint entryLength = soundReader.ReadUInt16(); uint numClips = 0; if (complexSound) { numClips = (uint)soundReader.ReadByte(); } else { uint trackIndex = soundReader.ReadUInt16(); byte waveBankIndex = soundReader.ReadByte(); wave = soundBank.GetWave(waveBankIndex, trackIndex); } if ((flags & 0x1E) != 0) { uint extraDataLen = soundReader.ReadUInt16(); //TODO: Parse RPC+DSP stuff // extraDataLen - 2, we need to account for extraDataLen itself! soundReader.BaseStream.Seek(extraDataLen - 2, SeekOrigin.Current); } if (complexSound) { soundClips = new XactClip[numClips]; for (int i = 0; i < numClips; i++) { soundReader.ReadByte(); //unkn uint clipOffset = soundReader.ReadUInt32(); soundReader.ReadUInt32(); //unkn soundClips[i] = new XactClip(soundBank, soundReader, clipOffset); } } var audioCategory = soundBank.AudioEngine.Categories[category]; audioCategory.AddSound(this); soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin); }
public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long oldPosition = clipReader.BaseStream.Position; clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin); byte numEvents = clipReader.ReadByte(); events = new ClipEvent[numEvents]; for (int i = 0; i < numEvents; i++) { uint eventInfo = clipReader.ReadUInt32(); uint eventId = eventInfo & 0x1F; switch (eventId) { case 1: EventPlayWave evnt = new EventPlayWave(); clipReader.ReadUInt32(); //unkn uint trackIndex = clipReader.ReadUInt16(); byte waveBankIndex = clipReader.ReadByte(); var loopCount = clipReader.ReadByte(); // if loopCount == 255 its an infinite loop // otherwise it loops n times.. // unknown clipReader.ReadUInt16(); clipReader.ReadUInt16(); evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex); evnt.wave.IsLooped = loopCount == 255; events[i] = evnt; break; default: throw new NotSupportedException(); } events[i].clip = this; } clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin); }
public XactSound (SoundBank soundBank, BinaryReader soundReader, uint soundOffset) { long oldPosition = soundReader.BaseStream.Position; soundReader.BaseStream.Seek (soundOffset, SeekOrigin.Begin); byte flags = soundReader.ReadByte (); complexSound = (flags & 1) != 0; uint category = soundReader.ReadUInt16 (); soundReader.ReadByte (); //unkn uint volume = soundReader.ReadUInt16 (); //maybe pitch? soundReader.ReadByte (); //unkn uint entryLength = soundReader.ReadUInt16 (); uint numClips = 0; if (complexSound) { numClips = (uint)soundReader.ReadByte (); } else { uint trackIndex = soundReader.ReadUInt16 (); byte waveBankIndex = soundReader.ReadByte (); wave = soundBank.GetWave(waveBankIndex, trackIndex); } if ( (flags & 0x1E) != 0 ) { uint extraDataLen = soundReader.ReadUInt16 (); //TODO: Parse RPC+DSP stuff // extraDataLen - 2, we need to account for extraDataLen itself! soundReader.BaseStream.Seek (extraDataLen - 2, SeekOrigin.Current); } if (complexSound) { soundClips = new XactClip[numClips]; for (int i=0; i<numClips; i++) { soundReader.ReadByte (); //unkn uint clipOffset = soundReader.ReadUInt32 (); soundReader.ReadUInt32 (); //unkn soundClips[i] = new XactClip(soundBank, soundReader, clipOffset); } } var audioCategory = soundBank.AudioEngine.Categories[category]; audioCategory.AddSound(this); soundReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin); }
public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long oldPosition = clipReader.BaseStream.Position; clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin); byte numEvents = clipReader.ReadByte(); events = new ClipEvent[numEvents]; for (int i = 0; i < numEvents; i++) { uint eventInfo = clipReader.ReadUInt32(); uint eventId = eventInfo & 0x1F; switch (eventId) { case 1: EventPlayWave evnt = new EventPlayWave(); clipReader.ReadUInt32(); //unkn uint trackIndex = clipReader.ReadUInt16(); byte waveBankIndex = clipReader.ReadByte(); //unkn clipReader.ReadByte(); clipReader.ReadUInt16(); clipReader.ReadUInt16(); evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex); events[i] = evnt; break; default: throw new NotImplementedException(); } events[i].clip = this; } clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin); }
public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset) { long position = soundReader.BaseStream.Position; soundReader.BaseStream.Seek((long)soundOffset, SeekOrigin.Begin); byte num1 = soundReader.ReadByte(); this.complexSound = ((int)num1 & 1) != 0; int num2 = (int)soundReader.ReadUInt16(); int num3 = (int)soundReader.ReadByte(); int num4 = (int)soundReader.ReadUInt16(); int num5 = (int)soundReader.ReadByte(); int num6 = (int)soundReader.ReadUInt16(); uint num7 = 0U; if (this.complexSound) { num7 = (uint)soundReader.ReadByte(); } else { uint trackIndex = (uint)soundReader.ReadUInt16(); byte waveBankIndex = soundReader.ReadByte(); this.wave = soundBank.GetWave(waveBankIndex, trackIndex); } if (((int)num1 & 30) != 0) { uint num8 = (uint)soundReader.ReadUInt16(); soundReader.BaseStream.Seek((long)(num8 - 2U), SeekOrigin.Current); } if (this.complexSound) { this.soundClips = new XactClip[(IntPtr)num7]; for (int index = 0; (long)index < (long)num7; ++index) { int num8 = (int)soundReader.ReadByte(); uint clipOffset = soundReader.ReadUInt32(); int num9 = (int)soundReader.ReadUInt32(); this.soundClips[index] = new XactClip(soundBank, soundReader, clipOffset); } } soundReader.BaseStream.Seek(position, SeekOrigin.Begin); }
public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset) { long position = soundReader.BaseStream.Position; soundReader.BaseStream.Seek((long) soundOffset, SeekOrigin.Begin); byte num1 = soundReader.ReadByte(); this.complexSound = ((int) num1 & 1) != 0; uint num2 = (uint) soundReader.ReadUInt16(); int num3 = (int) soundReader.ReadByte(); uint num4 = (uint) soundReader.ReadUInt16(); int num5 = (int) soundReader.ReadByte(); uint num6 = (uint) soundReader.ReadUInt16(); uint num7 = 0U; if (this.complexSound) { num7 = (uint) soundReader.ReadByte(); } else { uint trackIndex = (uint) soundReader.ReadUInt16(); byte waveBankIndex = soundReader.ReadByte(); this.wave = soundBank.GetWave(waveBankIndex, trackIndex); } if (((int) num1 & 30) != 0) { uint num8 = (uint) soundReader.ReadUInt16(); soundReader.BaseStream.Seek((long) num8, SeekOrigin.Current); } if (this.complexSound) { this.soundClips = new XactClip[(IntPtr) num7]; for (int index = 0; (long) index < (long) num7; ++index) { int num8 = (int) soundReader.ReadByte(); uint clipOffset = soundReader.ReadUInt32(); int num9 = (int) soundReader.ReadUInt32(); this.soundClips[index] = new XactClip(soundBank, soundReader, clipOffset); } } soundReader.BaseStream.Seek(position, SeekOrigin.Begin); }
public XactClip (SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long oldPosition = clipReader.BaseStream.Position; clipReader.BaseStream.Seek (clipOffset, SeekOrigin.Begin); byte numEvents = clipReader.ReadByte(); events = new ClipEvent[numEvents]; for (int i=0; i<numEvents; i++) { uint eventInfo = clipReader.ReadUInt32(); uint eventId = eventInfo & 0x1F; switch (eventId) { case 1: EventPlayWave evnt = new EventPlayWave(); clipReader.ReadUInt32 (); //unkn uint trackIndex = clipReader.ReadUInt16 (); byte waveBankIndex = clipReader.ReadByte (); //unkn clipReader.ReadByte (); clipReader.ReadUInt16 (); clipReader.ReadUInt16 (); evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex); events[i] = evnt; break; default: throw new NotImplementedException(); } events[i].clip = this; } clipReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin); }
public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long position = clipReader.BaseStream.Position; clipReader.BaseStream.Seek((long) clipOffset, SeekOrigin.Begin); byte num1 = clipReader.ReadByte(); this.events = new XactClip.ClipEvent[(int) num1]; for (int index = 0; index < (int) num1; ++index) { if ((int) (clipReader.ReadUInt32() & 31U) != 1) throw new NotImplementedException(); XactClip.EventPlayWave eventPlayWave = new XactClip.EventPlayWave(); int num2 = (int) clipReader.ReadUInt32(); uint trackIndex = (uint) clipReader.ReadUInt16(); byte waveBankIndex = clipReader.ReadByte(); int num3 = (int) clipReader.ReadByte(); int num4 = (int) clipReader.ReadUInt16(); int num5 = (int) clipReader.ReadUInt16(); eventPlayWave.wave = soundBank.GetWave(waveBankIndex, trackIndex); this.events[index] = (XactClip.ClipEvent) eventPlayWave; this.events[index].clip = this; } clipReader.BaseStream.Seek(position, SeekOrigin.Begin); }
public XactClip(SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long oldPosition = clipReader.BaseStream.Position; clipReader.BaseStream.Seek(clipOffset, SeekOrigin.Begin); byte numEvents = clipReader.ReadByte(); events = new ClipEvent[numEvents]; for (int i = 0; i < numEvents; i++) { uint eventInfo = clipReader.ReadUInt32(); uint eventId = eventInfo & 0x1F; switch (eventId) { case 0: // FIXME: SetVolumeEventInfo -flibit EventSetVolume volEvnt = new EventSetVolume(); events[i] = volEvnt; break; case 1: case 4: EventPlayWave evnt = new EventPlayWave(); clipReader.ReadUInt32(); //unkn uint trackIndex = clipReader.ReadUInt16(); byte waveBankIndex = clipReader.ReadByte(); var loopCount = clipReader.ReadByte(); // if loopCount == 255 its an infinite loop // otherwise it loops n times.. // unknown clipReader.ReadUInt16(); clipReader.ReadUInt16(); evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex); evnt.IsLooped = loopCount == 255; events[i] = evnt; break; case 3: case 8: // FIXME: lolwuta // FIXME: WavePlayVariationEventInfo -flibit EventWavePlayVariation playVarEvt = new EventWavePlayVariation(); events[i] = playVarEvt; break; case 6: EventPlayMultiWave evt = new EventPlayMultiWave(); // A whole bunch of shit nobody cares about clipReader.ReadBytes(33); // u16 0 0 // u8 255 255 // u32 12 12 // u16 0 0 // u8 156 123 // u8 255 254 // u16 100 215 // u8 151 151 // u16 180 214 // u8 0 // u8 122 // u16 68 // u8 0 // u8 122 // u16 68 // u8 0 // u8 240 // u16 65 // u8 0 // u8 240 // u16 65 // u8 32 16 ushort numEntries = clipReader.ReadUInt16(); evt.waves = new SoundEffect[numEntries]; clipReader.ReadUInt16(); // 3 clipReader.ReadBytes(4); // 255 each for (ushort j = 0; j < numEntries; j++) { ushort index = clipReader.ReadUInt16(); byte wavebank = clipReader.ReadByte(); byte minWeight = clipReader.ReadByte(); byte weight = clipReader.ReadByte(); evt.waves[j] = soundBank.GetWave(wavebank, index); } events[i] = evt; break; default: throw new NotImplementedException("eventInfo & 0x1F = " + eventId); } events[i].clip = this; } clipReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin); }
public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset) { long oldPosition = soundReader.BaseStream.Position; soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin); byte flags = soundReader.ReadByte(); complexSound = (flags & 1) != 0; category = soundReader.ReadUInt16(); uint volume = soundReader.ReadByte(); // FIXME: Maybe wrong? uint pitch = soundReader.ReadUInt16(); // FIXME: Maybe wrong? soundReader.ReadByte(); //unkn uint entryLength = soundReader.ReadUInt16(); uint numClips = 0; if (complexSound) { numClips = (uint)soundReader.ReadByte(); } else { uint trackIndex = soundReader.ReadUInt16(); byte waveBankIndex = soundReader.ReadByte(); soundClips = new XactClip[1]; soundClips[0] = new XactClip(soundBank.GetWave(waveBankIndex, trackIndex)); } if ((flags & 0xE) != 0) // RPC Tables { uint extraDataLen = soundReader.ReadUInt16(); if ((flags == 0x02) || (flags == 0x03)) // FIXME: Verify this! // The number of RPC presets that affect this sound. { uint numRPCPresets = soundReader.ReadByte(); rpcEffects = new byte[numRPCPresets]; for (uint i = 0; i < numRPCPresets; i++) { byte rpcTable = soundReader.ReadByte(); // !!! FIXME: Anyone know how these bytes work? -flibit // System.Console.WriteLine(rpcTable); // !!! HACK: Screw it, I need these working. -flibit // Codename lolno has these RPC entries... // All affect Volume, based on the Distance variable. // 1 1 0 0 0 1 1 0 --- 198 - Attenuation // 1 1 1 1 1 0 0 0 --- 248 - Attenuation_high // 0 0 1 0 0 0 0 1 --- 033 - Attenuation_low if (rpcTable == 198 || rpcTable == 218 || rpcTable == 050) { rpcEffects[i] = 0; } else if (rpcTable == 248 || rpcTable == 001) { rpcEffects[i] = 1; } else if (rpcTable == 033 || rpcTable == 150) { rpcEffects[i] = 2; } else if (rpcTable == 000) { rpcEffects[i] = 3; } else { throw new NotImplementedException("Check the XACT RPC parsing!"); } } // Create the variable table for (int i = 0; i < rpcEffects.Length; i++) { rpcVariables.Add( soundBank.audioengine.variables[soundBank.audioengine.rpcCurves[rpcEffects[i]].variable].name, soundBank.audioengine.variables[soundBank.audioengine.rpcCurves[rpcEffects[i]].variable].initValue ); } // Seek to the end of this block. soundReader.BaseStream.Seek(extraDataLen - 3 - numRPCPresets, SeekOrigin.Current); } else { // Screw it, just skip the block. soundReader.BaseStream.Seek(extraDataLen - 2, SeekOrigin.Current); } } if ((flags & 0x10) != 0) // DSP Presets { uint extraDataLen = soundReader.ReadUInt16(); byte numPresets = soundReader.ReadByte(); uint[] presets = new uint[numPresets]; for (int i = 0; i < numPresets; i++) { presets[i] = soundReader.ReadUInt32(); } } if (complexSound) { soundClips = new XactClip[numClips]; for (int i = 0; i < numClips; i++) { soundReader.ReadByte(); //unkn uint clipOffset = soundReader.ReadUInt32(); soundReader.ReadUInt32(); //unkn soundClips[i] = new XactClip(soundBank, soundReader, clipOffset); } } // FIXME: This is totally arbitrary. I dunno the exact ratio here. staticVolume = volume / 256.0f; Volume = 1.0f; soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin); }
public XactClip (SoundBank soundBank, BinaryReader clipReader, uint clipOffset) { long oldPosition = clipReader.BaseStream.Position; clipReader.BaseStream.Seek (clipOffset, SeekOrigin.Begin); byte numEvents = clipReader.ReadByte(); events = new ClipEvent[numEvents]; for (int i=0; i<numEvents; i++) { uint eventInfo = clipReader.ReadUInt32(); uint eventId = eventInfo & 0x1F; switch (eventId) { case 1: EventPlayWave evnt = new EventPlayWave(); clipReader.ReadUInt32 (); //unkn uint trackIndex = clipReader.ReadUInt16 (); byte waveBankIndex = clipReader.ReadByte (); var loopCount = clipReader.ReadByte (); // if loopCount == 255 its an infinite loop // otherwise it loops n times.. // unknown clipReader.ReadUInt16 (); clipReader.ReadUInt16 (); evnt.wave = soundBank.GetWave(waveBankIndex, trackIndex); evnt.wave.IsLooped = loopCount == 255; events[i] = evnt; break; default: throw new NotSupportedException(); } events[i].clip = this; } clipReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin); }