• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java STBVorbisInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Decoder

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public Decoder(String path, IntBuffer buffers){
	this.buffers = buffers;
	
	vorbis = ResourceLoader.getBytes(path);
	IntBuffer error = BufferUtils.createIntBuffer(1);
	handle = stb_vorbis_open_memory(vorbis, error, null);
	
	if(handle == 0L){
		throw new RuntimeException("Unable to open stb");
	}
	
	STBVorbisInfo info = STBVorbisInfo.malloc();
	stb_vorbis_get_info(handle, info);
	channels = info.channels();
	sampleRate = info.sample_rate();

	format = (channels == 1) ? AL10.AL_FORMAT_MONO16 : AL10.AL_FORMAT_STEREO16;
	
	lengthSamples = stb_vorbis_stream_length_in_samples(handle);
	lengthSeconds = stb_vorbis_stream_length_in_seconds(handle);
	
	pcm = BufferUtils.createShortBuffer(BUFFER_SIZE);
	
	samplesLeft = lengthSamples;
}
 
开发者ID:tek256,项目名称:LD38,代码行数:26,代码来源:Music.java


示例2: allocate

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
private void allocate(){
	ByteBuffer buffer = ResourceLoader.getBytes(path);
	IntBuffer error = BufferUtils.createIntBuffer(1);
	long decoder = stb_vorbis_open_memory(buffer, error, null);
	if(decoder == 0L){
		Application.error("Unable to open STB Vorbis");
		return;
	}
	
	STBVorbisInfo info = STBVorbisInfo.malloc();
	
	stb_vorbis_get_info(decoder, info);
	
	int channels = info.channels();
	int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
	ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples);
	pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
	stb_vorbis_close(decoder);
	
	AL10.alBufferData(id, info.channels() == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate());
}
 
开发者ID:tek256,项目名称:LD38,代码行数:22,代码来源:Sound.java


示例3: readVorbis

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
private ShortBuffer readVorbis(String resource, int bufferSize, STBVorbisInfo info) throws Exception {
    try (MemoryStack stack = MemoryStack.stackPush()) {
        vorbis = Utils.ioResourceToByteBuffer(resource, bufferSize);
        IntBuffer error = stack.mallocInt(1);
        long decoder = stb_vorbis_open_memory(vorbis, error, null);
        if (decoder == NULL) {
            throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));
        }

        stb_vorbis_get_info(decoder, info);

        int channels = info.channels();

        int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);

        pcm = MemoryUtil.memAllocShort(lengthSamples);

        pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
        stb_vorbis_close(decoder);

        return pcm;
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:24,代码来源:SoundBuffer.java


示例4: SoundBuffer

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public SoundBuffer(String file) throws Exception {
    this.bufferId = alGenBuffers();
    try (STBVorbisInfo info = STBVorbisInfo.malloc()) {
        ShortBuffer pcm = readVorbis(file, 32 * 1024, info);

        // Copy to buffer
        alBufferData(bufferId, info.channels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm,
                info.sample_rate());
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:11,代码来源:SoundBuffer.java


示例5: SoundBuffer

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public SoundBuffer(String file) throws Exception {
    this.bufferId = alGenBuffers();
    try (STBVorbisInfo info = STBVorbisInfo.malloc()) {
        ShortBuffer pcm = readVorbis(file, 32 * 1024, info);

        // Copy to buffer
        alBufferData(bufferId, info.channels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate());
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:10,代码来源:SoundBuffer.java


示例6: decodeToPCM

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
/**
 * This method reads in the OGG data, and convert it into PCM samples ready to be fed into the mouth of OpenAL
 * ALBuffer class.
 */
private void decodeToPCM(DirectBuffer input)
{
    // Create a memory representation to read from memory
    ByteBuffer memoryBuffer = (ByteBuffer) input.nativeBuffer();

    // Open the vorbis file to get stb_vorbis*
    IntBuffer error = BufferUtils.createIntBuffer(1);
    long handle = stb_vorbis_open_memory(memoryBuffer, error, null);

    if (handle == NULL)
        throw new SilenceException("Error " + error.get(0) + ": decoding the OGG data");

    // Get the information about the OGG header
    STBVorbisInfo info = STBVorbisInfo.malloc();
    stb_vorbis_get_info(handle, info);

    int channels = info.channels();
    sampleRate = info.sample_rate();

    format = channels == 1 ? ALFormat.MONO_16 : ALFormat.STEREO_16;

    // Read all the samples once for all
    int numSamples = stb_vorbis_stream_length_in_samples(handle);
    ByteBuffer pcm = BufferUtils.createByteBuffer(numSamples * Short.BYTES);
    stb_vorbis_get_samples_short_interleaved(handle, channels, pcm.asShortBuffer());

    // Convert the audio bytes and store the data buffer
    data = pcm;

    // Close the stb_vorbis* handle
    stb_vorbis_close(handle);
    info.free();
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:38,代码来源:OggReader.java


示例7: loadSound

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public static int loadSound(File file) {
	STBVorbisInfo info = STBVorbisInfo.malloc();
	ByteBuffer vorbis;
	try {
		vorbis = loadSoundToByteBuffer(file, (int) file.length());
	} catch (IOException e) {
		throw new RuntimeException(e);
	}

	IntBuffer error = BufferUtils.createIntBuffer(1);
	long decoder = stb_vorbis_open_memory(vorbis, error, null);
	if (decoder == NULL)
		throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));

	stb_vorbis_get_info(decoder, info);

	int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);

	ShortBuffer pcm = BufferUtils.createShortBuffer(info.channels() * lengthSamples);

	stb_vorbis_get_samples_short_interleaved(decoder, info.channels(), pcm);
	stb_vorbis_close(decoder);
	int buffer = alGenBuffers();
	alBufferData(buffer, info.channels() == 2 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, pcm,
			info.sample_rate());

	return buffer;
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:29,代码来源:SoundLoader.java


示例8: readVorbis

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public static ALBufferData readVorbis(Supplier<InputStream> resource) {
    try (STBVorbisInfo info = STBVorbisInfo.malloc()) {
        ByteBuffer vorbis;
        try {
            vorbis = LUtils.inputStreamToDirectByteBuffer(resource);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        IntBuffer error = BufferUtils.createIntBuffer(1);
        long decoder = stb_vorbis_open_memory(vorbis, error, null);
        if (decoder == MemoryUtil.NULL)
            throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));

        stb_vorbis_get_info(decoder, info);

        int channels = info.channels();

        int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);

        ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples);

        pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
        stb_vorbis_close(decoder);

        return ALBufferData.create(channels == 1 ? AL10.AL_FORMAT_MONO16 : AL10.AL_FORMAT_STEREO16, pcm,
                info.sample_rate());
    }
}
 
开发者ID:TechShroom,项目名称:EmergencyLanding,代码行数:30,代码来源:SoundUtil.java


示例9: loadOGGFormat

import org.lwjgl.stb.STBVorbisInfo; //导入依赖的package包/类
public void loadOGGFormat(){
    STBVorbisInfo info = STBVorbisInfo.malloc();
    ByteBuffer buff = BufferUtils.createByteBuffer(0);
    //lecture du fichier
    //----------------------------------------------------------------------------------------------------------------
    try {
        File file = new File(fileName);
        if ( file.isFile() ) {
            FileInputStream fis = new FileInputStream(file);
            FileChannel fc = fis.getChannel();
            buff = BufferUtils.createByteBuffer((int)fc.size() + 1);

            while ( fc.read(buff) != -1 ) ;

            fis.close();
            fc.close();
        } else {
            System.err.println("File not found !");
            return;
        }

        buff.flip();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    //----------------------------------------------------------------------------------------------------------------

    IntBuffer error = BufferUtils.createIntBuffer(1);
    long decoder = stb_vorbis_open_memory(buff, error, null);
    if ( decoder == NULL )
        throw new RuntimeException("Failed to open Ogg Vorbis file. Error: " + error.get(0));

    stb_vorbis_get_info(decoder, info);

    int channels = info.channels();

    stb_vorbis_seek_start(decoder);
    int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);

    ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples * channels);

    stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm);
    stb_vorbis_close(decoder);

    buffer = alGenBuffers();

    source = alGenSources();

    if(channels == 1)alBufferData(buffer, AL_FORMAT_MONO16, pcm, info.sample_rate());
    else alBufferData(buffer, AL_FORMAT_STEREO16, pcm, info.sample_rate());
}
 
开发者ID:mrdev023,项目名称:Global-Gam-Jam-2017,代码行数:52,代码来源:Audio.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLAggregateExpr类代码示例发布时间:2022-05-23
下一篇:
Java DistributedRowMatrix类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap