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

Java AudioData类代码示例

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

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



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

示例1: process

import com.jme3.audio.AudioData; //导入依赖的package包/类
@Override
@FXThread
protected void process() {
    super.process();

    final AudioTreeNode audioModelNode = (AudioTreeNode) getNode();
    final AudioNode audioNode = audioModelNode.getElement();

    final AssetManager assetManager = EDITOR.getAssetManager();

    EXECUTOR_MANAGER.addJMETask(() -> {

        final AudioKey audioKey = AudioNodeUtils.getAudioKey(audioNode);
        final AudioData audioData = assetManager.loadAudio(audioKey);

        AudioNodeUtils.updateData(audioNode, audioData, audioKey);

        audioNode.play();
    });
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:PlayAudioNodeAction.java


示例2: fillContextMenu

import com.jme3.audio.AudioData; //导入依赖的package包/类
@Override
public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) {
    if (!(nodeTree instanceof ModelNodeTree)) return;

    final AudioNode element = getElement();
    final AudioData audioData = element.getAudioData();
    final AudioSource.Status status = element.getStatus();

    if (audioData != null && status != AudioSource.Status.Playing) {
        items.add(new PlayAudioNodeAction(nodeTree, this));
    } else if (audioData != null) {
        items.add(new StopAudioNodeAction(nodeTree, this));
    }

    super.fillContextMenu(nodeTree, items);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:17,代码来源:AudioTreeNode.java


示例3: convertFormat

import com.jme3.audio.AudioData; //导入依赖的package包/类
private int convertFormat(AudioData ad){
    switch (ad.getBitsPerSample()){
        case 8:
            if (ad.getChannels() == 1)
                return AL_FORMAT_MONO8;
            else if (ad.getChannels() == 2)
                return AL_FORMAT_STEREO8;

            break;
        case 16:
            if (ad.getChannels() == 1)
                return AL_FORMAT_MONO16;
            else
                return AL_FORMAT_STEREO16;
    }
    throw new UnsupportedOperationException("Unsupported channels/bits combination: "+
                                            "bits="+ad.getBitsPerSample()+", channels="+ad.getChannels());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:LwjglAudioRenderer.java


示例4: load

import com.jme3.audio.AudioData; //导入依赖的package包/类
public Object load(AssetInfo info) throws IOException {
    if (!(info.getKey() instanceof AudioKey)){
        throw new IllegalArgumentException("Audio assets must be loaded using an AudioKey");
    }
    
    AudioKey key = (AudioKey) info.getKey();
    boolean readStream = key.isStream();
    boolean streamCache = key.useStreamCache();
    
    InputStream in = null;
    try {
        in = info.openStream();
        AudioData data = load(in, readStream, streamCache);
        if (data instanceof AudioStream){
            // audio streams must remain open
            in = null;
        }
        return data;
    } finally {
        if (in != null){
            in.close();
        }
    }
    
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:OGGLoader.java


示例5: load

import com.jme3.audio.AudioData; //导入依赖的package包/类
public Object load(AssetInfo info) throws IOException {
    AudioData data;
    InputStream inputStream = null;
    try {
        inputStream = info.openStream();
        data = load(inputStream, ((AudioKey)info.getKey()).isStream());
        if (data instanceof AudioStream){
            inputStream = null;
        }
        return data;
    } finally {
        if (inputStream != null){
            inputStream.close();
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:WAVLoader.java


示例6: loadImpl

import com.jme3.audio.AudioData; //导入依赖的package包/类
/**
 * Load the audio data.
 *
 * @param audioData the audio data.
 * @param audioKey  the audio key.
 */
@JMEThread
private void loadImpl(@NotNull final AudioData audioData, @NotNull final AudioKey audioKey) {
    removeAudioNode();
    setAudioData(audioData);
    setAudioKey(audioKey);

    final Node stateNode = getStateNode();

    final AudioNode audioNode = new AudioNode(audioData, audioKey);
    audioNode.setPositional(false);
    stateNode.attachChild(audioNode);

    setAudioNode(audioNode);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:21,代码来源:AudioViewer3DState.java


示例7: openFile

import com.jme3.audio.AudioData; //导入依赖的package包/类
@Override
@FXThread
public void openFile(@NotNull final Path file) {
    super.openFile(file);

    final Path assetFile = notNull(EditorUtil.getAssetFile(file));
    final String assetPath = EditorUtil.toAssetPath(assetFile);

    final AudioKey audioKey = new AudioKey(assetPath);
    final AssetManager assetManager = EDITOR.getAssetManager();
    final AudioData audioData = assetManager.loadAudio(audioKey);

    final float duration = audioData.getDuration();
    final int bitsPerSample = audioData.getBitsPerSample();
    final int channels = audioData.getChannels();
    final AudioData.DataType dataType = audioData.getDataType();
    final int sampleRate = audioData.getSampleRate();

    final AudioViewer3DState editorAppState = getEditorAppState();
    editorAppState.load(audioData, audioKey);

    getChannelsField().setText(String.valueOf(channels));
    getDurationField().setText(String.valueOf(duration));
    getDataTypeField().setText(String.valueOf(dataType));
    getSampleRateField().setText(String.valueOf(sampleRate));
    getBitsPerSampleField().setText(String.valueOf(bitsPerSample));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:AudioViewerEditor.java


示例8: updateData

import com.jme3.audio.AudioData; //导入依赖的package包/类
/**
 * Update audio data for an audio node.
 *
 * @param audioNode the audio node.
 * @param audioData the audio data.
 * @param audioKey  the audio key.
 */
@JMEThread
public static void updateData(@NotNull final AudioNode audioNode, @Nullable final AudioData audioData,
                              @Nullable final AudioKey audioKey) {
    try {
        AUDIO_DATA_FIELD.set(audioNode, audioData);
        AUDIO_KEY_FIELD.set(audioNode, audioKey);
    } catch (final IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:18,代码来源:AudioNodeUtils.java


示例9: main

import com.jme3.audio.AudioData; //导入依赖的package包/类
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLoader(AWTLoader.class.getName(), "png");
    am.registerLoader(WAVLoader.class.getName(), "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class.getName());

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.png");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.png");

    System.out.println("Success!");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:TestAbsoluteLocators.java


示例10: attachAudioToSource

import com.jme3.audio.AudioData; //导入依赖的package包/类
private boolean attachAudioToSource(int sourceId, AudioData data){
    if (data instanceof AudioBuffer){
        return attachBufferToSource(sourceId, (AudioBuffer) data);
    }else if (data instanceof AudioStream){
        return attachStreamToSource(sourceId, (AudioStream) data);
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:9,代码来源:LwjglAudioRenderer.java


示例11: playSource

import com.jme3.audio.AudioData; //导入依赖的package包/类
public void playSource(AudioNode src) {
    checkDead();
    synchronized (threadLock){
        while (!threadLock.get()){
            try {
                threadLock.wait();
            } catch (InterruptedException ex) {
            }
        }
        if (audioDisabled)
            return;

        //assert src.getStatus() == Status.Stopped || src.getChannel() == -1;

        if (src.getStatus() == Status.Playing){
            return;
        }else if (src.getStatus() == Status.Stopped){

            // allocate channel to this source
            int index = newChannel();
            if (index == -1) {
                logger.log(Level.WARNING, "No channel available to play {0}", src);
                return;
            }
            clearChannel(index);
            src.setChannel(index);

            AudioData data = src.getAudioData();
            if (data.isUpdateNeeded())
                updateAudioData(data);

            chanSrcs[index] = src;
            setSourceParams(channels[index], src, false);
            attachAudioToSource(channels[index], data);
        }

        alSourcePlay(channels[src.getChannel()]);
        src.setStatus(Status.Playing);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:41,代码来源:LwjglAudioRenderer.java


示例12: updateAudioData

import com.jme3.audio.AudioData; //导入依赖的package包/类
private void updateAudioData(AudioData ad){
    if (ad instanceof AudioBuffer){
        updateAudioBuffer((AudioBuffer) ad);
    }else if (ad instanceof AudioStream){
        updateAudioStream((AudioStream) ad);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:LwjglAudioRenderer.java


示例13: deleteAudioData

import com.jme3.audio.AudioData; //导入依赖的package包/类
public void deleteAudioData(AudioData ad){
    synchronized (threadLock){
        while (!threadLock.get()){
            try {
                threadLock.wait();
            } catch (InterruptedException ex) {
            }
        }
        if (audioDisabled)
            return;
    
        if (ad instanceof AudioBuffer){
            AudioBuffer ab = (AudioBuffer) ad;
            int id = ab.getId();
            if (id != -1){
                ib.put(0,id);
                ib.position(0).limit(1);
                alDeleteBuffers(ib);
                ab.resetObject();
            }
        }else if (ad instanceof AudioStream){
            AudioStream as = (AudioStream) ad;
            int[] ids = as.getIds();
            if (ids != null){
                ib.clear();
                ib.put(ids).flip();
                alDeleteBuffers(ib);
                as.resetObject();
            }
        }
    }            
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:LwjglAudioRenderer.java


示例14: loadAudio

import com.jme3.audio.AudioData; //导入依赖的package包/类
private AudioNode loadAudio() {
        if (data.getSoundFile() == null) {
            return null;
        }
        
        AudioNode an = new AudioNode(LuoYing.getAssetManager(), data.getSoundFile(), AudioData.DataType.Buffer);
        an.setVolume(data.getVolume());
        an.setTimeOffset(data.getTimeOffset());
        an.setLooping(data.isLooping());
        an.setDirection(data.getDirection());
        an.setDirectional(data.isDirectional());
        an.setInnerAngle(data.getInnerAngle());
        an.setMaxDistance(data.getMaxDistance());
        an.setOuterAngle(data.getOuterAngle());
        an.setPitch(data.getPitch());
        
        // 容易java.lang.IllegalStateException: Only mono audio is supported for positional audio nodes
        an.setPositional(data.isPositional());
        
        an.setRefDistance(data.getRefDistance());
        an.setReverbEnabled(data.isReverbEnabled());
        an.setVelocity(data.getVelocity());
        an.setVelocityFromTranslation(data.isVelocityFromTranslation());
        
//        audio.setDryFilter(); // 暂不支持。
//        audio.setReverbFilter();
        return an;
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:29,代码来源:Sound.java


示例15: deleteAudioData

import com.jme3.audio.AudioData; //导入依赖的package包/类
@Override
public void deleteAudioData(AudioData ad) {
    if (ad instanceof AndroidAudioData) {
        AndroidAudioData audioData = (AndroidAudioData) ad;
        if (audioData.getAssetKey() instanceof AudioKey) {
            AudioKey assetKey = (AudioKey) audioData.getAssetKey();
            if (assetKey.isStream()) {
                for (AudioNode src : musicPlaying.keySet()) {
                    if (src.getAudioData() == ad) {
                        MediaPlayer mp = musicPlaying.get(src);
                        mp.stop();
                        mp.release();
                        musicPlaying.remove(src);
                        src.setStatus(Status.Stopped);
                        src.setChannel(-1);
                        break;
                    }
                }
            } else {
                if (audioData.getId() > 0) {
                    soundPool.unload(audioData.getId());
                }
                audioData.setId(0);
            }

        }
    } else {
        throw new IllegalArgumentException("AudioData is not of type AndroidAudioData in deleteAudioData");
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:31,代码来源:AndroidAudioRenderer.java


示例16: main

import com.jme3.audio.AudioData; //导入依赖的package包/类
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLoader(AWTLoader.class.getName(), "jpg");
    am.registerLoader(WAVLoader.class.getName(), "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class.getName());

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.jpg");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.jpg");

    System.out.println("Success!");
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:28,代码来源:TestAbsoluteLocators.java


示例17: getPlaceholderAudio

import com.jme3.audio.AudioData; //导入依赖的package包/类
public static AudioData getPlaceholderAudio(){
    AudioBuffer audioBuf = new AudioBuffer();
    audioBuf.setupFormat(1, 8, 44100);
    ByteBuffer bb = BufferUtils.createByteBuffer(1);
    bb.put((byte)0).flip();
    audioBuf.updateData(bb);
    return audioBuf;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:9,代码来源:PlaceholderAssets.java


示例18: getAudioData

import com.jme3.audio.AudioData; //导入依赖的package包/类
/**
 * @return the audio data.
 */
@JMEThread
private @NotNull AudioData getAudioData() {
    return notNull(audioData);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioViewer3DState.java


示例19: setAudioData

import com.jme3.audio.AudioData; //导入依赖的package包/类
/**
 * @param audioData the audio data.
 */
@JMEThread
private void setAudioData(@NotNull final AudioData audioData) {
    this.audioData = audioData;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:8,代码来源:AudioViewer3DState.java


示例20: loadAudio

import com.jme3.audio.AudioData; //导入依赖的package包/类
public AudioData loadAudio(AudioKey key){
    return (AudioData) loadAsset(key);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:DesktopAssetManager.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java StoryControls类代码示例发布时间:2022-05-23
下一篇:
Java ModelerException类代码示例发布时间: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