Search in sources :

Example 11 with AudioManager

use of jmri.AudioManager in project JMRI by JMRI.

the class AbstractAudioSource method setAssignedBuffer.

@Override
public void setAssignedBuffer(String bufferSystemName) {
    if (!queued) {
        AudioManager am = InstanceManager.getDefault(jmri.AudioManager.class);
        Audio a = am.getBySystemName(bufferSystemName);
        if (a.getSubType() == Audio.BUFFER) {
            setAssignedBuffer((AudioBuffer) a);
        } else {
            log.warn("Attempt to assign incorrect object type to buffer - AudioBuffer expected.");
            this.buffer = null;
            this.bound = false;
        }
    } else {
        log.error("Attempted to assign buffer " + bufferSystemName + " to Queued Source " + this.getSystemName());
    }
}
Also used : AudioManager(jmri.AudioManager) AbstractAudio(jmri.implementation.AbstractAudio) Audio(jmri.Audio)

Example 12 with AudioManager

use of jmri.AudioManager in project JMRI by JMRI.

the class SoundBite method init.

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) {
                    log.debug("VSD file is null! Filename: {}", filename);
                    // Path must be provided by caller.
                    sound_buf.setURL(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);
}
Also used : AudioManager(jmri.AudioManager) AudioException(jmri.AudioException)

Aggregations

AudioManager (jmri.AudioManager)12 Audio (jmri.Audio)8 AudioException (jmri.AudioException)4 AudioSource (jmri.jmrit.audio.AudioSource)4 AudioBuffer (jmri.jmrit.audio.AudioBuffer)3 AudioListener (jmri.jmrit.audio.AudioListener)2 Element (org.jdom2.Element)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Vector3f (javax.vecmath.Vector3f)1 AbstractAudio (jmri.implementation.AbstractAudio)1 Attribute (org.jdom2.Attribute)1