public void play() { if (use_short_sound) { short_sound.play(); is_playing = false; // short sound, won't be playing long... } else { if (use_start_sound) { t = newTimer( start_sound.getLengthAsInt(), false, new ActionListener() { public void actionPerformed(ActionEvent e) { handleTimerPop(e); } }); start_sound.play(); if (use_mid_sound) { t.start(); is_playing = true; } } else if (use_mid_sound) { mid_sound.setLooped(true); mid_sound.play(); } } }
// Catch the timer pop after the start sound is played and trigger the (looped) sustain sound. protected void handleTimerPop(ActionEvent e) { log.info("Received timer pop after start sound played."); // TODO: Need to validate that this is the timer pop if (use_mid_sound) { mid_sound.setLooped(true); mid_sound.play(); } t.stop(); }
public boolean init(VSDFile vf) { if (!initialized) { if (use_start_sound) { start_sound = new SoundBite(vf, start_file, name + "_Start", name + "_Start"); start_sound.setLooped(false); start_sound.setGain(gain); } if (use_mid_sound) { mid_sound = new SoundBite(vf, mid_file, name + "_Mid", name + "_Mid"); mid_sound.setLooped(false); mid_sound.setGain(gain); } if (use_end_sound) { end_sound = new SoundBite(vf, end_file, name + "_End", name + "_End"); end_sound.setLooped(false); end_sound.setGain(gain); } if (use_short_sound) { short_sound = new SoundBite(vf, short_file, name + "_Short", name + "_Short"); short_sound.setLooped(false); short_sound.setGain(gain); } } return (true); }
public void shutdown() { if (use_start_sound) { start_sound.stop(); } if (use_mid_sound) { mid_sound.stop(); } if (use_end_sound) { end_sound.stop(); } if (use_short_sound) { short_sound.stop(); } }
@Override public void setVolume(float v) { if (use_start_sound) { start_sound.setVolume(v); } if (use_mid_sound) { mid_sound.setVolume(v); } if (use_end_sound) { end_sound.setVolume(v); } if (use_short_sound) { short_sound.setVolume(v); } }
@Override public void mute(boolean m) { if (use_start_sound) { start_sound.mute(m); } if (use_mid_sound) { mid_sound.mute(m); } if (use_end_sound) { end_sound.mute(m); } if (use_short_sound) { short_sound.mute(m); } }
@Override public void setPosition(PhysicalLocation p) { super.setPosition(p); if (use_start_sound) { start_sound.setPosition(p); } if (use_mid_sound) { mid_sound.setPosition(p); } if (use_end_sound) { end_sound.setPosition(p); } if (use_short_sound) { short_sound.setPosition(p); } }
public void loop() { if (use_start_sound) { start_sound.setLooped(false); start_sound.play(); t = newTimer( start_sound.getLengthAsInt() - 100, false, new ActionListener() { public void actionPerformed(ActionEvent e) { handleTimerPop(e); } }); t.setRepeats(false); // timer pop only once to trigger the sustain sound. t.start(); } else if (use_mid_sound) { mid_sound.setLooped(true); mid_sound.play(); } is_playing = true; }
public void stop() { log.warn("Stopping"); // make sure the start sound is killed if (use_start_sound) { start_sound.stop(); } // If the mid sound is used, turn off the looping. // this will allow it to naturally die. if (use_mid_sound) { mid_sound.setLooped(false); mid_sound.fadeOut(); } // If the timer is running, stop it. if (t != null) { t.stop(); } // If we're using the end sound, stop the mid sound // and play the end sound. if (use_end_sound) { if (use_mid_sound) { mid_sound.stop(); } end_sound.setLooped(false); end_sound.play(); } is_playing = false; }
public static long calcLength(SoundBite s) { return (calcLength(s.getBuffer())); }