com.softsynth.jmsl.util
Class SequencerGeneratorAdapter
java.lang.Object
com.softsynth.jmsl.util.SequencerGeneratorAdapter
- All Implemented Interfaces:
- SequenceGenerator
- Direct Known Subclasses:
- WeightedIntegerSequence
public abstract class SequencerGeneratorAdapter
- extends java.lang.Object
- implements SequenceGenerator
SequenceGenerator with reusable random driver implementation
Contains its own RandomDriver which can be used to make random choices.
Subclasses of this just need to define next() and setNext()
Make sure you getRandomDriver() in your subclasses and use its choose() methods to generate your sequence, else
getNext(), getSeed(), and setSeed() won't work.
- Author:
- Nick Didkovsky, 2/5/2004
Method Summary |
int |
getNext()
|
int |
getSeed()
|
void |
randomize()
Set seed from system time. |
void |
reset()
Reset sequence generator so that it will restart at last saved seed value. |
void |
setSeed(int seed)
Set pseudo-random generator seed for repeatable sequences. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SequencerGeneratorAdapter
public SequencerGeneratorAdapter()
getNext
public int getNext()
- Specified by:
getNext
in interface SequenceGenerator
- Returns:
- next without changing current state
setSeed
public void setSeed(int seed)
- Set pseudo-random generator seed for repeatable sequences.
Saves new seed for reset();
- Specified by:
setSeed
in interface SequenceGenerator
getSeed
public int getSeed()
- Specified by:
getSeed
in interface SequenceGenerator
- Returns:
- seed set by setSeed.
randomize
public void randomize()
- Set seed from system time. This will result in a unique sequence each time it is called.
Also saves the seed for reset()
- Specified by:
randomize
in interface SequenceGenerator
reset
public void reset()
- Reset sequence generator so that it will restart at last saved seed value.
- Specified by:
reset
in interface SequenceGenerator