javazoom.jl.decoder.Decoder Java Examples

The following examples show how to use javazoom.jl.decoder.Decoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Player.java    From jclic with GNU General Public License v2.0 6 votes vote down vote up
public Player(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);		
	decoder = new Decoder();
			
	if (device!=null)
	{		
		audio = device;
	}
	else
	{			
		FactoryRegistry r = FactoryRegistry.systemRegistry();
		audio = r.createAudioDevice();
	}
	audio.open(decoder);
}
 
Example #2
Source File: Player.java    From epic-inventor with GNU General Public License v2.0 6 votes vote down vote up
public Player(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);		
	decoder = new Decoder();
			
	if (device!=null)
	{		
		audio = device;
	}
	else
	{			
		FactoryRegistry r = FactoryRegistry.systemRegistry();
		audio = r.createAudioDevice();
	}
	audio.open(decoder);
}
 
Example #3
Source File: MP3SOUNDDATA.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public MP3SOUNDDATA(SWFInputStream sis, boolean raw) throws IOException {
    if (!raw) {
        seekSamples = sis.readSI16("seekSamples");
    }
    frames = new ArrayList<>();
    MP3FRAME f;
    Decoder decoder = new Decoder();
    Bitstream bitstream = new Bitstream(new ByteArrayInputStream(sis.readBytesEx(sis.available(), "soundStream")));
    while ((f = MP3FRAME.readFrame(bitstream, decoder)) != null) {
        frames.add(f);
    }
}
 
Example #4
Source File: Converter.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
public void convert(String sourceName, String destName,
	ProgressListener progressListener, Decoder.Params decoderParams)
	throws JavaLayerException
{
	if (destName.length()==0)
		destName = null;
	try {
		InputStream in = openInput(sourceName);
		convert(in, destName, progressListener, decoderParams);
		in.close();
	} catch(IOException ioe) {
		throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
	}
}
 
Example #5
Source File: AudioDeviceBase.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Opens this audio device. 
 * 
 * @param decoder	The decoder that will provide audio data
 *					to this audio device. 
 */
public synchronized void open(Decoder decoder) throws JavaLayerException
{
	if (!isOpen())
	{
		this.decoder = decoder;
		openImpl();
		setOpen(true);
	}
}
 
Example #6
Source File: AdvancedPlayer.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);

	if (device!=null) audio = device;
	else audio = FactoryRegistry.systemRegistry().createAudioDevice();
	audio.open(decoder = new Decoder());
}
 
Example #7
Source File: Converter.java    From epic-inventor with GNU General Public License v2.0 5 votes vote down vote up
public void convert(String sourceName, String destName,
	ProgressListener progressListener, Decoder.Params decoderParams)
	throws JavaLayerException
{
	if (destName.length()==0)
		destName = null;
	try {
		InputStream in = openInput(sourceName);
		convert(in, destName, progressListener, decoderParams);
		in.close();
	} catch(IOException ioe) {
		throw new JavaLayerException(ioe.getLocalizedMessage(), ioe);
	}
}
 
Example #8
Source File: AudioDeviceBase.java    From epic-inventor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Opens this audio device. 
 * 
 * @param decoder	The decoder that will provide audio data
 *					to this audio device. 
 */
public synchronized void open(Decoder decoder) throws JavaLayerException
{
	if (!isOpen())
	{
		this.decoder = decoder;
		openImpl();
		setOpen(true);
	}
}
 
Example #9
Source File: AdvancedPlayer.java    From epic-inventor with GNU General Public License v2.0 5 votes vote down vote up
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException {
    bitstream = new Bitstream(stream);

    if (device != null) {
        audio = device;
    } else {
        audio = FactoryRegistry.systemRegistry().createAudioDevice();
    }
    audio.open(decoder = new Decoder());
}
 
Example #10
Source File: JLayerDecoderImpl.java    From dcs-sdk-java with Apache License 2.0 4 votes vote down vote up
@Override
public void decode(InputStream inputStream) throws Exception {
    Decoder decoder = new Decoder();
    Bitstream bitstream = new Bitstream(inputStream);
    Header header;
    isStopRead = false;
    isGetMp3InfoFinished = false;
    int count = 0;
    while (!isStopRead && (header = bitstream.readFrame()) != null) {
        isDecoding = true;
        long start = System.currentTimeMillis();
        SampleBuffer sampleBuffer = (SampleBuffer) decoder.decodeFrame(header, bitstream);
        // 获取采样率等
        if (!isGetMp3InfoFinished) {
            fireOnDecodeInfo(sampleBuffer.getSampleFrequency(), sampleBuffer.getChannelCount());
            isGetMp3InfoFinished = true;
        }
        short[] buffer = sampleBuffer.getBuffer();
        byte[] pcm = new byte[buffer.length / 2];
        for (int i = 0; i < buffer.length / 2 / 2; i++) {
            int j = i * 2;
            pcm[j] = (byte) (buffer[i] & 0xff);
            pcm[j + 1] = (byte) ((buffer[i] >> 8) & 0xff);
        }
        if (count == 0 || count == 1) {
            byte[] newPcm = avoidNullPcm(pcm);
            if (newPcm != null) {
                fireOnDecodePcm(newPcm);
            }
        } else {
            fireOnDecodePcm(pcm);
        }
        count++;
        bitstream.closeFrame();
        long end = System.currentTimeMillis();
        Log.i(TAG, "after decode pcm.length:" + pcm.length + "," + (end - start));
    }
    isDecoding = false;
    fireOnDecodeFinished();
    inputStream.close();
}
 
Example #11
Source File: AudioDeviceBase.java    From jclic with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieves the decoder that provides audio data to this
 * audio device.
 * 
 * @return The associated decoder. 
 */
protected Decoder getDecoder()
{
	return decoder;	
}
 
Example #12
Source File: AudioDevice.java    From jclic with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Prepares the AudioDevice for playback of audio samples. 
 * @param decoder	The decoder that will be providing the audio
 *					samples. 
 * 
 * If the audio device is already open, this method returns silently. 
 * 
 */
public void open(Decoder decoder) throws JavaLayerException;
 
Example #13
Source File: AudioDeviceBase.java    From epic-inventor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieves the decoder that provides audio data to this
 * audio device.
 * 
 * @return The associated decoder. 
 */
protected Decoder getDecoder()
{
	return decoder;	
}
 
Example #14
Source File: AudioDevice.java    From epic-inventor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Prepares the AudioDevice for playback of audio samples. 
 * @param decoder	The decoder that will be providing the audio
 *					samples. 
 * 
 * If the audio device is already open, this method returns silently. 
 * 
 */
public void open(Decoder decoder) throws JavaLayerException;