Unable to load file using Minim::loadFileStream() and others using Minim (without Processing)

Hey all,
I am trying to use Minim without Processing and running into some errors. I am compiling correctly, but am unable to load a file that exists.

I have added a MinimWrapper class which has the sketchPath and createInput methods defined. I have an init() method for this class which allocates a new Minim object and loads an mp3 file as a AudioRecordingStream, using loadFileStream().

This call silently fails (wee!), and returns null. What gives? I’ve switched the slashes around and used a relative path as well, with similar results.

Here’s my example:

public class MinimWrapper {

    Minim minim;
    AudioPlayer audioPlayer;
    AudioRecordingStream audioRecordingStream;
    BeatDetect beatDetect;
    float eRadius;

     // Required methods for using Minim.
    String sketchPath( String fileName ) { return fileName; }
    InputStream createInput(String fileName ) {
        try {
            return new FileInputStream(new File(fileName));
        } catch(Exception e) {
            return null;
        }
    }

    public void init(File iFile)
    {
        minim = new Minim(this);

        String filename = iFile.getAbsolutePath();
        if (iFile.exists() == false) {
            System.out.println("file: " + filename + " does not exist");
        }

        int fftSize = 512;
        audioRecordingStream  = minim.loadFileStream(filename, fftSize, false);
        if (audioRecordingStream == null) {
            System.out.println("Unable to load file as AudioRecordingStream object " + filename);
        }
        // removed stuff here for brevity.

}

And the output from the Intellij console:

"C:\Program Files\Java\jdk-12.0.2\bin\java.exe" "-javaagent:E:\Apps\IntelliJ IDEA Community Edition 2019.3.3\lib\idea_rt.jar=58794:E:\Apps\IntelliJ IDEA Community Edition 2019.3.3\bin" -Dfile.encoding=UTF-8 -classpath E:\StepMania\Beatcharter\out\production\Beatcharter;E:\StepMania\Beatcharter\lib\commons-cli-1.4.jar;E:\StepMania\Beatcharter\lib\jl1.0.1.jar;E:\StepMania\Beatcharter\lib\tritonus_share.jar;E:\StepMania\Beatcharter\lib\tritonus_aos.jar;E:\StepMania\Beatcharter\lib\mp3spi1.9.5.jar;E:\StepMania\Beatcharter\lib\commons-io-2.6.jar Main -i sample1.mp3
Generating SM for sample1.mp3 to ./sample1.sm
Unable to load file as AudioRecordingStream object E:\StepMania\Beatcharter\sample1.mp3

Note these are my print statements, the last one seen above in the sample code. I guess Minim doesn’t think a failure to load the file is worth logging?
Any idea what I’m doing wrong here?

1 Like

The problem was that my required methods above, sketchPath() and createInput() were missing ‘public’, specifically createInput() for this error. Pretty obvious, but I’m not sure why there wasn’t any compilation or runtime errors…

2 Likes