com.vwp.sound.mod.modplay.player
Interface Mixer

All Known Implementing Classes:
DefaultMixer

public interface Mixer

By implementing this interface it's possible to use a different mixer than the default. A mixer mixes sound from a set of tracks (channels). Use setTrack to initialize a track. The mixer is free to handle output anyway it likes, but it's a good idea to use one of the supplied output plugins form com.vwp.sound.mod.modplay.output.


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].
 

Method Detail

setTrack

void setTrack(short[] sampleData,
              double offset,
              double rate,
              double volume,
              double panning,
              int loopType,
              int loopStart,
              int loopLength,
              int track)
              throws PlayerException
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.

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

play

void play(double millisecs)
          throws PlayerException
mix and play the indicated number of millisecounds of sound

Parameters:
millisecs - the number of milliseconds of sound to play
Throws:
PlayerException

getNumberOfTracks

int getNumberOfTracks()
Returns:
the maximal number of tracks this mixer can handle

setAmplification

void setAmplification(double amp)
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.

Parameters:
amp - amplification

getAmplification

double getAmplification()
get the amplification


setVolume

void setVolume(double volume)
sets the volume The legal values are [0-1]. Default value is 1

Parameters:
volume -

getVolume

double getVolume()
Returns:
the volume

setBalance

void setBalance(double balance)
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

Parameters:
balance -

getBalance

double getBalance()
get the balance


setSeparation

void setSeparation(double separation)
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:

Parameters:
separation - the separation of left and right channel

getSeparation

double getSeparation()
get the channel separation


setMute

void setMute(int track,
             boolean mute)
mutes a track

Parameters:
mute - mute if true, unmute if false

isMute

boolean isMute(int track)