コード例 #1
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();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        internal AudioCategory(AudioEngine audioengine, string name, BinaryReader reader)
        {
            Debug.Assert(audioengine != null);
            Debug.Assert(!string.IsNullOrEmpty(name));

            this.sounds = new List <Cue>();
            this.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);
            instanceBehaviour = (MaxInstanceBehaviour)(instanceFlags >> 3);

            reader.ReadUInt16();              //unkn

            byte vol = reader.ReadByte();     //volume in unknown format
            //lazy 4-param fitting:
            //0xff 6.0
            //0xca 2.0
            //0xbf 1.0
            //0xb4 0.0
            //0x8f -4.0
            //0x5a -12.0
            //0x14 -38.0
            //0x00 -96.0
            var a = -96.0;
            var b = 0.432254984608615;
            var c = 80.1748600297963;
            var d = 67.7385212334047;

            volume = (float)(((a - d) / (1 + (Math.Pow(vol / c, b)))) + d);

            byte visibilityFlags = reader.ReadByte();

            isBackgroundMusic = (visibilityFlags & 0x1) != 0;
            isPublic          = (visibilityFlags & 0x2) != 0;
        }
コード例 #4
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;
		}