Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Minim and Real Memory / Memory

$
0
0
As PhiLho said. Perhaps you need some println()'s cause there are two options and both are no good. Either you don't close samples as I assumed (because each sample never stops playing, in fact it's replaced before it ends). Or you do close each sample, but then you also stop minim and the sketch, which is strange, because you keep using it.

To answer your question. You only need to close a sample when you are done with it. You only need to stop Minim when you are done with the whole sketch.

In addition, I suggest moving to Processing 2.01 where you don't need to stop Minim anymore so I suspect some changes have been made in the past years also to the included core version of Minim.

Furthermore I find it very peculiar that there would be a 32 limit on playable files. I've written a test sketch - tested with Processing 2.01's Minim - and I encounter no such problems. I can load all 42 mp3s and play each one of them.

Again, all the code you posted so far has seemed buggy. So I would check twice before your blame it on the library.

Code Example (Processing 2.01)
  1. // press space to go to the next file

  2. import ddf.minim.*;
  3.  
  4. String pathToMp3s = "C:/Media/Music/Collected/"; // contains 42 mp3s of in total 324 MB
  5.  
  6. Minim minim;
  7. AudioPlayer[] mp3s;
  8. String[] filenames;
  9. int count;
  10.  
  11. void setup() {
  12.   size(300, 300);
  13.   minim = new Minim(this);
  14.  
  15.   filenames = loadFilenames(pathToMp3s);
  16.   mp3s = new AudioPlayer[filenames.length];
  17.  
  18.   for (int i=0; i<mp3s.length; i++) {
  19.     mp3s[i] = minim.loadFile(pathToMp3s + filenames[i]);
  20.   }
  21.  
  22.   mp3s[0].play();;
  23.   println("Number 0 (" + filenames[0] + ") is currently playing.");
  24. }
  25.  
  26. void draw() {
  27.   background(0);
  28. }
  29.  
  30. void keyPressed() {
  31.   if (key == ' ') {
  32.     for (int i=0; i<mp3s.length; i++) {
  33.       if (mp3s[i].isPlaying()) mp3s[i].pause();
  34.     }
  35.     count = ++count%mp3s.length;
  36.     mp3s[count].play();
  37.     println("Number " + count + " (" + filenames[count] + ") is currently playing.");
  38.   }
  39. }
  40.  
  41. String[] loadFilenames(String path) {
  42.   File folder = new File(path);
  43.   java.io.FilenameFilter filenameFilter = new java.io.FilenameFilter() {
  44.     public boolean accept(File dir, String name) {
  45.       String lowcase = name.toLowerCase();
  46.       return lowcase.endsWith(".mp3");
  47.     }
  48.   };
  49.   return folder.list(filenameFilter);
  50. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles