com.jsyn.util
Class VoiceAllocator

java.lang.Object
  extended by com.jsyn.util.VoiceAllocator

public class VoiceAllocator
extends java.lang.Object

Allocate voices based on an integer tag. The tag could, for example, be a MIDI note number. When new voices are needed, they are created using the VoiceFactory. If no new voices are available then a voice in use will be stolen.


Constructor Summary
VoiceAllocator(int max)
           
 
Method Summary
 UnitVoice allocate(int tag)
          Allocate a Voice associated with this tag.
 java.util.Collection<UnitVoice> allOff()
          Turn all the voices off and return the ones that were on.
 int getMaxVoices()
           
 VoiceFactory getVoiceFactory()
           
 boolean isOn(int tag)
           
 UnitVoice off(int tag)
           
 void setVoiceFactory(VoiceFactory factory)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VoiceAllocator

public VoiceAllocator(int max)
Method Detail

setVoiceFactory

public void setVoiceFactory(VoiceFactory factory)

getVoiceFactory

public VoiceFactory getVoiceFactory()

getMaxVoices

public int getMaxVoices()

allocate

public UnitVoice allocate(int tag)
Allocate a Voice associated with this tag. It will first pick a voice already assigned to that tag. Next it will pick the oldest voice that is off. Next it will pick the oldest voice that is on. If no voices are allocated it will create a new voice.

Parameters:
tag -
Returns:
Voice that is most

isOn

public boolean isOn(int tag)

off

public UnitVoice off(int tag)

allOff

public java.util.Collection<UnitVoice> allOff()
Turn all the voices off and return the ones that were on.