org.tritonus.share.sampled
Class FloatSampleBuffer

java.lang.Object
  extended by org.tritonus.share.sampled.FloatSampleBuffer

public class FloatSampleBuffer
extends java.lang.Object

A class for small buffers of samples in linear, 32-bit floating point format.

It is supposed to be a replacement of the byte[] stream architecture of JavaSound, especially for chains of AudioInputStreams. Ideally, all involved AudioInputStreams handle reading into a FloatSampleBuffer.

Specifications:

  1. Channels are separated, i.e. for stereo there are 2 float arrays with the samples for the left and right channel
  2. All data is handled in samples, where one sample means one float value in each channel
  3. All samples are normalized to the interval [-1.0...1.0]

When a cascade of AudioInputStreams use FloatSampleBuffer for processing, they may implement the interface FloatSampleInput. This signals that this stream may provide float buffers for reading. The data is not converted back to bytes, but stays in a single buffer that is passed from stream to stream. For that serves the read(FloatSampleBuffer) method, which is then used as replacement for the byte-based read functions of AudioInputStream.
However, backwards compatibility must always be retained, so even when an AudioInputStream implements FloatSampleInput, it must work the same way when any of the byte-based read methods is called.
As an example, consider the following set-up:

So, what happens when a block of samples is read from pcmAIS2 ?
  1. the read(byte[]) method of pcmAIS2 is called
  2. pcmAIS2 always operates on floating point samples, so it uses an own instance of FloatSampleBuffer and initializes it with the number of samples requested in the read(byte[]) method.
  3. It queries pcmAIS1 for the FloatSampleInput interface. As it implements it, pcmAIS2 calls the read(FloatSampleBuffer) method of pcmAIS1.
  4. pcmAIS1 notes that its underlying stream does not support floats, so it instantiates a byte buffer which can hold the number of samples of the FloatSampleBuffer passed to it. It calls the read(byte[]) method of auAIS.
  5. auAIS fills the buffer with the bytes.
  6. pcmAIS1 calls the initFromByteArray method of the float buffer to initialize it with the 8 bit data.
  7. Then pcmAIS1 processes the data: as the float buffer is normalized, it does nothing with the buffer - and returns control to pcmAIS2. The SampleSizeInBits field of the AudioFormat of pcmAIS1 defines that it should be 16 bits.
  8. pcmAIS2 receives the filled buffer from pcmAIS1 and does its processing on the buffer - it adds the reverb.
  9. As pcmAIS2's read(byte[]) method had been called, pcmAIS2 calls the convertToByteArray method of the float buffer to fill the byte buffer with the resulting samples.

To summarize, here are some advantages when using a FloatSampleBuffer for streaming:

Simple benchmarks showed that the processing requirements for the conversion to and from float is about the same as when converting it to shorts or ints without dithering, and significantly higher with dithering. An own implementation of a random number generator may improve this.

"Lazy" deletion of samples and channels:

The lazy mechanism can save many array instantiation (and copy-) operations for the sake of performance. All relevant methods exist in a second version which allows explicitely to disable lazy deletion.

Use the reset functions to clear the memory and remove hidden samples and channels.

Note that the lazy mechanism implies that the arrays returned from getChannel(int) may have a greater size than getSampleCount(). Consequently, be sure to never rely on the length field of the sample arrays.

As an example, consider a chain of converters that all act on the same instance of FloatSampleBuffer. Some converters may decrease the sample count (e.g. sample rate converter) and delete channels (e.g. PCM2PCM converter). So, processing of one block will decrease both. For the next block, all starts from the beginning. With the lazy mechanism, all float arrays are only created once for processing all blocks.
Having lazy disabled would require for each chunk that is processed

  1. new instantiation of all channel arrays at the converter chain beginning as they have been either deleted or decreased in size during processing of the previous chunk, and
  2. re-instantiation of all channel arrays for the reduction of the sample count.

Dithering:
By default, this class uses dithering for reduction of sample width (e.g. original data was 16bit, target data is 8bit). As dithering may be needed in other cases (especially when the float samples are processed using DSP algorithms), or it is preferred to switch it off, dithering can be explicitely switched on or off with the method setDitherMode(int).
For a discussion about dithering, see here and here.


Field Summary
static int DITHER_MODE_AUTOMATIC
          Constant for setDitherMode: dithering will be enabled if sample size is decreased
static int DITHER_MODE_OFF
          Constant for setDitherMode: dithering will not be done
static int DITHER_MODE_ON
          Constant for setDitherMode: dithering will be done
 
Constructor Summary
FloatSampleBuffer()
          Create an instance with initially no channels.
FloatSampleBuffer(byte[] buffer, int offset, int byteCount, AudioFormat format)
          Creates a new instance of FloatSampleBuffer and initializes it with audio data given in the interleaved byte array buffer.
FloatSampleBuffer(int channelCount, int sampleCount, float sampleRate)
          Create an empty FloatSampleBuffer with the specified number of channels, samples, and the specified sample rate.
 
Method Summary
 void addChannel(boolean silent)
          Add a channel to this buffer, e.g.
 void changeSampleCount(int newSampleCount, boolean keepOldSamples)
          Resizes this buffer.
static void checkFormatSupported(AudioFormat format)
          Verify that the specified AudioFormat can be converted to and from.
 byte[] convertToByteArray(AudioFormat format)
          Creates a new byte[] buffer, fills it with the audio data, and returns it.
 int convertToByteArray(byte[] buffer, int offset, AudioFormat format)
          Writes this sample buffer's audio data to buffer as an interleaved byte array.
 int convertToByteArray(int readOffset, int lenInSamples, byte[] buffer, int writeOffset, AudioFormat format)
          Writes this sample buffer's audio data to buffer as an interleaved byte array.
 void copy(int sourceIndex, int destIndex, int length)
          Copies data inside all channel.
 void copy(int channel, int sourceIndex, int destIndex, int length)
          Copies data inside a channel.
 void copyChannel(int sourceChannel, int targetChannel)
          Copy sourceChannel's audio data to targetChannel, identified by their indices in the channel list.
 void copyChannel(int sourceChannel, int sourceOffset, int targetChannel, int targetOffset, int aSampleCount)
          Copy sampleCount samples from sourceChannel at position srcOffset to targetChannel at position targetOffset.
 int copyTo(FloatSampleBuffer dest, int destOffset, int count)
          Copies the contents of this buffer to the destination buffer at the destOffset.
 int copyTo(int srcOffset, FloatSampleBuffer dest, int destOffset, int count)
          Copies the specified part of this buffer to the destination buffer.
 void expandChannel(int targetChannelCount)
          Mix up of 1 channel to n channels.
It copies the first channel to all newly created channels.
 java.lang.Object[] getAllChannels()
          Get an array of all channels.
 int getByteArrayBufferSize(AudioFormat format)
           
 int getByteArrayBufferSize(AudioFormat format, int lenInSamples)
           
 float[] getChannel(int channel)
          Get the actual audio data of one channel.
Modifying this array will modify the audio samples of this FloatSampleBuffer.
 int getChannelCount()
           
 float getDitherBits()
           
 int getDitherMode()
           
 int getSampleCount()
           
 float getSampleRate()
           
 void init(int newChannelCount, int newSampleCount, float newSampleRate)
          Initialize this sample buffer to have the specified channels, sample count, and sample rate.
 void init(int newChannelCount, int newSampleCount, float newSampleRate, boolean lazy)
          Initialize this sample buffer to have the specified channels, sample count, and sample rate.
 void initFromByteArray(byte[] buffer, int offset, int byteCount, AudioFormat format)
          Resets this buffer with the audio data specified in the arguments.
 void initFromByteArray(byte[] buffer, int offset, int byteCount, AudioFormat format, boolean lazy)
          Resets this buffer with the audio data specified in the arguments.
 void initFromFloatSampleBuffer(FloatSampleBuffer source)
          Resets this sample buffer with the data in source.
 void insertChannel(int index, boolean silent)
          Insert a (silent) channel at position index.
 void insertChannel(int index, boolean silent, boolean lazy)
          Inserts a channel at position index.
 void linearFade(float startVol, float endVol)
          Fade the volume level of this buffer from the given start volume to the end volume.
 void linearFade(float startVol, float endVol, int offset, int count)
          Fade the volume level of this buffer from the given start volume to the end volume.
 void linearFade(int channel, float startVol, float endVol, int offset, int count)
          Fade the volume level of the specified channel from the given start volume to the end volume.
 void makeSilence()
          Silence the entire audio buffer.
 void makeSilence(int channel)
          Silence the specified channel
 void makeSilence(int offset, int count)
          Silence the entire buffer in the specified range on all channels.
 void makeSilence(int channel, int offset, int count)
          Silence the specified channel in the specified range
 void mix(FloatSampleBuffer source)
          Mixes source to this buffer by adding all samples.
 void mix(FloatSampleBuffer source, int sourceOffset, int thisOffset, int count)
          Mixes source samples to this buffer by adding the sample values.
 void mixDownChannels()
          Mix down of n channels to one channel.
It uses a simple mixdown: all other channels are added to first channel.
The volume is NOT lowered ! Be aware, this might cause clipping when converting back to integer samples.
 void removeChannel(int channel)
          performs a lazy remove of the channel
 void removeChannel(int channel, boolean lazy)
          Removes a channel.
 void reset()
          Deletes all channels, frees memory...
 void reset(int newChannels, int newSampleCount, float newSampleRate)
          Destroys any existing data and creates new channels.
 void setDitherBits(float ditherBits)
          Set the number of bits for dithering.
 void setDitherMode(int mode)
          Sets the mode for dithering.
 float[] setRawChannel(int channel, float[] data)
          Low-level method to directly set the array for the given channel.
 void setSampleCount(int newSampleCount, boolean keepOldSamples)
          Alias for changeSampleCount
 void setSampleRate(float sampleRate)
          Sets the sample rate of this buffer.
 void setSamplesFromBytes(byte[] input, int inByteOffset, AudioFormat format, int floatOffset, int frameCount)
          Initializes audio data from the provided byte array.
 int writeByteBuffer(byte[] buffer, int srcByteOffset, AudioFormat format, int dstSampleOffset, int aSampleCount)
          Write the contents of the byte array to this buffer, overwriting existing data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DITHER_MODE_AUTOMATIC

public static final int DITHER_MODE_AUTOMATIC
Constant for setDitherMode: dithering will be enabled if sample size is decreased

See Also:
Constant Field Values

DITHER_MODE_ON

public static final int DITHER_MODE_ON
Constant for setDitherMode: dithering will be done

See Also:
Constant Field Values

DITHER_MODE_OFF

public static final int DITHER_MODE_OFF
Constant for setDitherMode: dithering will not be done

See Also:
Constant Field Values
Constructor Detail

FloatSampleBuffer

public FloatSampleBuffer()
Create an instance with initially no channels.


FloatSampleBuffer

public FloatSampleBuffer(int channelCount,
                         int sampleCount,
                         float sampleRate)
Create an empty FloatSampleBuffer with the specified number of channels, samples, and the specified sample rate.


FloatSampleBuffer

public FloatSampleBuffer(byte[] buffer,
                         int offset,
                         int byteCount,
                         AudioFormat format)
Creates a new instance of FloatSampleBuffer and initializes it with audio data given in the interleaved byte array buffer.

Method Detail

init

public void init(int newChannelCount,
                 int newSampleCount,
                 float newSampleRate)
Initialize this sample buffer to have the specified channels, sample count, and sample rate. If LAZY_DEFAULT is true, as much as possible will existing arrays be reused. Otherwise, any hidden channels are freed.

Parameters:
newChannelCount -
newSampleCount -
newSampleRate -
Throws:
java.lang.IllegalArgumentException - if newChannelCount or newSampleCount are negative, or newSampleRate is not positive.

init

public void init(int newChannelCount,
                 int newSampleCount,
                 float newSampleRate,
                 boolean lazy)
Initialize this sample buffer to have the specified channels, sample count, and sample rate. If lazy is true, as much as possible will existing arrays be reused. Otherwise, any hidden channels are freed.

Parameters:
newChannelCount -
newSampleCount -
newSampleRate -
lazy -
Throws:
java.lang.IllegalArgumentException - if newChannelCount or newSampleCount are negative, or newSampleRate is not positive.

checkFormatSupported

public static void checkFormatSupported(AudioFormat format)
Verify that the specified AudioFormat can be converted to and from. If the format is not supported, an IllegalArgumentException is thrown.

Throws:
java.lang.IllegalArgumentException - if the format is not supported

initFromByteArray

public void initFromByteArray(byte[] buffer,
                              int offset,
                              int byteCount,
                              AudioFormat format)
Resets this buffer with the audio data specified in the arguments. This FloatSampleBuffer's sample count will be set to byteCount / format.getFrameSize(). If LAZY_DEFAULT is true, it will use lazy deletion.

Throws:
java.lang.IllegalArgumentException

initFromByteArray

public void initFromByteArray(byte[] buffer,
                              int offset,
                              int byteCount,
                              AudioFormat format,
                              boolean lazy)
Resets this buffer with the audio data specified in the arguments. This FloatSampleBuffer's sample count will be set to byteCount / format.getFrameSize().

Parameters:
lazy - if true, then existing channels will be tried to be re-used to minimize garbage collection.
Throws:
java.lang.IllegalArgumentException

initFromFloatSampleBuffer

public void initFromFloatSampleBuffer(FloatSampleBuffer source)
Resets this sample buffer with the data in source.


writeByteBuffer

public int writeByteBuffer(byte[] buffer,
                           int srcByteOffset,
                           AudioFormat format,
                           int dstSampleOffset,
                           int aSampleCount)
Write the contents of the byte array to this buffer, overwriting existing data. If the byte array has fewer channels than this float buffer, only the first channels are written. Vice versa, if the byte buffer has more channels than this float buffer, only the first channels of the byte buffer are written to this buffer.

The format and the number of samples of this float buffer are not changed, so if the byte array has more samples than fit into this float buffer, it is not expanded.

Parameters:
buffer - the byte buffer to write to this float buffer
srcByteOffset - the offset in bytes in buffer where to start reading
format - the audio format of the bytes in buffer
dstSampleOffset - the offset in samples where to start writing the converted float data into this float buffer
aSampleCount - the number of samples to write
Returns:
the number of samples actually written

reset

public void reset()
Deletes all channels, frees memory... This also removes hidden channels by lazy remove.


reset

public void reset(int newChannels,
                  int newSampleCount,
                  float newSampleRate)
Destroys any existing data and creates new channels. It also destroys lazy removed channels and samples. Channels will not be silenced, though.


getByteArrayBufferSize

public int getByteArrayBufferSize(AudioFormat format)
Returns:
the required size of the buffer for calling convertToByteArray(..) is called

getByteArrayBufferSize

public int getByteArrayBufferSize(AudioFormat format,
                                  int lenInSamples)
Parameters:
lenInSamples - how many samples to be considered
Returns:
the required size of the buffer for the given number of samples for calling convertToByteArray(..)

convertToByteArray

public int convertToByteArray(byte[] buffer,
                              int offset,
                              AudioFormat format)
Writes this sample buffer's audio data to buffer as an interleaved byte array. buffer must be large enough to hold all data.

Returns:
number of bytes written to buffer
Throws:
java.lang.IllegalArgumentException - when buffer is too small or format doesn't match

convertToByteArray

public int convertToByteArray(int readOffset,
                              int lenInSamples,
                              byte[] buffer,
                              int writeOffset,
                              AudioFormat format)
Writes this sample buffer's audio data to buffer as an interleaved byte array. buffer must be large enough to hold all data.

Parameters:
readOffset - the sample offset from where samples are read from this FloatSampleBuffer
lenInSamples - how many samples are converted
buffer - the byte buffer written to
writeOffset - the byte offset in buffer
Returns:
number of bytes written to buffer
Throws:
java.lang.IllegalArgumentException - when buffer is too small or format doesn't match

convertToByteArray

public byte[] convertToByteArray(AudioFormat format)
Creates a new byte[] buffer, fills it with the audio data, and returns it.

Throws:
java.lang.IllegalArgumentException - when sample rate or channels do not match
See Also:
convertToByteArray(byte[], int, AudioFormat)

changeSampleCount

public void changeSampleCount(int newSampleCount,
                              boolean keepOldSamples)
Resizes this buffer.

If keepOldSamples is true, as much as possible samples are retained. If the buffer is enlarged, silence is added at the end. If keepOldSamples is false, existing samples may get discarded, the buffer may then contain random samples.


makeSilence

public void makeSilence()
Silence the entire audio buffer.


makeSilence

public void makeSilence(int offset,
                        int count)
Silence the entire buffer in the specified range on all channels.


makeSilence

public void makeSilence(int channel)
Silence the specified channel


makeSilence

public void makeSilence(int channel,
                        int offset,
                        int count)
Silence the specified channel in the specified range


linearFade

public void linearFade(float startVol,
                       float endVol)
Fade the volume level of this buffer from the given start volume to the end volume. E.g. to implement a fade in, use startVol=0 and endVol=1.

Parameters:
startVol - the start volume as a linear factor [0..1]
endVol - the end volume as a linear factor [0..1]

linearFade

public void linearFade(float startVol,
                       float endVol,
                       int offset,
                       int count)
Fade the volume level of this buffer from the given start volume to the end volume. The fade will start at the offset, and will have reached endVol after count samples. E.g. to implement a fade in, use startVol=0 and endVol=1.

Parameters:
startVol - the start volume as a linear factor [0..1]
endVol - the end volume as a linear factor [0..1]
offset - the offset in this buffer where to start the fade (in samples)
count - the number of samples to fade

linearFade

public void linearFade(int channel,
                       float startVol,
                       float endVol,
                       int offset,
                       int count)
Fade the volume level of the specified channel from the given start volume to the end volume. The fade will start at the offset, and will have reached endVol after count samples. E.g. to implement a fade in, use startVol=0 and endVol=1.

Parameters:
channel - the channel to do the fade
startVol - the start volume as a linear factor [0..1]
endVol - the end volume as a linear factor [0..1]
offset - the offset in this buffer where to start the fade (in samples)
count - the number of samples to fade

addChannel

public void addChannel(boolean silent)
Add a channel to this buffer, e.g. adding a channel to a mono buffer will make it a stereo buffer.

Parameters:
silent - if true, the channel is explicitly silenced. Otherwise the new channel may contain random data.

insertChannel

public void insertChannel(int index,
                          boolean silent)
Insert a (silent) channel at position index. If LAZY_DEFAULT is true, this is done lazily.


insertChannel

public void insertChannel(int index,
                          boolean silent,
                          boolean lazy)
Inserts a channel at position index.

If silent is true, the new channel will be silent. Otherwise it will contain random data.

If lazy is true, hidden channels which have at least getSampleCount() elements will be examined for reusage as inserted channel.
If lazy is false, still hidden channels are reused, but it is assured that the inserted channel has exactly getSampleCount() elements, thus not wasting memory.


removeChannel

public void removeChannel(int channel)
performs a lazy remove of the channel


removeChannel

public void removeChannel(int channel,
                          boolean lazy)
Removes a channel. If lazy is true, the channel is not physically removed, but only hidden. These hidden channels are reused by subsequent calls to addChannel or insertChannel.


copyChannel

public void copyChannel(int sourceChannel,
                        int targetChannel)
Copy sourceChannel's audio data to targetChannel, identified by their indices in the channel list. Both source and target channel have to exist. targetChannel will be overwritten


copyChannel

public void copyChannel(int sourceChannel,
                        int sourceOffset,
                        int targetChannel,
                        int targetOffset,
                        int aSampleCount)
Copy sampleCount samples from sourceChannel at position srcOffset to targetChannel at position targetOffset. sourceChannel and targetChannel are indices in the channel list. Both source and target channel have to exist. targetChannel will be overwritten


copy

public void copy(int sourceIndex,
                 int destIndex,
                 int length)
Copies data inside all channel. When the 2 regions overlap, the behavior is not specified.


copy

public void copy(int channel,
                 int sourceIndex,
                 int destIndex,
                 int length)
Copies data inside a channel. When the 2 regions overlap, the behavior is not specified.


expandChannel

public void expandChannel(int targetChannelCount)
Mix up of 1 channel to n channels.
It copies the first channel to all newly created channels.

Parameters:
targetChannelCount - the number of channels that this sample buffer will have after expanding. NOT the number of channels to add !
Throws:
java.lang.IllegalArgumentException - if this buffer does not have one channel before calling this method.

mixDownChannels

public void mixDownChannels()
Mix down of n channels to one channel.
It uses a simple mixdown: all other channels are added to first channel.
The volume is NOT lowered ! Be aware, this might cause clipping when converting back to integer samples.


mix

public void mix(FloatSampleBuffer source)
Mixes source to this buffer by adding all samples. At most, source's number of samples, number of channels are mixed. None of the sample count, channel count or sample rate of either buffer are changed. In particular, the caller needs to assure that the sample rate of the buffers match.

Parameters:
source - the buffer to be mixed to this buffer

mix

public void mix(FloatSampleBuffer source,
                int sourceOffset,
                int thisOffset,
                int count)
Mixes source samples to this buffer by adding the sample values. None of the sample count, channel count or sample rate of either buffer are changed. In particular, the caller needs to assure that the sample rate of the buffers match.

This method is not error tolerant, in particular, runtime exceptions will be thrown if the channel counts do not match, or if the offsets and count exceed the buffer's capacity.

Parameters:
source - the source buffer from where to take samples and mix to this one
sourceOffset - offset in source where to start reading samples
thisOffset - offset in this buffer from where to start mixing samples
count - number of samples to mix

copyTo

public int copyTo(FloatSampleBuffer dest,
                  int destOffset,
                  int count)
Copies the contents of this buffer to the destination buffer at the destOffset. At most, dest's number of samples, number of channels are copied. None of the sample count, channel count or sample rate of either buffer are changed. In particular, the caller needs to assure that the sample rate of the buffers match.

Parameters:
dest - the buffer to write to
destOffset - the position in dest where to start writing the samples of this buffer
count - the number of samples to be copied
Returns:
the number of samples copied

copyTo

public int copyTo(int srcOffset,
                  FloatSampleBuffer dest,
                  int destOffset,
                  int count)
Copies the specified part of this buffer to the destination buffer. At most, dest's number of samples, number of channels are copied. None of the sample count, channel count or sample rate of either buffer are changed. In particular, the caller needs to assure that the sample rate of the buffers match.

Parameters:
srcOffset - the start position in this buffer, where to start reading samples
dest - the buffer to write to
destOffset - the position in dest where to start writing the samples
count - the number of samples to be copied
Returns:
the number of samples copied

setSamplesFromBytes

public void setSamplesFromBytes(byte[] input,
                                int inByteOffset,
                                AudioFormat format,
                                int floatOffset,
                                int frameCount)
Initializes audio data from the provided byte array. The float samples are written at destOffset. This FloatSampleBuffer must be big enough to accomodate the samples.

srcBuffer is read from index srcOffset to (srcOffset + (lengthInSamples * format.getFrameSize()))

Parameters:
input - the input buffer in interleaved audio data
inByteOffset - the offset in input
format - input buffer's audio format
floatOffset - the offset where to write the float samples
frameCount - number of samples to write to this sample buffer

getChannelCount

public int getChannelCount()

getSampleCount

public int getSampleCount()

getSampleRate

public float getSampleRate()

setSampleCount

public void setSampleCount(int newSampleCount,
                           boolean keepOldSamples)
Alias for changeSampleCount

Parameters:
newSampleCount - the new number of samples for this buffer
keepOldSamples - if true, the new buffer will keep the current samples in the arrays
See Also:
changeSampleCount(int, boolean)

setSampleRate

public void setSampleRate(float sampleRate)
Sets the sample rate of this buffer. NOTE: no conversion is done. The samples are only re-interpreted.


getChannel

public float[] getChannel(int channel)
Get the actual audio data of one channel.
Modifying this array will modify the audio samples of this FloatSampleBuffer.
NOTE: the returned array may be larger than sampleCount. So in any case, sampleCount is to be respected.

Throws:
java.lang.IllegalArgumentException - if channel is out of bounds

setRawChannel

public float[] setRawChannel(int channel,
                             float[] data)
Low-level method to directly set the array for the given channel. Normally, you do not need this method, as you can conveniently resize the array with changeSampleCount(). This method may be useful for advanced optimization techniques.

Parameters:
channel - the channel to replace
data - the audio sample array
Returns:
the audio data array that was replaced
Throws:
java.lang.IllegalArgumentException - if channel is out of bounds or data is null
See Also:
changeSampleCount(int, boolean)

getAllChannels

public java.lang.Object[] getAllChannels()
Get an array of all channels.

Returns:
all channels as array

setDitherBits

public void setDitherBits(float ditherBits)
Set the number of bits for dithering. Typically, a value between 0.2 and 0.9 gives best results.

Note: this value is only used, when dithering is actually performed.


getDitherBits

public float getDitherBits()

setDitherMode

public void setDitherMode(int mode)
Sets the mode for dithering. This can be one of:
  • DITHER_MODE_AUTOMATIC: it is decided automatically, whether dithering is necessary - in general when sample size is decreased.
  • DITHER_MODE_ON: dithering will be forced
  • DITHER_MODE_OFF: dithering will not be done.


getDitherMode

public int getDitherMode()