public AudioData loadAudio(String name){ return loadAudio(new AudioKey(name, false)); }
@Override public Object load(AssetInfo assetInfo) throws IOException { AudioKey key = (AudioKey) assetInfo.getKey(); if (!(assetInfo instanceof AndroidLocator.AndroidAssetInfo)) { throw new UnsupportedOperationException("Cannot load audio files from classpath." + "Place your audio files in " + "Android's assets directory"); } if (key.isStream()) { return loadStream(assetInfo); } else { return loadBuffer(assetInfo); } } }
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 (readStream && !streamCache) { // we still need the stream in this case .. in = null; } return data; } finally { if (in != null){ in.close(); } } }
/** * Creates a new <code>AudioNode</code> with the given audio file. * * @param assetManager The asset manager to use to load the audio file * @param name The filename of the audio file * @param stream If true, the audio will be streamed gradually from disk, * otherwise, it will be buffered. * @param streamCache If stream is also true, then this specifies if * the stream cache is used. When enabled, the audio stream will * be read entirely but not decoded, allowing features such as * seeking, looping and determining duration. * * @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead */ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) { this.audioKey = new AudioKey(name, stream, streamCache); this.data = (AudioData) assetManager.loadAsset(audioKey); }
public Object load(AssetInfo info) throws IOException { AudioData data; InputStream inputStream = null; try { inputStream = info.openStream(); data = load(info, inputStream, ((AudioKey)info.getKey()).isStream()); if (data instanceof AudioStream){ inputStream = null; } return data; } finally { if (inputStream != null){ inputStream.close(); } } } }
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(); } } }
AudioKey key = new AudioKey(selected.getName(), true, true); try{ musicData = (AudioData) loader.load(new AssetInfo(null, key) {
public Object load(AssetInfo info) throws IOException { AudioData data; InputStream inputStream = null; try { inputStream = info.openStream(); data = load(info, inputStream, ((AudioKey)info.getKey()).isStream()); if (data instanceof AudioStream){ inputStream = null; } return data; } finally { if (inputStream != null){ inputStream.close(); } } } }
public AudioData loadAudio(String name){ return loadAudio(new AudioKey(name, false)); }
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(); } } } }
public AudioData loadAudio(String name){ return loadAudio(new AudioKey(name, false)); }
@Override 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; } catch (Exception e) { return new AudioBuffer(); // Failed } finally { if (inputStream != null) { inputStream.close(); } } } }
/** * Creates a new <code>AudioNode</code> with the given audio file. * * @param assetManager The asset manager to use to load the audio file * @param name The filename of the audio file * @param stream If true, the audio will be streamed gradually from disk, * otherwise, it will be buffered. * @param streamCache If stream is also true, then this specifies if * the stream cache is used. When enabled, the audio stream will * be read entirely but not decoded, allowing features such as * seeking, looping and determining duration. */ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) { this.audioKey = new AudioKey(name, stream, streamCache); this.data = (AudioData) assetManager.loadAsset(audioKey); }
/** * Creates a new <code>AudioNode</code> with the given audio file. * * @param assetManager The asset manager to use to load the audio file * @param name The filename of the audio file * @param stream If true, the audio will be streamed gradually from disk, * otherwise, it will be buffered. * @param streamCache If stream is also true, then this specifies if * the stream cache is used. When enabled, the audio stream will * be read entirely but not decoded, allowing features such as * seeking, looping and determining duration. * * @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead */ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean streamCache) { this.audioKey = new AudioKey(name, stream, streamCache); this.data = (AudioData) assetManager.loadAsset(audioKey); }
/** * Creates a new <code>AudioNode</code> with the given audio file. * * @param audioRenderer The audio renderer to use for playing. Cannot be null. * @param assetManager The asset manager to use to load the audio file * @param name The filename of the audio file * @param stream If true, the audio will be streamed gradually from disk, * otherwise, it will be buffered. * @param streamCache If stream is also true, then this specifies if * the stream cache is used. When enabled, the audio stream will * be read entirely but not decoded, allowing features such as * seeking, looping and determining duration. * * @deprecated AudioRenderer parameter is ignored. */ public AudioNode(AudioRenderer audioRenderer, AssetManager assetManager, String name, boolean stream, boolean streamCache) { this.audioKey = new AudioKey(name, stream, streamCache); this.data = (AudioData) assetManager.loadAsset(audioKey); }
if (audioNode == null) { audioBuffer = new AudioBuffer(); audioNode = new AudioNode(audioBuffer, new AudioKey("Speaker-" + device.getName(), true, true)); audioNode.setName("Speaker-" + device.getName()); } else {
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); rootNode.attachChild(geom); //audioStream = new AudioStream(); //audioStream.setupFormat(1, 16, 16000); audioBuffer = new AudioBuffer(); audioBuffer.setupFormat(1, 16, 16000); // might return -1 if unknown float streamDuration = 1f;//computeStreamDuration(); AudioInputStream audioInputStream; try { audioInputStream = AudioSystem.getAudioInputStream(new File("/home/pablo/tts_file.wav")); audioBuffer.updateData(readToBuffer(audioInputStream)); } catch (UnsupportedAudioFileException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } audioSource = new AudioNode(audioBuffer, new AudioKey("Speaker", true, true)); }