Channel
Keywords: micromod.Channel class

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 Channel

    java.lang.Object
      micromod.Channel

public class Channel
extends java.lang.Object

A Channel attemps to do a bit of Amiga hardware emulation to play ProTracker modules a bit better than most. In my experience, this implementation can play some modules that even SurfSmurf can't manage. There are still one or two tunes that won't sound entirely correct, but I believe this is one of the better implementations. The justification for the design of this class is that it provides a protracker specific channel interface and allows the InstrumentPlayer,LoopDecoder,resampler interfaces to be reused in other mod players. In fact, InstrumentPlayer and LoopDecoder have been hacked to better emulate ProTracker. This is an advantage of using different codebases for each module type.

Field Summary
`protected int` | `amplitude`
`protected int` | `fineTune`
`protected int[]` | `fineTuneTable` A log table for calculating fine tuned periods.
`protected static int` | `FIXED_POINT_SHIFT`
`protected InstrumentPlayer` | `instrumentPlayer`
`protected int` | `leftPan`
`protected int` | `mixerStepPrecalc`
`protected int` | `period`
`protected int` | `rightPan`
`protected int` | `volume`

Constructor Summary
`Channel(int samplingRate, boolean pal)` Constructor

Method Summary
`protected void` | `calculateMixerStep(int period, int fineTune)` Calculate the step and subStep values for the resampler, from the specified period and fineTune value.
`void` | `configure(int samplingRate, boolean pal)` Configure the Channel to use the specified sampling rate and PAL/NTSC mode.
`void` | `getAudio(short[] buffer, int length, Resampler resampler, boolean snapBack)` Get resampled audio into the specified buffers.
`int` | `getLeftAmplitude()`
`int` | `getPeriod()` Get the current period of the channel.Used so the Modulator can, er, modulate
`int` | `getRightAmplitude()`
`int` | `getVolume()` Get the current ProTracker volume of the channel, from 0 to 64.
`boolean` | `isSilent()`
`void` | `reset()` Overrides reset() to reinitialise the default volume and period.
`void` | `setFineTune(int fineTune)` Set the finetune.
`void` | `setPanning(int left, int right)` Set the leftAmp and rightAmp members to specify the panning.
`void` | `setPeriod(int period, boolean permanent)` Set the period using the conventional ProTracker period notation.
`void` | `setSamplePosition(int samplePosition)` Set the current sample position
`void` | `setVolume(int volume, boolean permanent)` Set the volume from 0 to 64.
`protected void` | `switchInstrument(boolean trig)` Play the assigned instrument.
`void` | `trigger(Instrument instrument, int period)` Trigger an instrument on the channel to play at the specified pitch.

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

Field Detail

### FIXED_POINT_SHIFT

    protected static final int FIXED_POINT_SHIFT

See Also:
  Constant Field Values

### period

    protected int period

### volume

    protected int volume

### fineTune

    protected int fineTune

### amplitude

    protected int amplitude

### leftPan

    protected int leftPan

### rightPan

    protected int rightPan

### mixerStepPrecalc

    protected int mixerStepPrecalc

### instrumentPlayer

    protected InstrumentPlayer instrumentPlayer

### fineTuneTable

    protected int[] fineTuneTable

  A log table for calculating fine tuned periods.

Constructor Detail

### Channel

    public Channel(int samplingRate,
                   boolean pal)

  Constructor

Method Detail

### configure

    public void configure(int samplingRate,
                          boolean pal)

  Configure the Channel to use the specified sampling rate and PAL/NTSC mode.

### reset

    public void reset()

  Overrides reset() to reinitialise the default volume and period.

### trigger

    public void trigger(Instrument instrument,
                        int period)

  Trigger an instrument on the channel to play at the specified pitch. Call this for every row, even if the row is empty, since it resets the volume and pitch modulations done by eg) vibrato/tremolo ProTracker behaviour is currently as follows: Valid instrument, period > 0 : Plays from instrument start as normal. Null instrument, period > 0 : Assigned instrument is triggered at period. Valid instrument, period = 0 : Instrument is "assigned" but not triggered. Valid instrument, period =-1 : Instrument is "switched over" without retrig. Anything else is ignored. This behaviour will probably change after some testing, since I know it's not exactly correct.

### getPeriod

    public int getPeriod()

  Get the current period of the channel.Used so the Modulator can, er, modulate

### getVolume

    public int getVolume()

  Get the current ProTracker volume of the channel, from 0 to 64.

### setPeriod

    public void setPeriod(int period,
                          boolean permanent)

  Set the period using the conventional ProTracker period notation.

  Parameters:
    `permanent` - if false, the period change only affects one subsequent call to output()

### setVolume

    public void setVolume(int volume,
                          boolean permanent)

  Set the volume from 0 to 64.

  Parameters:
    `permanent` - if false, the period change only affects one subsequent call to output()

### setSamplePosition

    public void setSamplePosition(int samplePosition)

  Set the current sample position

### setFineTune

    public void setFineTune(int fineTune)

  Set the finetune. The finetune of the channel is set automatically when an instrument is assigned. This method is used for the (useless) set finetune ProTracker command.

### setPanning

    public void setPanning(int left,
                           int right)

  Set the leftAmp and rightAmp members to specify the panning. leftAmp and rightAmp are signed integers from -65536 to 65536 to specify the value a sample on either channel should be multiplied by. If one of these is negative, a "surround" effect can be achieved.

### getLeftAmplitude

    public int getLeftAmplitude()

  Returns:
    the current left-speaker amplitude of the channel, in 16 bit fixed point format. This value can be negative, and if it is, the audio should be inverted for a surround effect.

### getRightAmplitude

    public int getRightAmplitude()

  Returns:
    the current right-speaker amplitude of the channel, in 16 bit fixed point format. This value can be negative, and if it is, the audio should be inverted for a surround effect.

### isSilent

    public boolean isSilent()

  Returns:
    true if a call to getAudio() would result only in a blank buffer.

### getAudio

    public void getAudio(short[] buffer,
                         int length,
                         Resampler resampler,
                         boolean snapBack)

  Get resampled audio into the specified buffers. Volume and panning are not applied. You must scale the amplitude according to getLeftAmplitude() and getRightAmplitude().

  Parameters:
    `snapBack` - Do not update the sample-pointers, so the same audio can be retrieved again.

### switchInstrument

    protected void switchInstrument(boolean trig)

  Play the assigned instrument.

  Parameters:
    `trig` - If true, will play instrument from start.

### calculateMixerStep

    protected void calculateMixerStep(int period,
                                      int fineTune)

  Calculate the step and subStep values for the resampler, from the specified period and fineTune value.

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