I'm creating a music visualiser. I am stuck on the part which allows the user to upload music tracks from their music library on their computer and have the visualiser respond to the beat of the specific song they have chosen.
I have used the minim library in Processing however I have to load the file name in the coding. I would like a way to have the user click a button which will open the file browser and allow them to select a track and then input that track into the player which will play the track and have the visualiser respond to the beats of the track.
I am not asking for code; rather I am asking on a way to go about this step by step. I am stuck on how to retrieve the files from the computer. I am not very good at coding so I am looking at libraries and tutorials online however; the videos I am finding on this topic only shows how to load text files into a sketch rather than a music file.
Sounds like you're looking for the selectInput()
function.
From the reference:
void setup() { selectInput("Select a file to process:", "fileSelected"); } void fileSelected(File selection) { if (selection == null) { println("Window was closed or the user hit cancel."); } else { println("User selected " + selection.getAbsolutePath()); } }
Opens a platform-specific file chooser dialog to select a file for input. After the selection is made, the selected File will be passed to the 'callback' function. If the dialog is closed or canceled, null will be sent to the function, so that the program is not waiting for additional input. The callback is necessary because of how threading works.