About nullpointerexception

Asked 2 years ago, Updated 2 years ago, 86 views

Hello, I'm having trouble getting an error.Please let me know.

import ddf.minim.*;//importing the minimal library 
Declaration of Minim;//Minim variable
AudioPlayer player;//Variables for storing sound data
inti;
import com.onformative.leap.LeapMotionP5;
import com.leapmotion.leap.Finger;

AudioPlayer loopSound;
float x,y;
LeapMotionP5leap;

void setup() {

    minimum = new Minimum(this); // initializing minimum
    player=minim.loadFile("piano14.mp3");
    leap = new LeapMotionP5(this);
    /*
    ↑ Load audio data, read as many as you want, or collectively.
    I don't know how to do it, but if it gets longer, will it be okay?
    Ask Mr. Google.

    Also, if you want to configure more than one player, add serial numbers to the player.
    e.g.)
    player1=minim.loadFile("○○○.mp3"); 
    player2=minim.loadFile("□□□.mp3"); 
    player3=minim.loadFile("△△△.mp3"); 
    */

    ColorMode(RGB,256);// Color Mode: Well, RGB is fine.
    size (800,600); // Campus size: preference
    Background (240, 240, 240); // Background color: Maybe the image is better?

}

void draw() {

    for (i=0; i<10;i++)
        /*
        ↑ The initial value of i is 0, and when i is lower than 10, i is +1 for each description.

        ↓ All of the following numbers are appropriate.Please change it according to the UI.
        */
    {
        Fill(30,30,30); // Color the ↓ squares
        rect(10,10+100*i,100,40);//Square description
        rect(150,55+100*i,100,40);
        rect(290,10+100*i,100,40);
        rect (430,55+100*i,100,40);
        rect(570,10+100*i,100,40);
        rect (710,55+100*i,100,40);
        for (Finger finger:leap.getFingerList()) {
            PVector fingerPos=leap.getTip(finger);
            else(fingerPos.x,fingerPos.y,10,10); 
            if(fingerPos.x>10&fingerPos.x<110&fingerPos.y>10+100*i&fingerPos.y<50+100*i)
                /*
                ↑
                ·Convert mouseX, mouseY to coordinates taken by leap motion
                "·If you use a ""variable"" like i, it is difficult to change the sound for each square."
                 It can be difficult.It might work out after trial and error (lol).
                */
            {
                fill (150, 150, 150);
                rect(10,10+100*i,100,40);
                /*
                ↑
                Only when the mouse cursor (=the coordinates of the fingertips obtained by leaping) comes to the specified position.
                Overwrite fill and rect.
                */
                player.play();
                /*
                Make a sound here. If you serialize it, change the player to distinguish it.
                */
            }
        }
    }
}

void stop()
{
    player.close();// Exit sound data
    minimum.stop();
    super.stop();
}

[Error Contents] NullPointerException
JavaSound Minimum Error
error invoking createInput on the file loader object null

java processing leap-motion

2022-09-30 21:10

1 Answers

[Error Contents] NullPointerException
JavaSound Minimum Error
error invoking createInput on the file loader object null

You can see from this error message that createInput is returning null (not working), so

player=minim.loadFile("piano14.mp3");

It appears that is experiencing an error.
The argument "piano14.mp3" is the only possible cause.

In Minim, click

the createInput method will search in the data folder, the sketch folder, handle URLs, and absolute paths.

There is a description.
Is the file piano14.mp3 in the location where createInput, such as the data folder, looks for the file?If the file is misplaced, moving it to the appropriate location should solve the problem.
If you don't know where the data folder is, I think you can solve this problem by specifying the file with the absolute path.


2022-09-30 21:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.