Ejemplo n.º 1
0
        public void NoteOffAll(bool immediate)
        {
            var node = _voiceManager.ActiveVoices.First;

            if (immediate)
            {//if immediate ignore hold pedals and clear the entire registry
                _voiceManager.ClearRegistry();
                while (node != null)
                {
                    node.Value.StopImmediately();
                    var delnode = node;
                    node = node.Next;
                    _voiceManager.ActiveVoices.Remove(delnode);
                    _voiceManager.FreeVoices.AddFirst(delnode.Value);
                }
            }
            else
            {//otherwise we have to check for hold pedals and double check the registry before removing the voice
                while (node != null)
                {
                    VoiceParameters voiceParams = node.Value.VoiceParams;
                    if (voiceParams.State == VoiceStateEnum.Playing)
                    {
                        //if hold pedal is enabled do not stop the voice
                        if (_synthChannels[voiceParams.Channel].HoldPedal)
                        {
                            voiceParams.NoteOffPending = true;
                        }
                        else
                        {
                            node.Value.Stop();
                            _voiceManager.RemoveVoiceFromRegistry(node.Value);
                        }
                    }
                    node = node.Next;
                }
            }
        }
Ejemplo n.º 2
0
 public Voice()
 {
     VoiceParams = new VoiceParameters();
 }