Issues with Minim and Strings

Basically, I have an imported string where the code reads the individual letters of text. When a specific letter appears, it acts as a variable to trigger an action

if string = = 'a' { fill(#00000); }

or something to that effect.

I'm trying to make specific letters trigger imported mp3 files. But when I use the minim library's function player.play("note.mp3"); I get an error "the method of play(int) is the type AudioPlayer is not applicable for the arguments (String)"

Can anyone help?

Tagged:

Answers

  • First, to compare strings you should use: StringOne.equals(StringTwo)

    Second, the AudioPlayer.play() method, as the error message states clearly, does not take a String as an input parameter. See the javadocs: http://code.compartmental.net/minim/javadoc/ddf/minim/AudioPlayer.html

    If you want to play different tracks, you need to load them separately, then play/pause accordingly.

  • I'm not necessarily comparing strings, more of using a method to analyze what is in a string and act accordingly. It works on it's own without involving the sound library.

    I have an octave (a-g) of notes loaded all separately as files. Does this mean that this audio player doesn't work with strings at all? Or is there a work around needed?

  • edited October 2014

    The loading of the mp3 file is SEPARATE from the playing of the sound in the file

    // Global variable
    Minim minim;
    
    public void setup(){
        size(300,300);
        minim = new Minim(this); // create a Minim controller
        // Assume that for each note a-g there is an associated file noteA...noteG
        AudioPlayer noteA = minim.loadFile("noteA.mp3");
        AudioPlayer noteB = minim.loadFile("noteB.mp3");
        // So load each one in turn
    
        // To play the sound use
        noteA.play();
        noteB.play(); // etc.
    }
    
Sign In or Register to comment.