filepathprocessingminim

How do I specify the full path of a file using Minim in Processing?


I am using Windows, and running Processing 3.

I downloaded a french audiovisualizer, and it by default has a folder named "data" with a song.wav inside. When booting up the processing project it required me to make the project in its own folder, so I believe the location of the song.wav is different now.

So, I decided to do the reasonable thing and specify the full path of the song which changed the code from this:

  song = minim.loadFile("song.wav");

to

  song = minim.loadFile("C:\Users\*******\Downloads\ProcessingCubes-master\data\PulseWAV.wav");

(My user tag has been ommitted.)

But this returned the nasty error of:

processing.app.SketchException: Not expecting symbol 'U', which is LATIN CAPITAL LETTER U.
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:376)
    at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:155)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:122)
    at processing.mode.java.JavaBuild.build(JavaBuild.java:104)
    at processing.mode.java.JavaMode.handleLaunch(JavaMode.java:122)
    at processing.mode.java.JavaEditor.lambda$0(JavaEditor.java:1099)
    at java.lang.Thread.run(Thread.java:748)

I'm not very familiar with processing, just decided to do it for this one project, so I don't know how to continue from here. Any help is appreciated.


Solution

  • The backslash \ character is an escape character.

    Escape characters let you use combinations like "\n" for newline or "\t" for tab.

    Your error is telling you that "\U" is not a valid combination, so "C:\Users..." is not allowed.

    To fix this, you need to escape the escape character. In other words, you need to use "\\" instead of "\".

    "C:\\Users\\*******\\Downloads\\ProcessingCubes-master\\data\\PulseWAV.wav"
    

    This is a common problem with Windows file paths. In my experience you can also use forward slashes:

    "C:/Users/*******/Downloads/ProcessingCubes-master/data/PulseWAV.wav"
    

    By the way, it's generally a good idea to google any error messages you don't understand. I tried googling "Not expecting symbol 'U', which is LATIN CAPITAL LETTER U." and got a couple results which look like they would have unblocked you.