public void RemoveFromRegistry(Voice voice) { VoiceNode node = registry[voice.VoiceParams.channel, voice.VoiceParams.note]; if (node == null) { return; } if (node.Value == voice) { registry[voice.VoiceParams.channel, voice.VoiceParams.note] = node.Next; vnodes.Push(node); return; } else { VoiceNode node2 = node; node = node.Next; while (node != null) { if (node.Value == voice) { node2.Next = node.Next; vnodes.Push(node); return; } node2 = node; node = node.Next; } } }
public void AddToRegistry(Voice voice) { VoiceNode node = vnodes.Pop(); node.Value = voice; node.Next = registry[voice.VoiceParams.channel, voice.VoiceParams.note]; registry[voice.VoiceParams.channel, voice.VoiceParams.note] = node; }
public void RemoveFromRegistry(int channel, int note) { VoiceNode node = registry[channel, note]; while (node != null) { vnodes.Push(node); node = node.Next; } registry[channel, note] = null; }
public void ClearRegistry() { LinkedListNode <Voice> node = activeVoices.First; while (node != null) { VoiceNode vnode = registry[node.Value.VoiceParams.channel, node.Value.VoiceParams.note]; while (vnode != null) { vnodes.Push(vnode); vnode = vnode.Next; } registry[node.Value.VoiceParams.channel, node.Value.VoiceParams.note] = null; node = node.Next; } }
//--Public Methods public VoiceManager(int voiceCount) { stealingMethod = VoiceStealEnum.Quietest; polyphony = voiceCount; //initialize voice containers voicePool = new Voice[voiceCount]; VoiceNode[] nodes = new VoiceNode[voiceCount]; for (int x = 0; x < voicePool.Length; x++) { voicePool[x] = new Voice(); nodes[x] = new VoiceNode(); } vnodes = new Stack <VoiceNode>(nodes); //free voice list freeVoices = new LinkedList <Voice>(voicePool); activeVoices = new LinkedList <Voice>(); registry = new VoiceNode[Synthesizer.DefaultChannelCount, Synthesizer.DefaultKeyCount]; }
//--Public Methods public VoiceManager(int voiceCount) { stealingMethod = VoiceStealEnum.Quietest; polyphony = voiceCount; //initialize voice containers voicePool = new Voice[voiceCount]; VoiceNode[] nodes = new VoiceNode[voiceCount]; for (int x = 0; x < voicePool.Length; x++) { voicePool[x] = new Voice(); nodes[x] = new VoiceNode(); } vnodes = new Stack<VoiceNode>(nodes); //free voice list freeVoices = new LinkedList<Voice>(voicePool); activeVoices = new LinkedList<Voice>(); registry = new VoiceNode[Synthesizer.DefaultChannelCount, Synthesizer.DefaultKeyCount]; }
public VoiceNode() { Value = null; Next = null; }