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

java.lang.Object
  extended by com.vwp.sound.mod.modplay.player.DefaultMixer
All Implemented Interfaces:
Mixer

public class DefaultMixer
extends java.lang.Object
implements Mixer

This is the default mixer used by JMOD. For simplicity, it is hardcoded to produce 16 bits, 44100Hz samplerate, stereo sound. If lower quality is desired, downsampling must be done by the used output plugin.


Constructor Summary
DefaultMixer(Output output, java.lang.Class lowLevelMixerClass, int numberOfTracks)
           
 
Method Summary
 double getAmplification()
          get the amplification
 double getBalance()
          get the balance
 int getNumberOfTracks()
           
 double getSeparation()
          get the channel separation
 double getVolume()
           
 boolean isMute(int track)
           
 void play(double millisecs)
          mix and play the indicated number of millisecounds of sound
 void setAmplification(double amp)
          sets the amplification The legal values are [0-inf].
 void setBalance(double balance)
          sets the balance The legal values are [0-1].
 void setMute(int track, boolean mute)
          mutes a track
 void setSeparation(double separation)
          sets the channel separation The legal values are [0-1].
 void setTrack(short[] sampleData, double offset, double rate, double volume, double panning, int loopType, int loopStart, int looplength, int track)
          set up a track.
 void setVolume(double volume)
          sets the volume The legal values are [0-1].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMixer

public DefaultMixer(Output output,
                    java.lang.Class lowLevelMixerClass,
                    int numberOfTracks)
Parameters:
output - the output plugin used by this mixer
lowLevelMixerClass - class who implements the LowLevelMixer interface
numberOfTracks - the number of tracks this mixer should be able to mix
Method Detail

setTrack

public void setTrack(short[] sampleData,
                     double offset,
                     double rate,
                     double volume,
                     double panning,
                     int loopType,
                     int loopStart,
                     int looplength,
                     int track)
              throws PlayerException
Description copied from interface: Mixer
set up a track. The track will continue to play the given sample with the given parameters until the next time this method is called on the same track.

Specified by:
setTrack in interface Mixer
Parameters:
sampleData - the data of the sample that should be played
offset - the offset from where the sample should start playing
rate - the rate the sample should be played at
volume - the volume of the sample
panning - the panning of the sample
loopType - what kind of looping (if any) should be done on this sample
loopStart - the start of the loop
looplength - the lenght of the loop
track - the track there this sample should be played
Throws:
PlayerException

getNumberOfTracks

public int getNumberOfTracks()
Specified by:
getNumberOfTracks in interface Mixer
Returns:
the maximal number of tracks this mixer can handle

setAmplification

public void setAmplification(double amp)
Description copied from interface: Mixer
sets the amplification The legal values are [0-inf]. Default value is 1. If this value is set > 1 clipping may occur. To avoid clipping, the the mixer must divide the volume of each track by the number of tracks. This will somethimes result in too low volume. This can be fixed by setting the amplification to a value > 1.0.

Specified by:
setAmplification in interface Mixer
Parameters:
amp - amplification

getAmplification

public double getAmplification()
Description copied from interface: Mixer
get the amplification

Specified by:
getAmplification in interface Mixer

setVolume

public void setVolume(double volume)
Description copied from interface: Mixer
sets the volume The legal values are [0-1]. Default value is 1

Specified by:
setVolume in interface Mixer

getVolume

public double getVolume()
Specified by:
getVolume in interface Mixer
Returns:
the volume

setBalance

public void setBalance(double balance)
Description copied from interface: Mixer
sets the balance The legal values are [0-1]. Default value is 0.5 balance >= 0.5 gives 100% in right channel and 2*(1-balance)*100% in left channel balance <= 0.5 gives 100% in left channel and 2*balance*100% in right channel

Specified by:
setBalance in interface Mixer

getBalance

public double getBalance()
Description copied from interface: Mixer
get the balance

Specified by:
getBalance in interface Mixer

setSeparation

public void setSeparation(double separation)
Description copied from interface: Mixer
sets the channel separation The legal values are [0-1]. Default value is 1 Some module formats dictates that some tracks are played in the left channel and others in the right. This often sound strange, especially when using headphones. The separation is used to put the sound more "in the midle". The following formulas are used to calculate the volume in the right an left channels:

Specified by:
setSeparation in interface Mixer
Parameters:
separation - the separation of left and right channel

getSeparation

public double getSeparation()
Description copied from interface: Mixer
get the channel separation

Specified by:
getSeparation in interface Mixer

setMute

public void setMute(int track,
                    boolean mute)
Description copied from interface: Mixer
mutes a track

Specified by:
setMute in interface Mixer
mute - mute if true, unmute if false

isMute

public boolean isMute(int track)
Specified by:
isMute in interface Mixer

play

public void play(double millisecs)
          throws PlayerException
Description copied from interface: Mixer
mix and play the indicated number of millisecounds of sound

Specified by:
play in interface Mixer
Parameters:
millisecs - the number of milliseconds of sound to play
Throws:
PlayerException