Problem Beads and Control P5

edited June 2016 in Library Questions

Hi, this is my first post on this forum os i'm sorry if my question isn't at the right place. I'm using Processing 3.1.1 and I have some problems with Beads. I'm using ControlP5 to change the gain of my Audioplayer but look at this code, it gives me a really long error from the void Musique and I don't know why.

Then the 2nd problem is when I start a long music, sometimes the program takes tool long to launch and it gives me this errorjava.lang.RuntimeException: Waited 5000ms for: <6c8aac95, 624d5f74>[count 2, qsz 0, owner <main-FPSAWTAnimator#00-Timer0>] - <main-FPSAWTAnimator#00-Timer0-FPSAWTAnimator#00-Timer1> at processing.opengl.PSurfaceJOGL$ at

And finally I'd like to know how to loop a sound because when i use setToLoopStart() and .KillOnEnd() it tells me that those functions doesn't exist.

Thanks for your help :)



  • edited May 2016

    It should be the sample player not the audiocontext that is setKillOnEnd player.setKillOnEnd(false); setToLoopStart() is the same, attaches to player. What happens if you load a small mp3 file - could it be running out of memory? I don't see where you're calling Musique, or why gain is /2000, where is the draw() loop? Look at the Sonifying Processing tutorial and copy the code from there. This sets up the sample player etc before the main setup loop which I think does matter.

  • Yes you're right about player i'm stupid ^^. If i load a small mp3 it's okay but its not a long music so it's pretty annoying. The gain is /2000 to correspond to my first gain. I don't need to call Musique because i'm not "using" it ? I didn't give you the draw loop() because everything about sound is in setup.

  • Actually my big problem comes from Musique because it works but it also give me an massive error because i'm using ControlP5, and i don't get the glider thing from onifying processing

  • Answer ✓

    Oh OK, didn't realise there was more code! Sorry, not used ControlP5 so no help with that.

  • Hi again, i have a new question about beads only this time. If i want to add a now sound, do I have to create a new audio context and sampler player ? (if i want to add a noise in front of my music)

  • Answer ✓

    New sample player for each sound, but the same audiocontext - you'll need to add an input to the audiocontext.

  • Okay, but when I want to start a music I have to do ac.start() and it will start I can't choose wich sound is played

  • In your draw loop, you can trigger samples from here: for instance, if the sampler player is called sp, then use sp.reTrigger(); to play, or use sp.setToLoopStart(); sp.start(); is how the sonifying processing tutorial does it. Don't know why but mine plays at first as well when the program runs, you could put a sp.reset(); in the setup to stop this happening.

  • edited June 2016

    I see what you mean but mine don't stop even with a sp.reset

    Also when I want to stop a sample player what do I have to use ? .pause() .reset() .setOnEnd() ? And when i stop a music with those it's pretty ugly the way the music cuts

  • Try using a gain envelope - you can fade the sample out using these, then doesn't matter what you use to stop it, could start with gain of 0, then fade it up when you're ready.

  • I think you only need one audio context and connect everything to that. Some of the code needs to be in your setup loop, not sure if it will work elsewhere. You'll need some code to change the gain variable. Can't help much with code as I'm using a tablet currently.

  • edited June 2016

    I'd like to have my musique and my sound separatly so that i can change the gain of both groups independently so i thought 2 ac was good. Forget this ^^

    Then what must go into the loop ?

  • I honestly don't know if it matters, but not seen any code with 2 audioContexts. You can use a musicGain and a soundGain so you can mix sounds and control relative levels. I do just copy the code from the examples, and then change it from there! I should be able to have a play with your code in a couple of hours.

  • That's why I think i don't anything in loop (from what I have in setup) and as I write previously, yup wrong idea it sucks and 2 gains are better ^^

  • I just saw your post about gain enveloppe but I don't want to mute it I want to stop it and maybe replace it

  • I'm not sure why it plays samples when the program first runs - so not sure how to turn it off! That's the only reason I'd personally start with gain at 0, then once program running put the gain up and reset the music.

  • why put the gain at 0 if we reset first the music ? ^^

  • Maybe you don't have this problem - when I start the program the samples all play, so I've started with gain = 0 to stop this, then I reset them & turn the gain up - when you said they don't stop with sp.reset(); this might be a way round that.

  • edited June 2016 Answer ✓

    This works my end - copy the bits into the relevant parts of your program. I've started with normal gain.

                // sample players into separate mixer channels
                import beads.*;
                AudioContext ac;
                SamplePlayer musiquePlay, son1, son2;
                Gain musiqueGain, sonGain;
                float sonVolume = 0.6;
                float musiqueVolume = 0.7;
                void setup()
                  size(800, 600);
                  ac = new AudioContext(); 
                  try {
                    // copy these SamplePlayers to make more sounds
                    musiquePlay = new SamplePlayer(ac, new Sample(sketchPath("") + "DrumMachine/ClosedHihat.wav"));
                    son1 = new SamplePlayer(ac, new Sample(sketchPath("") + "DrumMachine/Rimshot.wav"));
                    son2 = new SamplePlayer(ac, new Sample(sketchPath("") + "DrumMachine/Soft Bassdrum.wav"));
                  catch(Exception e)
                    println("Exception while attempting to load sample!");
                  son1.setKillOnEnd(false); // if you want to reuse the sample
                  sonGain = new Gain(ac, 1, sonVolume); // set volumes for each channel
                  musiqueGain = new Gain(ac, 1, musiqueVolume);
                  sonGain.addInput(son1); // connect each sample player to relevant channel of mixer
                  ac.out.addInput(sonGain); // join son & musique outs here into final mix
                  musiquePlay.reTrigger(); // start background music
                } // end setup
                void draw() {
                  // call son1.reTrigger() from here to play that sound
                void mousePressed() { // so you can test it
                  if ( mouseButton == LEFT ) {
                    son1.reTrigger(); // play the audio file
                  } else  {
  • For your first answer, yes I have the same problem when I start the program they all start but even with a sp.reset(); and gain = 0; then don't stop :/

    I'm reading your second one ^^

  • Ok it works ^^ thanks :p

  • Great, well done.

Sign In or Register to comment.