Help with AudioPlayer

edited October 2013 in Library Questions

I'm having trouble playing multiple sound files with the Minim audio player. Currently, I have an array of 3 AudioPlayers all initialized with separate audio files. I have a loop that goes to each cell of the array and plays the audio file.

  minim = new Minim(this);
  for (int i = 0 ; i < NUM_WAVS ; i++) {
    snd[i] = minim.loadFile(i+".mp3");
  }
  mLong = new Minim(this);
  for (int l = 0 ; l < LONG_WAVS ; l++) {
    sndlong[l] = mLong.loadFile("long"+l+".mp3");
  }
  mDrone = new Minim(this);
  for (int d = 0 ; d < DRONE_WAVS ; d++) {
    drone[d] = mDrone.loadFile("drone"+d+".mp3");
  }

The last AudioPlayer (mDrone) doesn't play unless I delete one of the first two, than it plays fine. So I know it can read the mp3s and play them. Will AudioPlayer only allow you 2 players?

Anybody know how to fix it?

Thanks

Tagged:

Answers

  • It sounds like the issue I had in Ubuntu. If that's the case, this may help: https://github.com/hamoid/Fun-Programming/blob/master/scripts/fix_sound.sh

  • thxs for reply hamoid, i'm using osx (& processing 2.0.3); do u think the same problem could exist on this platform?

    BTW I do get 2 separate audio files playing together. Just can't get a 3rd playing.

  • Answer ✓

    Ah then it must be something different I think. Similar symptoms though :)

    What values do you have in NUM_WAVS, LONG_WAVS and DRONE_WAVS? Are you maybe loading too many of them? Have you initialised the snd, sndlong and drone arrays? You say you have an array of AudioPlayers, but I see three arrays... is that what you want?

  • minim has 25 mp3s mLong has 8 mp3s drone has 3 longer mp3s

    i've initialised snd, sndlong and drone. & I know the code is correct as if i delete snd, the other two play; Or if i delete sndlong, the other two play; otherwise as it is just the first two (snd, sndlong) play.

  • whichever i put as last doesn't play. So (as above) in this order; 1. minim 2. mLong 3. mDrone

    mDrone doesn't play. But if I move mDrone to appear first, it does and mLong doesn't play.

    mDrone = new Minim(this);
    for (int d = 0 ; d < DRONE_WAVS ; d++) {
      drone[d] = mDrone.loadFile("drone"+d+".mp3");
    }
    minim = new Minim(this);
    for (int i = 0 ; i < NUM_WAVS ; i++) {
      snd[i] = minim.loadFile(i+".mp3");
    }
    mLong = new Minim(this);
    for (int l = 0 ; l < LONG_WAVS ; l++) {
      sndlong[l] = mLong.loadFile("long"+l+".mp3");
    }
    
  • Answer ✓

    Maybe you could try reduce each array to 1 element to find out if it's related to the number of sounds, or the number of arrays. If loading 1 of each kind works, increase the numbers until it fails. Or maybe the word "minim" is somehow reserved? Does increasing the available ram in the Processing settings help?

  • Thanks hamoid, it seems like it is an issue with the number of sounds I can load. I've cut it back to 30 audio clips and all three audio players now work together.

    many thanks for your help

  • Hi did this allow the tracks to be played at the same time? Could you show the whole code? thanks

Sign In or Register to comment.