Solved is there a way to slowdown sounds?

Discussion in 'Plugin Development' started by xize, Sep 18, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    xize

    hello,

    I whas wondering is it possible to slow down playing sounds without schedulers or can it only be done with schedulers?

    I wasn't really able to find a way to slow down playing sounds without using schedulers.

    the way I use my sounds is like:

    Code:
    entityPlayer.getWorld().createExplosion(entityPlayer.getLocation(), 0.0F);
    entityPlayer.getWorld().playSound(entityPlayer.getLocation(), Sound.AMBIENCE_CAVE, 3, 3);
    entityPlayer.getWorld().playSound(entityPlayer.getLocation(), Sound.AMBIENCE_RAIN, 3, 3);
    entityPlayer.getWorld().playSound(entityPlayer.getLocation(), Sound.ANVIL_BREAK, 3, 3);
    entityPlayer.getWorld().playSound(entityPlayer.getLocation(), Sound.AMBIENCE_THUNDER, 3, 3);
    entityPlayer.getWorld().playSound(entityPlayer.getLocation(), Sound.WOLF_DEATH, 3, 3);
    
    I'm not sure what these float values mean I thought it whas to change the pitch of the sound but not sure.

    thanks:)
     
  2. Offline

    Bammerbom

    xize There are other ways. But schedulars is the best.
    I don't know that other ways. I am beginner.
     
  3. Offline

    The_Doctor_123

    When you say "slow down" do you mean delaying it, or actually slowing the sound itself?
     
  4. Offline

    Bart

    He means delaying it. You can only use schedulers, not sure what Jhtzb is talking about. If it's a regular occurrence I would make a method for it.

    Code:java
    1.  
    2. public void playDelayedSound(Location l, Sound sound, int pitch, int volume, long delay) {
    3. plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    4. public void run() {
    5. l.getWorld().playSound(l,sound,pitch,volume);
    6. }
    7. }, delay);
    8. }
    9.  


    Usage to delay all your sounds by one tick:

    Code:java
    1.  
    2. playDelayedSound(entityPlayer.getLocation(), Sound.AMBIENCE_CAVE, 3, 3, 20L);
    3. playDelayedSound(entityPlayer.getLocation(), Sound.AMBIENCE_RAIN, 3, 3, 40L);
    4. playDelayedSound(entityPlayer.getLocation(), Sound.ANVIL_BREAK, 3, 3, 60L);
    5. playDelayedSound(entityPlayer.getLocation(), Sound.AMBIENCE_THUNDER, 3, 3, 80L);
    6. playDelayedSound(entityPlayer.getLocation(), Sound.WOLF_DEATH, 3, 3, 100L);
    7.  

    Remember that delay is in ticks, 20 ticks per second so 20L would be one second. The example above would play all your sounds one after the other with a 1 second delay on them.
     
  5. Offline

    xize

    ah thanks all:), it works
     
Thread Status:
Not open for further replies.

Share This Page