For an audio-visualising app I am looking for a way to import music from a folder or just get a list or array in the sketch itself. Is this possible and how can I do this? I am using processing 2.2 on a windows 8 computer.
Okay... @GoToLoop, I've tried your sketch just the way it is without changing things. I get a pop up screen when clicking on the screen. I can only select folders? And when I select one I still get a black screen. How does this work? :p Sorry for being such a nuisance
final String[] EXTS = {
".png", ".jpg", ".jpeg", ".gif"
};
It only reads file names w/ those extensions! So we gotta choose a folder w/ at least 1 of those type of files. listFiles() invokes that accept() customized method in order to filter them out.
As I've already mentioned, you gotta replace those w/ the 1s you're gonna need!
Answers
This thread below got a full example on how to get a File[] from some user-chosen folder:
http://forum.processing.org/two/discussion/6004/how-to-make-a-movie-array
Basically we use FilenameFilter interface + listFiles() method in order to only get the extensions we want to:
Just replace the image extensions w/ audio 1s. Of course, rename pictFilter to something like sndFilter! (*)
@GoToLoop: You don't have to install that library? The webpage is a bit confusing.... :P
And Do you have to use alll the code you used in the thread about the movie array? all the voids and everything?
That example doesn't use any 3rd-party libraries. Only standard Java's!
That example is about displaying pictures from a folder. You gotta adapt it for your particular needs!
Thanks a lot!!!
Okay... @GoToLoop, I've tried your sketch just the way it is without changing things. I get a pop up screen when clicking on the screen. I can only select folders? And when I select one I still get a black screen. How does this work? :p Sorry for being such a nuisance
That's true! It uses selectFolder() rather than selectInput():
http://processing.org/reference/selectFolder_.html
http://processing.org/reference/selectInput_.html
As you can see inside
new
FilenameFilter():It only reads file names w/ those extensions! So we gotta choose a folder w/ at least 1 of those type of files.
listFiles() invokes that accept() customized method in order to filter them out.
As I've already mentioned, you gotta replace those w/ the 1s you're gonna need!
I've been through your code, but where can I find the part to what has happened with the selected file? The screen stays black
This is the code which invokes the folder select pop-up window:
Once it's done and closed, it invokes folderSelected():
Which in turn calls up getFolderContent():
Which returns a File[] filter out by listFiles() + pictFilter!
P.S.: You don't need to use neither selectFolder() nor selectInput() if you got a fixed path where your files are!