Use an Array of mp3 files which when on keyPressed plays a random selection from it at the same time

edited March 2016 in Library Questions

I know it seems convoluted, Im struggling to play more than one track at a time using minim. I would like to know how to set up an array of maybe 10 tracks I have (bass,chords,melody etc), then on a key command to play a random selection of maybe four of the ten tracks at the same time, ?

Is this difficult to do? Any pointers very much appreciated.

Answers

  • Thanks GoToLoop

    I read it but don't fully grasp it.

    I need to add an array of mp3's

    then on key press play a selection of them at the same time.

    Ive managed it with images using PImage and for loop but the sound files I can't figure out.

    Any pointers?

  • I assume you already call play() in order to play an AudioPlayer from your array.
    My advice is to also call rewind() before play().

  • @vincepat Are you wanting to play a synchronized mix of selected tracks - as if using a multichannel mixer? If so I'm not sure Minim can do this. I looked at it as that is what I wanted to do a while back, but could only find a way to play single files.

  • Hi Hudson - yes I'm trying to play maybe 3 tracks simultaneously on a key press. Then an another key press would play another 3 tracks, all randomly picked from an array of 10+ .mp3s.

    GotoLoop - thanks I'll give that a go.

    Genuinely appreciate the support thanks

  • Just had a quick look at the minim docs and think that it may be worth trying AudioSample instead of AudioPlayer?

  • edited March 2016

    Im struggling

    import ddf.minim.analysis.*;
    import ddf.minim.effects.*;
    import ddf.minim.signals.*;
    import ddf.minim.spi.*;
    import ddf.minim.ugens.*;
    
    import ddf.minim.*;
    
    Minim minim;
    AudioSample[] songArray = new AudioSample [10];
    
    void setup()
    {
      size(100, 100);
       minim = new Minim(this);
     for (int i = 0 ; i < 3 ; i++) {
      songArray[i] = minim.loadSample("sound" + i +".mp3");
     }
      for (int p = 0 ; p < 3 ; p++) {
      songArray[p] = minim.loadSample("sounds" + p +".mp3");
     }
      for (int s = 0 ; s < 4 ; s++) {
      songArray[s] = minim.loadSample("soundss" + s +".mp3");
     }
    
    }
    
    void draw()
    {
    
    }
    
     void mousePressed(){
    
     .play();
    
     }
    

    This is what I have so far.

Sign In or Register to comment.