A question about the import of minim files

Hi!
I am a beginner in processing. I had some problems when importing audio files using minim. The file name and location looks correct. Below is my code.

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioPlayer song;

void setup()
{
  size(200,200);
  
  minim= new Minim( this );
  
  song = minim.loadFile("music-1.mp3",2048);
  
  song.play();
  
}
void draw()
{

}

Many thanks .!

1 Like

what is the real file location?
could be sketch dir or data dir

what is the real file name?
“music_1.mp3”

Files in the date folder, I just tried to use the microphone for input.
Also have this problem.
I don’t know if it is related to the macOS (catalina) I use.
I hope it’s not a computer problem
Thanks

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioInput microphone;

void setup()
{
  size(500,500);
  
  minim= new Minim( this );
  
  microphone= minim.getLineIn();
  
}
void draw()
{
  float backgroundCol = microphone.mix.level() * 255.0 ;

  background(backgroundCol,backgroundCol,backgroundCol);
  
}

if that is a problem about
// a incompatible system / .vs. / a processing version //
please not use any OWN code …
just try using existing examples
and tell us what works and what not

  • mic
  • camera
  • file

see also
(eg. Processing.app/Contents/Info.plist )

I just tried several cases on the processing official website
Mostly no problem
But the errors are basically in the aspect of file import
No code error was detected before clicking Run
but “NullPointerException” will be prompted when clicking Run
and the running window cannot be closed

For example: Load and Display Image, film and mic
ps: My first language is not English, so please forgive me for looking strange in my word

no, my only point was, as long you test / post own code
( also even you only copy from somewhere …)

10 people will read it / 5 people might even copy paste and test it /
but never have the actual by you use file available…

what a waste of time if it is not code but system related…

when i say example i mean like:
PDE / File / Examples / Contributed Libraries / Minim / Basics / PlayAFile [any key]
PDE / File / Examples / Contributed Libraries / Minim / Basics / RecordAudioInput “TALK/SING” [r]


BUT if the provided examples for
processing core or libraries regarding
file / camera / sound / work, but your code not
you not need us here,
you can work on your own and compare a running example with your code.


for your above microphone code
( in case you have no error, but just a blank screen )
you might use a

  println(backgroundCol);

in draw to see your problem

i changed and combined it with the example and it works here
( here: win 10 64bit / processing 3.5.3 64bit )

import ddf.minim.*;

Minim minim;
AudioInput mic;

void setup() {
  size(500, 200);
  minim= new Minim( this );
  mic= minim.getLineIn();
}
void draw() {  
  float backgroundCol = mic.mix.level() * 2000; //255.0 ;
  println(backgroundCol);
  background(backgroundCol, backgroundCol, backgroundCol);
  stroke(255);
  for (int i = 0; i < mic.bufferSize() - 1; i++) {
    line(i, 50 + mic.left.get(i)*50, i+1, 50 + mic.left.get(i+1)*50);
    line(i, 150 + mic.right.get(i)*50, i+1, 150 + mic.right.get(i+1)*50);
  }
}

1 Like

thank you!
My problem has been solved!!

1 Like