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


Java Bitstream类代码示例

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


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

示例1: Player

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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);
}
 
开发者ID:EndlessBot,项目名称:jLib,代码行数:17,代码来源:Player.java

示例2: Music

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
public Music (OpenALAudio audio, FileHandle file) {
	super(audio, file);
	if (audio.noDevice) return;
	bitstream = new Bitstream(file.read());
	decoder = new MP3Decoder();
	bufferOverhead = 4096;
	try {
		Header header = bitstream.readFrame();
		if (header == null) throw new GdxRuntimeException("Empty MP3");
		int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
		outputBuffer = new OutputBuffer(channels, false);
		decoder.setOutputBuffer(outputBuffer);
		setup(channels, header.getSampleRate());
	} catch (BitstreamException e) {
		throw new GdxRuntimeException("error while preloading mp3", e);
	}
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:18,代码来源:Mp3.java

示例3: Music

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
public Music(OpenALAudio audio, FileHandle file) {
    super(audio, file);
    if (audio.noDevice) {
        return;
    }
    bitstream = new Bitstream(file.read());
    decoder = new MP3Decoder();
    try {
        Header header = bitstream.readFrame();
        if (header == null) {
            throw new GdxRuntimeException("empty ogg");
        }
        int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
        outputBuffer = new OutputBuffer(channels, false);
        decoder.setOutputBuffer(outputBuffer);
        setup(channels, header.getSampleRate());
    } catch (BitstreamException e) {
        throw new GdxRuntimeException("error while preloading mp3", e);
    }
}
 
开发者ID:kovertopz,项目名称:libGDX-LWJGL-Audio,代码行数:21,代码来源:Mp3.java

示例4: Player

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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);
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:17,代码来源:Player.java

示例5: AdvancedPlayer

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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());
}
 
开发者ID:EndlessBot,项目名称:jLib,代码行数:9,代码来源:AdvancedPlayer.java

示例6: MP3SOUNDDATA

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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);
    }
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:13,代码来源:MP3SOUNDDATA.java

示例7: AdvancedPlayer

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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());
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:10,代码来源:AdvancedPlayer.java

示例8: AdvancedPlayer

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
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());
}
 
开发者ID:BlkStormy,项目名称:epic-inventor,代码行数:11,代码来源:AdvancedPlayer.java

示例9: decode

import javazoom.jl.decoder.Bitstream; //导入依赖的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

示例10: initialize

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
@Override
public boolean initialize(URL url)
{
	initialized(SET, false);
	cleanup();
	if(url == null)
	{
		errorMessage("url null in method 'initialize'");
		cleanup();
		return false;
	}

	try
	{
		bitstream = new Bitstream(new BufferedInputStream(url.openStream()));
		decoder = new Decoder();

		mainHeader = bitstream.readFrame();

		buffer = new DMAISObuffer(2);
		decoder.setOutputBuffer(buffer);

		int channels;
		if(mainHeader.mode() < 3)
			channels = 2;
		else channels = 1;

		bitstream.closeFrame();
		bitstream.close();

		myAudioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
				mainHeader.frequency(), 16, channels, channels * 2, mainHeader.frequency(),
				false);

		AudioFormat mpegAudioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, -1.0f,
				16, channels, channels * 2, -1.0f, false);

		myAudioInputStream = new DecodedMpegAudioInputStream(myAudioFormat,
				new AudioInputStream(new BufferedInputStream(url.openStream()),
						mpegAudioFormat, -1));
	} catch (Exception e)
	{
		errorMessage("Unable to set up input streams in method " + "'initialize'");
		printStackTrace(e);
		cleanup();
		return false;
	}

	if(myAudioInputStream == null)
	{
		errorMessage("Unable to set up audio input stream in method " + "'initialize'");
		cleanup();
		return false;
	}

	endOfStream(SET, false);
	initialized(SET, true);
	return true;
}
 
开发者ID:Dynious,项目名称:SoundsCool,代码行数:60,代码来源:CodecJLayerMP3.java

示例11: decode

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
@Override
public AudioInputStream decode(File inputFile) throws UnsupportedAudioFileException, IOException {

  MpegAudioFileReader mafr = new MpegAudioFileReader();
  AudioInputStream mp3Ais;
  // AudioInputStream mp3Dmais = null;
  AudioInputStream result;

  try {
    mp3Ais = mafr.getAudioInputStream(inputFile);
  } catch (Exception e) {

    /*
     * This is now a work around (aka hack) for files with stored images in them. The images have to be removed. We load the file as FileInputStream, check
     * the length of the header and skip it.
     */
    FileInputStream f_in = new FileInputStream(inputFile);
    Bitstream m = new Bitstream(f_in);
    long start = m.header_pos();

    try {
      m.close();
    } catch (BitstreamException be) {
      // nop
    }

    f_in = new FileInputStream(inputFile);

    // Skip the header
    f_in.skip(start);

    // Now try again with the 'truncated' sound stream
    mp3Ais = mafr.getAudioInputStream(f_in);
  }

  AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, mp3Ais.getFormat().getSampleRate(), 16, mp3Ais.getFormat().getChannels(),
      mp3Ais.getFormat().getChannels() * 2, mp3Ais.getFormat().getSampleRate(), false);

  result = new DecodedMpegAudioInputStream(decodedFormat, mp3Ais);

  // result = new PCMtoPCMCodec().getAudioInputStream(TARGET_ENCODING, mp3Dmais);
  // result = new MpegFormatConversionProvider().getAudioInputStream(TARGET_ENCODING, mp3Dmais);
  // result = AudioSystem.getAudioInputStream(TARGET_ENCODING, mp3Dmais);

  return tidyStream(result);
}
 
开发者ID:nwaldispuehl,项目名称:interval-music-compositor,代码行数:47,代码来源:Mp3AudioFileDecoder.java

示例12: play

import javazoom.jl.decoder.Bitstream; //导入依赖的package包/类
public boolean play(int frameIndexStart, int frameIndexFinal,
		int correctionFactorInFrames) throws JavaLayerException {
	try {
		this.bitstream = new Bitstream(this.getAudioInputStream());
	} catch (IOException e) {
		e.printStackTrace();
	}
	this.audioDevice = FactoryRegistry.systemRegistry().createAudioDevice();
	this.decoder = new Decoder();
	this.audioDevice.open(this.decoder);

	boolean shouldContinueReadingFrames = true;

	this.paused = false;
	this.stopped = false;
	this.frameIndexCurrent = 0;

	while (shouldContinueReadingFrames == true
			&& this.frameIndexCurrent < frameIndexStart
					- correctionFactorInFrames) {
		shouldContinueReadingFrames = this.skipFrame();
		this.frameIndexCurrent++;
	}

	if (this.listener != null) {
		this.listener.playbackStarted(new PlaybackEvent(this,
				PlaybackEvent.EventType.Started, this.audioDevice
						.getPosition()));
	}

	if (frameIndexFinal < 0) {
		frameIndexFinal = Integer.MAX_VALUE;
	}

	while (shouldContinueReadingFrames == true
			&& this.frameIndexCurrent < frameIndexFinal) {
		if (this.paused || this.stopped) {
			shouldContinueReadingFrames = false;
			try {
				Thread.sleep(1);
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		} else {
			shouldContinueReadingFrames = this.decodeFrame();
			this.frameIndexCurrent++;
		}
	}

	// last frame, ensure all data flushed to the audio device.
	if (this.audioDevice != null && !this.paused) {
		this.audioDevice.flush();

		synchronized (this) {
			this.complete = (this.closed == false);
			this.close();
		}

		// report to listener
		if (this.listener != null) {
			int audioDevicePosition = -1;
			if (this.audioDevice != null) {
				audioDevicePosition = this.audioDevice.getPosition();
			} else {
				// throw new
				// NullPointerException("attribute audioDevice in " +
				// this.getClass() + " is NULL");
			}
			PlaybackEvent playbackEvent = new PlaybackEvent(this,
					PlaybackEvent.EventType.Stopped,
					audioDevicePosition);
			this.listener.playbackFinished(playbackEvent);
		}
	}

	return shouldContinueReadingFrames;
}
 
开发者ID:git-commit,项目名称:radio-activity,代码行数:78,代码来源:JLayerPlayerPausable.java


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