public final boolean init(VSDFile vf, BufferMode mode) { AudioManager am = jmri.InstanceManager.getDefault(jmri.AudioManager.class); if (!initialized) { try { sound_src = (AudioSource) am.provideAudio(SrcSysNamePrefix + system_name); sound_src.setUserName(BufUserNamePrefix + user_name); setLooped(false); if (mode == BufferMode.BOUND_MODE) { sound_buf = (AudioBuffer) am.provideAudio(BufSysNamePrefix + system_name); sound_buf.setUserName(BufUserNamePrefix + user_name); if (vf == null) { sound_buf.setURL(vsd_file_base + filename); } else { java.io.InputStream ins = vf.getInputStream(filename); if (ins != null) { sound_buf.setInputStream(ins); } else { return (false); } } sound_src.setAssignedBuffer(sound_buf); setLength(); } } catch (AudioException | IllegalArgumentException ex) { log.warn("Problem creating SoundBite: " + ex); } } return (true); }
public void mute(boolean m) { if (m) { volume = sound_src.getGain(); sound_src.setGain(0); } else { sound_src.setGain(volume); } }
public void setLooped(boolean loop, int minloops, int maxloops) { this.looped = loop; this.minloops = minloops; this.maxloops = maxloops; sound_src.setLooped(looped); sound_src.setMinLoops(minloops); sound_src.setMaxLoops(maxloops); }
public void fadeOut() { // Skip the fade action if the fade out time is zero. if (sound_src.getFadeOut() == 0) { sound_src.stop(); } else { sound_src.fadeOut(); } is_playing = false; }
public void fadeIn() { // Skip the fade action if the fade in time is zero. if (sound_src.getFadeIn() == 0) { sound_src.play(); } else { sound_src.fadeIn(); } is_playing = true; }
public int numQueuedBuffers() { if (bufferMode == BufferMode.QUEUE_MODE) { return (sound_src.numQueuedBuffers()); } else { return (0); } }
public void queueBuffer(AudioBuffer b) { if (bufferMode == BufferMode.QUEUE_MODE) { if (b == null) { log.debug("queueAudioBuffer with null buffer input"); return; } if (sound_src == null) { log.debug("queueAudioBuffer with null sound_src"); return; } log.debug("Queueing Buffer: " + b.getSystemName()); sound_src.queueBuffer(b); } else { log.warn("Attempted to Queue buffer to a Bound SoundBite."); } }
public void setVolume(float v) { volume = v * gain; sound_src.setGain(volume); }
public int getFadeInTime() { return (sound_src.getFadeIn()); }
@Override public void setPosition(PhysicalLocation v) { super.setPosition(v); sound_src.setPosition(v); }
public void rewind() { sound_src.rewind(); }
public int getFadeOutTime() { return (sound_src.getFadeOut()); }
public void stop() { sound_src.stop(); is_playing = false; }
public void pause() { sound_src.pause(); is_playing = false; }
public void loop() { sound_src.play(); is_playing = true; }
public void setFadeInTime(int t) { sound_src.setFadeIn(t); }
public void unqueueBuffers() { if (bufferMode == BufferMode.QUEUE_MODE) { sound_src.unqueueBuffers(); } }
public void setFadeTimes(int in, int out) { sound_src.setFadeIn(in); sound_src.setFadeOut(out); }
public void setFadeOutTime(int t) { sound_src.setFadeOut(t); }