com.vwp.sound.mod.modplay.player
Class ModuleState

java.lang.Object
  extended by com.vwp.sound.mod.modplay.player.ModuleState

public class ModuleState
extends java.lang.Object

This is the heart of the player code. This represents the state of the playing module


Constructor Summary
ModuleState(Module module, Mixer mixer)
          Creates a ModuleState playing the supplied module and using the supplied mixer
 
Method Summary
 int getDivision()
           
 int getDivisionsInPattern()
           
 Mixer getMixer()
           
 Module getModule()
           
 int getPatternsInModule()
           
 int getPosition()
           
 int getTick()
           
 int getTicksInDivision()
           
 void jump(int position, int division, int tick)
          jump to the given module position
 boolean play()
          play one "tick" of the module.
 void setBpm(int bpm)
          sets the beats per minute
 void setPatternDelay(int delay)
          causes the current division to be played delay times.
 void setPosition(int position)
          Changes the currently playing pattern to the pattern at the given position
 void setSpeed(int speed)
          sets the speed (a.k.a ticksInDivision)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModuleState

public ModuleState(Module module,
                   Mixer mixer)
Creates a ModuleState playing the supplied module and using the supplied mixer

Parameters:
module - module to be played
mixer - the mixer...
Method Detail

play

public boolean play()
             throws PlayerException
play one "tick" of the module. (A tick is the smallest time interval used by modules. The speed value if actually the number of ticks per division, and the number of divisions played per minute is: div_per_min = 24 * BPM / speed.) The state of the module is only changed by effects between ticks.

Returns:
true if still playing, false if end is reached
Throws:
PlayerException

getModule

public Module getModule()
Returns:
the playing module

getMixer

public Mixer getMixer()
Returns:
the mixer used

getPosition

public int getPosition()
Returns:
the current position

getPatternsInModule

public int getPatternsInModule()
Returns:
the number of pattern positions in the module (Not the number of patterns since each pattern may be played several times)

getDivisionsInPattern

public int getDivisionsInPattern()
Returns:
the number of divisions in the current pattern (often 64)

getTicksInDivision

public int getTicksInDivision()
Returns:
the number of ticks in a division (a.k.a speed)

getTick

public int getTick()
Returns:
the currently playing tick in the currently playing division

getDivision

public int getDivision()
Returns:
the currently playing division

setPosition

public void setPosition(int position)
Changes the currently playing pattern to the pattern at the given position

Parameters:
position - the position to play

setSpeed

public void setSpeed(int speed)
sets the speed (a.k.a ticksInDivision)

Parameters:
speed - new speed of module

setBpm

public void setBpm(int bpm)
sets the beats per minute

Parameters:
bpm - beats per minute

jump

public void jump(int position,
                 int division,
                 int tick)
jump to the given module position

Parameters:
position - the pattern position to jump to
division - the division to jump to
tick - the tick to jump to

setPatternDelay

public void setPatternDelay(int delay)
causes the current division to be played delay times. Any notes, or effects started in this division should not be reset each time the division is played

Parameters:
delay - the times to play the current division