edu.uiuc.cs397rhc.game
Class Groove

java.lang.Object
  extended by edu.uiuc.cs397rhc.game.Groove
All Implemented Interfaces:
Equalizable

public class Groove
extends java.lang.Object
implements Equalizable

A Groove is a MIDI piece that is faded in, played for a few seconds, then faded out in response to game events. It is divided up into an Instrumentation for each team. When activated, it is told which team has activated it, and will fade in, play, and fade out only the parts assigned to that particular team. A team's part will continue to play so long as that team continues to activate the ability before the set duration period since the last activation has elapsed. Grooves can also be assigned a master Groove. This will guarantee that, right before playing, the Groove is synchronized with the position of its master.

Author:
Pedro DeRose

Field Summary
static int DEFAULT_DURATION
          The default duration of play after an activation.
 
Constructor Summary
Groove(java.lang.String filename, java.util.EnumMap<GameUtils.Team,Instrumentation> teamParts)
          Creates a Groove for the given file and with the given Instrumentations.
Groove(java.lang.String filename, int duration, java.util.EnumMap<GameUtils.Team,Instrumentation> teamToPart)
          Creates a Groove for the given file and with the given Instrumentations, which will play for the given duration when activated.
 
Method Summary
 void activate(GameUtils.Team team)
          Activates the part associated with the given team for the default duration.
 void activate(GameUtils.Team team, int duration)
          Activates the part associated with the given team for the given duration.
 void deactivate(GameUtils.Team team)
          Deactivates the part associated with the given team.
 java.util.Set<GameUtils.Team> getTeamSet()
          The number of teams for which parts have been assigned.
protected  javax.sound.midi.Transmitter getTransmitter()
          The transmitter that is attached to the synthesizer.
 double getVolumePercentage()
          Gets the independent volume percentage of the object.
 boolean isActive()
          Whether the Groove is active.
 void setMaster(Groove groove)
          Sets the master Groove to which this one should be synched before playing.
 void setVolumePercentage(double percent)
          Sets the volume percentage of the object independently of other volume manipulations, such as fading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DURATION

public static final int DEFAULT_DURATION
The default duration of play after an activation.

See Also:
Constant Field Values
Constructor Detail

Groove

public Groove(java.lang.String filename,
              java.util.EnumMap<GameUtils.Team,Instrumentation> teamParts)
Creates a Groove for the given file and with the given Instrumentations.

Parameters:
filename - the MIDI file's name
teamParts - the parts associated with each team

Groove

public Groove(java.lang.String filename,
              int duration,
              java.util.EnumMap<GameUtils.Team,Instrumentation> teamToPart)
Creates a Groove for the given file and with the given Instrumentations, which will play for the given duration when activated.

Parameters:
filename - the MIDI file's name
duration - the duration to play when activated
teamToPart - the parts associated with each team
Method Detail

setMaster

public void setMaster(Groove groove)
Sets the master Groove to which this one should be synched before playing.

Parameters:
groove - the master Groove

getTransmitter

protected javax.sound.midi.Transmitter getTransmitter()
The transmitter that is attached to the synthesizer. Provided so that subclasses can make additive changes.

Returns:
the transmitter attached to the synthesizer

isActive

public boolean isActive()
Whether the Groove is active.

Returns:
true if active, false otherwise

getTeamSet

public java.util.Set<GameUtils.Team> getTeamSet()
The number of teams for which parts have been assigned.

Returns:
the Set of teams of which this Groove is aware.

setVolumePercentage

public void setVolumePercentage(double percent)
Description copied from interface: Equalizable
Sets the volume percentage of the object independently of other volume manipulations, such as fading.

Specified by:
setVolumePercentage in interface Equalizable
Parameters:
percent - the new volume percentage

getVolumePercentage

public double getVolumePercentage()
Description copied from interface: Equalizable
Gets the independent volume percentage of the object.

Specified by:
getVolumePercentage in interface Equalizable
Returns:
the volume percentage

activate

public void activate(GameUtils.Team team)
Activates the part associated with the given team for the default duration.

Parameters:
team - the team to activate

activate

public void activate(GameUtils.Team team,
                     int duration)
Activates the part associated with the given team for the given duration.

Parameters:
team - the team to activate
duration - the duration to play for

deactivate

public void deactivate(GameUtils.Team team)
Deactivates the part associated with the given team.

Parameters:
team - the team to deactivate