当前位置: 首页>>代码示例>>Java>>正文


Java SampleBuffer类代码示例

本文整理汇总了Java中javazoom.jl.decoder.SampleBuffer的典型用法代码示例。如果您正苦于以下问题:Java SampleBuffer类的具体用法?Java SampleBuffer怎么用?Java SampleBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SampleBuffer类属于javazoom.jl.decoder包,在下文中一共展示了SampleBuffer类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decode

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
@Override
public void decode(SWFInputStream sis, OutputStream os) throws IOException {
    byte[] data = sis.readBytesEx(sis.available(), "soundStream");
    inputStream.add(data);

    SampleBuffer buf;
    while ((buf = readFrame(decoder, bitStream)) != null) {
        short[] audio = buf.getBuffer();
        byte[] d = new byte[buf.getBufferLength() * 2];
        for (int i = 0; i < buf.getBufferLength(); i++) {
            int s = audio[i];
            d[i * 2] = (byte) (s & 0xff);
            d[i * 2 + 1] = (byte) ((s >> 8) & 0xff);
        }
        os.write(d);
    }
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:18,代码来源:MP3Decoder.java

示例2: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
/**
 * Decodes a single frame.
 *
 * @return true if there are no more frames to decode, false otherwise.
 */
protected boolean decodeFrame() throws JavaLayerException
{
	try
	{
		AudioDevice out = audio;
		if (out == null) return false;

		Header h = bitstream.readFrame();
		if (h == null) return false;

		// sample buffer set when decoder constructed
		SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);

		synchronized (this)
		{
			out = audio;
			if(out != null)
			{
				out.write(output.getBuffer(), 0, output.getBufferLength());
			}
		}

		bitstream.closeFrame();
	}
	catch (RuntimeException ex)
	{
		throw new JavaLayerException("Exception decoding audio frame", ex);
	}
	return true;
}
 
开发者ID:EndlessBot,项目名称:jLib,代码行数:36,代码来源:AdvancedPlayer.java

示例3: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
/**
 * Decodes a single frame.
 * 
 * @return true if there are no more frames to decode, false otherwise.
 */
protected boolean decodeFrame() throws JavaLayerException {
	try {
		AudioDevice out = audio;
		if (out == null)
			return false;

		Header h = bitstream.readFrame();
		if (h == null)
			return false;

		// sample buffer set when decoder constructed
		SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);

		synchronized (this) {
			out = audio;
			if (out != null) {
				out.write(output.getBuffer(), 0, output.getBufferLength());
			}
		}

		bitstream.closeFrame();
	} catch (RuntimeException ex) {
		throw new JavaLayerException("Exception decoding audio frame", ex);
	}
	return true;
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:32,代码来源:AdvancedPlayer.java

示例4: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
/**
 * Decodes a single frame.
 *
 * @return true if there are no more frames to decode, false otherwise.
 */
protected boolean decodeFrame() throws JavaLayerException {
    try {
        AudioDevice out = audio;
        if (out == null) {
            return false;
        }

        Header h = bitstream.readFrame();
        if (h == null) {
            return false;
        }

        // sample buffer set when decoder constructed
        SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);

        synchronized (this) {
            out = audio;
            if (out != null) {
                out.write(output.getBuffer(), 0, output.getBufferLength());
            }
        }

        bitstream.closeFrame();
    } catch (RuntimeException ex) {
        throw new JavaLayerException("Exception decoding audio frame", ex);
    }
    return true;
}
 
开发者ID:BlkStormy,项目名称:epic-inventor,代码行数:34,代码来源:AdvancedPlayer.java

示例5: decode

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
@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();
}
 
开发者ID:dueros,项目名称:dcs-sdk-java,代码行数:42,代码来源:JLayerDecoderImpl.java

示例6: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
/**
	 * Decodes a single frame.
	 * 
	 * @return true if there are no more frames to decode, false otherwise.
	 */
	protected boolean decodeFrame() throws JavaLayerException
	{		
		try
		{
			AudioDevice out = audio;
			if (out==null)
				return false;

			Header h = bitstream.readFrame();	
			
			if (h==null)
				return false;
				
			// sample buffer set when decoder constructed
			SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream);
																																					
			synchronized (this)
			{
				out = audio;
				if (out!=null)
				{					
					out.write(output.getBuffer(), 0, output.getBufferLength());
				}				
			}
																			
			bitstream.closeFrame();
		}		
		catch (RuntimeException ex)
		{
			throw new JavaLayerException("Exception decoding audio frame", ex);
		}
/*
		catch (IOException ex)
		{
			System.out.println("exception decoding audio frame: "+ex);
			return false;	
		}
		catch (BitstreamException bitex)
		{
			System.out.println("exception decoding audio frame: "+bitex);
			return false;	
		}
		catch (DecoderException decex)
		{
			System.out.println("exception decoding audio frame: "+decex);
			return false;				
		}
*/		
		return true;
	}
 
开发者ID:EndlessBot,项目名称:jLib,代码行数:56,代码来源:Player.java

示例7: getSamples

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
public SampleBuffer getSamples() {
    return samples;
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:4,代码来源:MP3FRAME.java

示例8: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
/**
 * Decodes a single frame.
 * 
 * @return true if there are no more frames to decode, false otherwise.
 */
protected boolean decodeFrame() throws JavaLayerException
{
	try
	{
		AudioDevice out = audio;
		if (out == null)
			return false;

		Header h = bitstream.readFrame();

		if (h == null)
			return false;

		// sample buffer set when decoder constructed
		SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);

		synchronized (this)
		{
			out = audio;
			if (out != null)
			{
				out.write(output.getBuffer(), 0, output.getBufferLength());
			}
		}

		bitstream.closeFrame();
	} catch (RuntimeException ex)
	{
		throw new JavaLayerException("Exception decoding audio frame", ex);
	}
	/*
			catch (IOException ex)
			{
				System.out.println("exception decoding audio frame: "+ex);
				return false;	
			}
			catch (BitstreamException bitex)
			{
				System.out.println("exception decoding audio frame: "+bitex);
				return false;	
			}
			catch (DecoderException decex)
			{
				System.out.println("exception decoding audio frame: "+decex);
				return false;				
			}
	*/
	return true;
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:55,代码来源:Player.java

示例9: decodeFrame

import javazoom.jl.decoder.SampleBuffer; //导入依赖的package包/类
protected boolean decodeFrame() throws JavaLayerException {
	boolean returnValue = false;
	if (this.stopped) { // nothing for decode
		return false;
	}

	/*
	 * Fix NullPointer
	 */
	
	if(bitstream == null)
		throw new JavaLayerException("Could not open Stream");
	
	try {
		if (this.audioDevice != null) {
			Header header = this.bitstream.readFrame();
			if (header != null) {
				// sample buffer set when decoder constructed
				SampleBuffer output = (SampleBuffer) this.decoder
						.decodeFrame(header, this.bitstream);

				synchronized (this) {
					if (this.audioDevice != null) {
						this.audioDevice.write(output.getBuffer(), 0,
								output.getBufferLength());
					}
				}

				this.bitstream.closeFrame();
				if (listener != null)
					listener.frameDecoded(new PlaybackEvent(this, PlaybackEvent.EventType.FrameDecoded, audioDevice.getPosition()));
				returnValue = true;
			} else {
				System.out.println("End of file"); // end of file
				returnValue = false;
			}
		}
	} catch (RuntimeException ex) {
		throw new JavaLayerException("Exception decoding audio frame", ex);
	}
	return returnValue;
}
 
开发者ID:git-commit,项目名称:radio-activity,代码行数:43,代码来源:JLayerPlayerPausable.java


注:本文中的javazoom.jl.decoder.SampleBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。