Beispiel #1
0
        private Voice StealQuietestVoice()
        {
            var voiceVolume = 1000.0;
            LinkedListNode <Voice> quietest = null;
            var node = ActiveVoices.First;

            while (node != null)
            {
                if (node.Value.VoiceParams.State != VoiceStateEnum.Playing)
                {
                    float volume = node.Value.VoiceParams.CombinedVolume;
                    if (volume < voiceVolume)
                    {
                        quietest    = node;
                        voiceVolume = volume;
                    }
                }
                node = node.Next;
            }
            if (quietest == null)
            {
                quietest = ActiveVoices.First;
            }
            //check and remove from registry
            RemoveVoiceFromRegistry(quietest.Value);
            ActiveVoices.Remove(quietest);
            //stop voice if it is not already
            quietest.Value.VoiceParams.State = VoiceStateEnum.Stopped;
            return(quietest.Value);
        }
Beispiel #2
0
        private Voice StealOldest()
        {
            var node = ActiveVoices.First;

            //first look for a voice that is not playing
            while (node != null && node.Value.VoiceParams.State == VoiceStateEnum.Playing)
            {
                node = node.Next;
            }
            //if no stopping voice is found use the oldest
            if (node == null)
            {
                node = ActiveVoices.First;
            }
            //check and remove from registry
            RemoveVoiceFromRegistry(node.Value);
            ActiveVoices.Remove(node);
            //stop voice if it is not already
            node.Value.VoiceParams.State = VoiceStateEnum.Stopped;
            return(node.Value);
        }