ch.aplu.util
Interface SoundConverter


public interface SoundConverter

Interface for easy integration of a sound converter to SoundPlayer and SoundPlayerExt classes. Typically a converter may apply some sort of 'filtering', e.g. change the pitch with same tempo or change the tempo with same pitch. The sound is converted by data junks. putSamples() feeds the converter with a new data junk. receiveSamples() returns the converted samples. Because there may be same convertion delay, receiveSamples() may return none, a part or all converted samples of data previously sent to the converter. If the number of available bytes exceeds 'maxBytes', receiveSamples() is called several times until all data is retrieved. The input and output format to the converter must have PCM_SIGNED mono or stereo format (16 bit little endian).


Method Summary
 void cleanup()
          Callback method called when no more data is available before closing SoundPlayer's output to the sound device.
 void putSamples(byte[] inBuffer, int numBytes)
          Adds given number of bytes from the given buffer into the input of the converter.
 int receiveSamples(byte[] outBuffer, int maxBytes)
          Retrieves converted samples from the converted.
 void update()
          Callback method called each time before the new samples from the inBuffer are fed into the converter.
 

Method Detail

putSamples

void putSamples(byte[] inBuffer,
                int numBytes)
Adds given number of bytes from the given buffer into the input of the converter. If mono, nbBytes must be multiple of 2 (2 bytes per sample). If stereo, nbBytes must be multiple of 4 (4 bytes per sample).


receiveSamples

int receiveSamples(byte[] outBuffer,
                   int maxBytes)
Retrieves converted samples from the converted. Copies up to maxBytes bytes to outBuffer and removes them from the sample buffer. If there are less than maxBytes in the buffer, returns all that available. Return number of bytes copied in outBuffer. If mono, maxBytes must be multiple of 2 (2 bytes per sample) If stereo, maxBytes must be multiple of 4 (4 bytes per sample)


update

void update()
Callback method called each time before the new samples from the inBuffer are fed into the converter. May be used to change converter parameters in realtime.


cleanup

void cleanup()
Callback method called when no more data is available before closing SoundPlayer's output to the sound device. May be used to flush the sound converter's buffer. Remaining sound data is sent to the sound device and the device is closed.