internal AudioCategory(AudioEngine audioengine, string name, BinaryReader reader)
        {
            Debug.Assert(audioengine != null);
            Debug.Assert(!string.IsNullOrEmpty(name));

            _sounds = new List <XactSound>();
            _name   = name;
            _engine = audioengine;

            maxInstances  = reader.ReadByte();
            instanceLimit = maxInstances != 0xff;

            fadeIn  = (reader.ReadUInt16() / 1000f);
            fadeOut = (reader.ReadUInt16() / 1000f);

            byte instanceFlags = reader.ReadByte();

            fadeType         = (CrossfadeType)(instanceFlags & 0x7);
            InstanceBehavior = (MaxInstanceBehavior)(instanceFlags >> 3);

            reader.ReadUInt16();  //unkn

            var volume = XactHelpers.ParseVolumeFromDecibels(reader.ReadByte());

            _volume = new float[1] {
                volume
            };

            byte visibilityFlags = reader.ReadByte();

            isBackgroundMusic = (visibilityFlags & 0x1) != 0;
            isPublic          = (visibilityFlags & 0x2) != 0;
        }
Exemplo n.º 2
0
        internal AudioCategory(
            string name,
            float volume,
            byte maxInstances,
            int maxBehavior,
            ushort fadeInMS,
            ushort fadeOutMS,
            int fadeType
            )
        {
            INTERNAL_name     = name;
            INTERNAL_volume   = new PrimitiveInstance <float>(volume);
            activeCues        = new List <Cue>();
            cueInstanceCounts = new Dictionary <string, int>();

            maxCueInstances = maxInstances;
            maxCueBehavior  = (MaxInstanceBehavior)maxBehavior;
            maxFadeInMS     = fadeInMS;
            maxFadeOutMS    = fadeOutMS;
            crossfadeType   = (CrossfadeType)fadeType;

            fading          = new PrimitiveInstance <bool>(false);
            fadingCue       = new PrimitiveInstance <Cue>(null);
            queuedCue       = new PrimitiveInstance <Cue>(null);
            fadingCueVolume = new PrimitiveInstance <float>(0.0f);
            fadeTimer       = new Stopwatch();
        }
Exemplo n.º 3
0
        public CueData(XACTSound sound)
        {
            Sounds        = new XACTSound[1];
            Probabilities = new float[1, 2];

            Sounds[0]           = sound;
            Category            = sound.Category;
            Probabilities[0, 0] = 1.0f;
            Probabilities[0, 1] = 0.0f;
            IsUserControlled    = false;

            // Assume we can have max instances, for now.
            InstanceLimit  = 255;
            MaxCueBehavior = MaxInstanceBehavior.ReplaceOldest;
        }
Exemplo n.º 4
0
        public CueData(
            XACTSound[] sounds,
            float[,] probabilities,
            string controlVariable
            )
        {
            Sounds              = sounds;
            Category            = Sounds[0].Category;  // FIXME: Assumption!
            Probabilities       = probabilities;
            IsUserControlled    = !String.IsNullOrEmpty(controlVariable);
            UserControlVariable = controlVariable;

            // Assume we can have max instances, for now.
            InstanceLimit  = 255;
            MaxCueBehavior = MaxInstanceBehavior.ReplaceOldest;
        }
Exemplo n.º 5
0
		internal AudioCategory(
			string name,
			float volume,
			byte maxInstances,
			int maxBehavior,
			ushort fadeInMS,
			ushort fadeOutMS,
			int fadeType
		) {
			INTERNAL_name = name;
			INTERNAL_volume = new PrimitiveInstance<float>(volume);
			activeCues = new List<Cue>();
			cueInstanceCounts = new Dictionary<string, int>();

			maxCueInstances = maxInstances;
			maxCueBehavior = (MaxInstanceBehavior) maxBehavior;
			maxFadeInMS = fadeInMS;
			maxFadeOutMS = fadeOutMS;
			crossfadeType = (CrossfadeType) fadeType;
		}
Exemplo n.º 6
0
 public void SetLimit(byte instanceLimit, byte behavior)
 {
     InstanceLimit  = instanceLimit;
     MaxCueBehavior = (MaxInstanceBehavior)(behavior >> 3);
 }