public PlayWaveEvent( XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank, int[] waveBanks, int[] tracks, byte[] weights, int totalWeights, VariationType variation, Vector2?volumeVar, Vector2?pitchVar, Vector4?filterVar, int loopCount, bool newWaveOnLoop) : base(clip, timeStamp, randomOffset) { _soundBank = soundBank; _waveBanks = waveBanks; _tracks = tracks; _weights = weights; _totalWeights = totalWeights; _volumeVar = volumeVar; _pitchVar = pitchVar; _filterVar = filterVar; _wavIndex = -1; _loopIndex = 0; _trackVolume = 1f; _trackPitch = 0; _trackFilterFrequency = 0; _trackFilterQFactor = 0; _clipVolume = 1f; _clipPitch = 0; _clipReverbMix = 0; _variation = variation; _loopCount = loopCount; _newWaveOnLoop = newWaveOnLoop; }
public XactSound(AudioEngine engine, SoundBank soundBank, BinaryReader soundReader) { _soundBank = soundBank; var flags = soundReader.ReadByte(); _complexSound = (flags & 0x1) != 0; var hasRPCs = (flags & 0x0E) != 0; var hasDSPs = (flags & 0x10) != 0; _categoryId = soundReader.ReadUInt16(); _volume = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte()); _pitch = soundReader.ReadInt16() / 1000f; soundReader.ReadByte(); //priority soundReader.ReadUInt16(); // filter stuff? int numClips = 0; if (_complexSound) { numClips = soundReader.ReadByte(); } else { _trackIndex = soundReader.ReadUInt16(); _waveBankIndex = soundReader.ReadByte(); } if (!hasRPCs) { RpcCurves = Array.Empty <int>(); } else { var current = soundReader.BaseStream.Position; // This doesn't seem to be used... might have been there // to allow for some future file format expansion. var dataLength = soundReader.ReadUInt16(); var numPresets = soundReader.ReadByte(); RpcCurves = new int[numPresets]; for (var i = 0; i < numPresets; i++) { RpcCurves[i] = engine.GetRpcIndex(soundReader.ReadUInt32()); } // Just in case seek to the right spot. soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin); } if (!hasDSPs) { _useReverb = false; } else { // The file format for this seems to follow the pattern for // the RPC curves above, but in this case XACT only supports // a single effect... Microsoft Reverb... so just set it. _useReverb = true; soundReader.BaseStream.Seek(7, SeekOrigin.Current); } if (_complexSound) { _soundClips = new XactClip[numClips]; for (int i = 0; i < numClips; i++) { _soundClips[i] = new XactClip(soundBank, soundReader, _useReverb); } } var category = engine.Categories[_categoryId]; category.AddSound(this); }