ESS R2 Null Pointer

Hi folks,

I started using the ESS sound library to do offline audio spectrum analysis. The code is straightforward but it gives a null pointer error for this function:

fft.getSpectrum(channel.samples,cuepoint);

channel is my audio channel with an mp3 file as its source and cuepoint is the index calculated based on the current frame. Could it be that there is something about the audio file that it does not like?

Cheers

Tagged:

Answers

  • edited March 2015

    Depends on the exact stack trace you get in the console... Here, we can only guess.
    Use println() with fft and channel, to see if one of them is null.

  • Thanks for the reply! Yes, channel is empty, not sure why though.

    This is the full error message: Exception in thread "Animation Thread" java.lang.NullPointerException at krister.Ess.FFT.getSpectrum(FFT.java:107) at Version4.draw(Version4.java:111) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:662)

  • I don't know ESS nor your code, but from your description, perhaps the MP3 file wasn't found, hence the null channel.

  • Answer ✓

    Thanks for the tip. Solved the issue, turns out you have to define the exact path of your file (does not matter if the file is in the same folder):

    myChannel = new AudioChannel(dataPath("C:/Users/Desktop/etc.mp3"));

  • Usually, Processing, and most libraries, just find the files in the data folder inside the sketch folder, without having to specify a path.

Sign In or Register to comment.