Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## micromod
Class MicroMod

    java.lang.Object
      micromod.MicroMod

public class MicroMod
extends java.lang.Object

MicroMod 0.9xxx! Copyright 2002 Martin Cameron. This is Free Software subject to the terms of the Gnu Lesser General Public Licence(LGPL). Please see the included file "LGPL-2.1" This player was designed for the "standard" Amiga ProTracker format with extensions for more than four channels and channel panning. The player should work well with most clone formats such as FTK and older formats such as NoiseTracker, SoundTracker2.X and StarTrekker. Problems to address for 0.99: Missing glissando fx. The original Amiga period limits are enforced, so some pc mods may not work. Future plans: Needs a complete functional comparison with Amiga ProTracker. Rewrite planned. Lots of design ideas (will implement in MuXM first). Inherent Limitations: The original and rare Ultimate SoundTracker module format is not supported. The pattern loop command is ignored, for both design and compatibility reasons.

Field Summary
`protected int` | `currentTick`
`protected short[]` | `leftOutBuffer`
`protected static int` | `LOG2_VOL_RAMP_SAMPLES`
`static int` | `MAX_SAMPLES_PER_TICK`
`static java.lang.String` | `MICROMOD_VERSION`
`protected Mixer` | `mixer`
`protected OutputDevice` | `output`
`protected Resampler` | `resampler`
`protected short[]` | `rightOutBuffer`
`protected Sequencer` | `sequencer`
`protected Synthesizer` | `synthesizer`
`protected int` | `tickLength`
`protected static int` | `VOL_RAMP_SAMPLES`
`protected short[]` | `volRampLeftBuffer`
`protected short[]` | `volRampRightBuffer`

Constructor Summary
`MicroMod(Module module, PCM16StreamOutputDevice output, Resampler resampler)`

Method Summary
`void` | `doPlayback()` Call this method in an infinite loop to render a "tick" of audio at a time.
`void` | `doRealTimePlayback()`
`int` | `getCurrentPatternPos()`
`int` | `getSequenceLoopCount()`
`int` | `getSongLengthPatterns()`
`boolean` | `isPAL()`
`void` | `setCurrentPatternPos(int pos)` Set the pattern in the sequence to play from.
`void` | `setGain(int gain)` Set the gain value.
`void` | `setModule(Module module)` Assign another module to the player to play from the beginning.
`void` | `setOutputDevice(PCM16StreamOutputDevice output)` Assign another open output device to the player.
`void` | `setResampler(Resampler resampler)` Switch to the specified resampling algorithm.
`void` | `setWaveScaler(WaveScaler waveScaler)` Switch to the specified WaveScaler (dithering algorithm).
`void` | `setWaveShaper(WaveShaper waveShaper)` Switch to the specified WaveShaper (compressor/expander/limiter etc)
`void` | `usePAL(boolean pal)` Set whether to use PAL or NTSC decoding (default PAL for ProTracker/NoiseTracker)
`protected void` | `volumeRamp(short[] leftBuffer, short[] rightBuffer)` Crossfade the volume ramping buffers with the start of the specified buffers.
`protected void` | `writeAudio(int length, boolean ramp, boolean updateRamp)` Render length samples of audio and write them to the output device.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MICROMOD_VERSION

    public static final java.lang.String MICROMOD_VERSION

See Also:
  Constant Field Values

### output

    protected OutputDevice output

### sequencer

    protected Sequencer sequencer

### synthesizer

    protected Synthesizer synthesizer

### resampler

    protected Resampler resampler

### mixer

    protected Mixer mixer

### MAX_SAMPLES_PER_TICK

    public static final int MAX_SAMPLES_PER_TICK

See Also:
  Constant Field Values

### LOG2_VOL_RAMP_SAMPLES

    protected static final int LOG2_VOL_RAMP_SAMPLES

See Also:
  Constant Field Values

### VOL_RAMP_SAMPLES

    protected static final int VOL_RAMP_SAMPLES

See Also:
  Constant Field Values

### volRampLeftBuffer

    protected short[] volRampLeftBuffer

### volRampRightBuffer

    protected short[] volRampRightBuffer

### leftOutBuffer

    protected short[] leftOutBuffer

### rightOutBuffer

    protected short[] rightOutBuffer

### tickLength

    protected int tickLength

### currentTick

    protected int currentTick

Constructor Detail

### MicroMod

    public MicroMod(Module module,
                    PCM16StreamOutputDevice output,
                    Resampler resampler)

Parameters:
  `module` - The module to be played.
  `output` - An open output device to send the audio to.

Method Detail

### setModule

    public void setModule(Module module)

  Assign another module to the player to play from the beginning.

### setOutputDevice

    public void setOutputDevice(PCM16StreamOutputDevice output)

  Assign another open output device to the player.

### setResampler

    public void setResampler(Resampler resampler)

  Switch to the specified resampling algorithm.

### setWaveShaper

    public void setWaveShaper(WaveShaper waveShaper)

  Switch to the specified WaveShaper (compressor/expander/limiter etc)

### setWaveScaler

    public void setWaveScaler(WaveScaler waveScaler)

  Switch to the specified WaveScaler (dithering algorithm).

### usePAL

    public void usePAL(boolean pal)

  Set whether to use PAL or NTSC decoding (default PAL for ProTracker/NoiseTracker)

### isPAL

    public boolean isPAL()

  Returns:
    true if currently decoding in PAL, else NTSC

### setGain

    public void setGain(int gain)

  Set the gain value. 4096 represents a gain of 1.0 that allows for all channels to be panned to one side without clipping. The default is 2.0, which prevents clipping using Amiga 4 channel mods, but can potentially cause clipping in multichannel mods which use the panning commands. The maximum gain is 8.0.

### getSongLengthPatterns

    public int getSongLengthPatterns()

  Returns:
    The length in patterns of the current song.

### getCurrentPatternPos

    public int getCurrentPatternPos()

  Returns:
    The pattern being played.

### setCurrentPatternPos

    public void setCurrentPatternPos(int pos)

  Set the pattern in the sequence to play from. To restart playback of the current module from scratch, set pos=0.

### getSequenceLoopCount

    public int getSequenceLoopCount()

  Returns:
    the number of times the current pattern in the sequence has been played. You can use this to end if the song begins to loop around.

### doRealTimePlayback

    public void doRealTimePlayback()

### doPlayback

    public void doPlayback()

  Call this method in an infinite loop to render a "tick" of audio at a time. The playing thread will block while writing to the output device. If you want to use this player in a game or demo, you should use the doRealTimePlayback() method instead, as this will ensure even cpu usage.

### writeAudio

    protected void writeAudio(int length,
                              boolean ramp,
                              boolean updateRamp)

  Render length samples of audio and write them to the output device. This method is just common code used by doPlayback().

  Parameters:
    `ramp` - Crossfade the volume ramp buffer with the start of the audio.
    `updateRamp` - Render a few more samples into the volume ramp buffer.

### volumeRamp

    protected void volumeRamp(short[] leftBuffer,
                              short[] rightBuffer)

  Crossfade the volume ramping buffers with the start of the specified buffers. If the values are the same in each buffer, the result will be unchanged. This is important to maintain sound quality.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD