Im trying to play minim sounds over each other but they stop to allow for the new one

So I have two sounds shot and death now I want the sounds to play and when another call to play happens a new object is dynamically created and plays its sound, but still what happens is my sound is cut short!

class Sound {

  Minim minim;

  AudioSnippet shot, enemy_death;

  Sound(AudioSnippet s, AudioSnippet d) {

    minim = new Minim(this);

    shot = s;
    enemy_death = d;
  }

  void play_shot() {

    shot.play();
  }

  void play_death() {

    enemy_death.play();
  }
}

see this, this is my loading sound class, and I have to dynamically create the sound object and also load sounds in setup, it doesnt work, think I have one shot noise and I want it to play overlapped like two machine guns, how do I do this?

Tagged:

Answers

  • Line 9: the this there won't work, see Why I can't create an instance of a library from my own classes?. And you should avoid to instantiate Minim twice. I don't know if you make another instance, but the way it is coded, it can be instantiated several times.

    I haven't fully understood your question, but I suggest to take a look at the Minim examples shipped with Processing, if you haven't done it already.

  • ah yes I sussed it out, had to initialize minim in setup and use it asa global variable to load sounds in the class, just why do you have to initialize minim like that? (I have to explain what im doing in my comments for courswork)

Sign In or Register to comment.