Exemplo n.º 1
0
        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          = 1.0f;
            _trackPitch           = 0;
            _trackFilterFrequency = 0;
            _trackFilterQFactor   = 0;

            _clipVolume    = 1.0f;
            _clipPitch     = 0;
            _clipReverbMix = 0;

            _variation     = variation;
            _loopCount     = loopCount;
            _newWaveOnLoop = newWaveOnLoop;
        }
Exemplo n.º 2
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
        {
            _soundBank = soundBank;

            var oldPosition = soundReader.BaseStream.Position;

            soundReader.BaseStream.Seek(soundOffset, SeekOrigin.Begin);

            byte flags = soundReader.ReadByte();

            _complexSound = (flags & 1) != 0;

            _categoryID = soundReader.ReadUInt16();
            var volume = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            var pitch  = soundReader.ReadInt16() / 1000.0f;

            soundReader.ReadByte();    //unkn
            soundReader.ReadUInt16();  // entryLength

            uint numClips = 0;

            if (_complexSound)
            {
                numClips = (uint)soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            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 category = soundBank.AudioEngine.Categories[_categoryID];

            category.AddSound(this);

            soundReader.BaseStream.Seek(oldPosition, SeekOrigin.Begin);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public XactSound(SoundBank soundBank, BinaryReader soundReader)
        {
            _soundBank = soundBank;

            var flags = soundReader.ReadByte();

            _complexSound = (flags & 0x1) != 0;
            var hasRPCs    = (flags & 0x0E) != 0;
            var hasEffects = (flags & 0x10) != 0;

            _categoryID = soundReader.ReadUInt16();
            _volume     = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            _pitch      = soundReader.ReadInt16() / 1000.0f;
            var priority = soundReader.ReadByte();

            soundReader.ReadUInt16(); // filter stuff?

            uint numClips = 0;

            if (_complexSound)
            {
                numClips = soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            if (hasRPCs)
            {
                var current    = soundReader.BaseStream.Position;
                var dataLength = soundReader.ReadUInt16();
                soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
            }

            if (hasEffects)
            {
                var current    = soundReader.BaseStream.Position;
                var dataLength = soundReader.ReadUInt16();
                soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
            }

            if (_complexSound)
            {
                _soundClips = new XactClip[numClips];
                for (int i = 0; i < numClips; i++)
                {
                    _soundClips[i] = new XactClip(soundBank, soundReader);
                }
            }

            var category = soundBank.AudioEngine.Categories[_categoryID];

            category.AddSound(this);
        }
Exemplo n.º 5
0
 public PlayWaveEvent(XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank,
                      int[] waveBanks, int[] tracks, VariationType variation, bool isLooped)
     : base(clip, timeStamp, randomOffset)
 {
     _soundBank = soundBank;
     _waveBanks = waveBanks;
     _tracks    = tracks;
     _wavIndex  = 0;
     _volume    = 1.0f;
     _variation = variation;
     _isLooped  = isLooped;
 }
Exemplo n.º 6
0
 public PlayWaveEvent(   XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank, 
                         int[] waveBanks, int[] tracks, VariationType variation, bool isLooped)
     : base(clip, timeStamp, randomOffset)
 {
     _soundBank = soundBank;
     _waveBanks = waveBanks;
     _tracks = tracks;
     _wavIndex = 0;
     _volume = 1.0f;
     _variation = variation;
     _isLooped = isLooped;
 }
Exemplo n.º 7
0
		public XactSound(SoundBank soundBank, BinaryReader soundReader, uint soundOffset)
		{
            _soundBank = soundBank;

			var oldPosition = soundReader.BaseStream.Position;
			soundReader.BaseStream.Seek (soundOffset, SeekOrigin.Begin);
			
			byte flags = soundReader.ReadByte ();
			_complexSound = (flags & 1) != 0;

            _categoryID = soundReader.ReadUInt16();
            var volume = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            var pitch = soundReader.ReadInt16() / 1000.0f;
			soundReader.ReadByte (); //unkn
            soundReader.ReadUInt16 (); // entryLength
			
			uint numClips = 0;
			if (_complexSound)
				numClips = (uint)soundReader.ReadByte ();
			else 
            {
				_trackIndex = soundReader.ReadUInt16 ();
				_waveBankIndex = soundReader.ReadByte ();
			}
			
			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 category = soundBank.AudioEngine.Categories[_categoryID];
            category.AddSound(this);

			soundReader.BaseStream.Seek (oldPosition, SeekOrigin.Begin);
		}
Exemplo n.º 8
0
		public XactSound(SoundBank soundBank, BinaryReader soundReader)
		{
            _soundBank = soundBank;
			
            var flags = soundReader.ReadByte();
            _complexSound = (flags & 0x1) != 0;
            var hasRPCs = (flags & 0x0E) != 0;
            var hasEffects = (flags & 0x10) != 0;

            _categoryID = soundReader.ReadUInt16();
            _volume = XactHelpers.ParseVolumeFromDecibels(soundReader.ReadByte());
            _pitch = soundReader.ReadInt16() / 1000.0f;
			soundReader.ReadByte(); //priority
            soundReader.ReadUInt16(); // filter stuff?
			
			uint numClips = 0;
			if (_complexSound)
				numClips = soundReader.ReadByte();
			else 
            {
				_trackIndex = soundReader.ReadUInt16();
				_waveBankIndex = soundReader.ReadByte();
			}

			if (hasRPCs)
			{
				var current = soundReader.BaseStream.Position;
				var dataLength = soundReader.ReadUInt16();
				soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
			}

			if (hasEffects)
			{
				var current = soundReader.BaseStream.Position;
				var dataLength = soundReader.ReadUInt16();
				soundReader.BaseStream.Seek(current + dataLength, SeekOrigin.Begin);
			}

			if (_complexSound)
            {
				_soundClips = new XactClip[numClips];
				for (int i=0; i<numClips; i++) 
					_soundClips[i] = new XactClip(soundBank, soundReader);
			}

            var category = soundBank.AudioEngine.Categories[_categoryID];
            category.AddSound(this);
		}
		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);
		}
Exemplo n.º 10
0
 public PlayWaveEvent(   XactClip clip, float timeStamp, float randomOffset, SoundBank soundBank,
                         int[] waveBanks, int[] tracks, byte[] weights, int totalWeights,
                         VariationType variation, Vector2? volumeVar, Vector2? pitchVar, 
                         int loopCount, bool newWaveOnLoop)
     : base(clip, timeStamp, randomOffset)
 {
     _soundBank = soundBank;
     _waveBanks = waveBanks;
     _tracks = tracks;
     _weights = weights;
     _totalWeights = totalWeights;
     _volumeVar = volumeVar;
     _pitchVar = pitchVar;
     _wavIndex = -1;
     _loopIndex = 0;
     _trackVolume = 1.0f;
     _variation = variation;
     _loopCount = loopCount;
     _newWaveOnLoop = newWaveOnLoop;
 }
Exemplo n.º 11
0
 public ClipEvent(XactClip clip, float timeStamp, float randomOffset)
 {
     _clip = clip;
     _timeStamp = timeStamp;
     _randomOffset = randomOffset;
 }
Exemplo n.º 12
0
 public VolumeEvent(XactClip clip, float timeStamp, float randomOffset, float volume)
     : base(clip, timeStamp, randomOffset)
 {
     _volume = volume;
 }
Exemplo n.º 13
0
 public ClipEvent(XactClip clip, float timeStamp, float randomOffset)
 {
     _clip         = clip;
     _timeStamp    = timeStamp;
     _randomOffset = randomOffset;
 }
Exemplo n.º 14
0
 protected ClipEvent(XactClip clip, float timeStamp, float randomOffset)
 {
     _clip        = clip;
     TimeStamp    = timeStamp;
     RandomOffset = randomOffset;
 }
Exemplo n.º 15
0
	    protected ClipEvent(XactClip clip, float timeStamp, float randomOffset)
        {
            _clip = clip;
            TimeStamp = timeStamp;
            RandomOffset = randomOffset;
        }
Exemplo n.º 16
0
        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() / 1000.0f;
            soundReader.ReadByte();   //priority
            soundReader.ReadUInt16(); // filter stuff?

            var numClips = 0;

            if (_complexSound)
            {
                numClips = soundReader.ReadByte();
            }
            else
            {
                _trackIndex    = soundReader.ReadUInt16();
                _waveBankIndex = soundReader.ReadByte();
            }

            if (!hasRPCs)
            {
                RpcCurves = new int[0];
            }
            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);
        }
Exemplo n.º 17
0
//		public XactSound (Sound sound) {
//			complexSound = false;
//			wave = sound;
//		}
        public XactSound(SoundEffect sound)
        {
            soundClips    = new XactClip[1];
            soundClips[0] = new XactClip(sound);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
 public VolumeEvent(XactClip clip, float timeStamp, float randomOffset, float volume)
     : base(clip, timeStamp, randomOffset)
 {
     _volume = volume;
 }