Example usage for javax.sound.sampled SourceDataLine getFormat

List of usage examples for javax.sound.sampled SourceDataLine getFormat

Introduction

In this page you can find the example usage for javax.sound.sampled SourceDataLine getFormat.

Prototype

AudioFormat getFormat();

Source Link

Document

Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.

Usage

From source file:javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer.java

/**
 * Setup DSP./* w ww  . j a v  a 2 s . c o m*/
 * @param line
 */
public void setupDSP(SourceDataLine line) {
    if (dsp != null) {
        int channels = line.getFormat().getChannels();
        if (channels == 1)
            dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_MONO);
        else
            dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_STEREO);
        int bits = line.getFormat().getSampleSizeInBits();
        if (bits == 8)
            dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_EIGHT_BIT);
        else
            dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_SIXTEEN_BIT);
    }
}