Automatic MP3 audio track selection on the linux desktop with java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This project uses java, linux, and my private music collection to maintain a convolutional neural network that selects songs to play automatically.

The project also uses the chromaprint ubuntu library for /usr/bin/fpcalc which is included in the ubuntu package 'libchromaprint-tools'.

The project also uses a MySQL database. This has to be set up separately with the ubuntu packages 'mysql-common' and 'mysql-server'.

mysql> create database acnn;
mysql> grant all on acnn.* to 'testuser'@'localhost' identified by 'fpstuff';

some methods from the java ACNNDataBase class need to be called separately. Before doing this, or whenever the database needs to be wiped, use the code below to delete the 'station' and 'user' tables.

mysql> use acnn;
mysql> drop tables station, user, score, reject, heard, playing, user_score;

To run the java program for the first time, execute the line java -start, or enter the string -start in the space in your IDE where program arguments go.

You should then run the app normally without the -start option, and it should work without error. You can also try -music or -train as startup options.

Producing a jar file was difficult and initially required editing the manifest file from the resulting jar by hand. The MANIFEST.MF file should look like this:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: samuel
Build-Jdk: 1.7.0_40
Created-By: Apache Maven

The part that needed to be edited was the last line that begins with the keyword 'Main-Class'. After editing the maven pom.xml files the manifest issue seems to have been solved.

Music for this project must be in the mp3 format and must be arranged in the following manner. All songs are sorted by album and are stored in folders with the artist and album title as the folder's name. These album folders are all stored in a single larger folder, usually called 'Music' or 'music'. There is generally a jpg image in each folder for the album's cover image. This file is called 'cover.jpg'. Song files that are simply dropped in the 'Music' folder without an album directory will not be recognized.

Further Notes

After installing tomcat8 I modified the 'context.xml' file in the 'META-INF' folder so that it reads antResourceLocking="true". I also created a folder called 'WEB-INF' next to the 'META-INF' folder, in the 'ROOT' folder. Also set allowLinking="true". The linking never worked for me.

Run the script before building the war with the script. This will place necessary tags in the war's context.xml file. You do not need to modify the global context.xml file for this. This also passes the music directory's location to the server by editing the web.xml file. The script uses 'sed' to accomplish this. For this and other reasons the project is meant to be developed on a linux platform.

The WEB-INF folder has a directory called 'classes' and in that a symbolic link in it to the target area for my IntelliJ project, where the class files are stored. Also in the 'WEB-INF' folder is the new 'web.xml' file.

I added a directory at /opt/acnn for storing files that otherwise would go into the user's home directory in a dot folder. I copied all the weight and bias files from the training home directory to the '/opt/acnn/' directory. I also changed the ownership of that dir to tomcat8 with a command like this:

$ cd /opt/acnn
$ sudo chown tomcat8:tomcat8 .
$ sudo chmod a+rw /opt/acnn/myfile* /opt/acnn/fp-test*

I am using the Apache maven-war-plugin in my pom.xml file and executing the command mvn package in the terminal to generate my war file. I also had to add special dependencies to my pom.xml file so that I could create a war file and ALSO create a desktop version with a working intellij gui form.

I installed activemq from the ubuntu repository. I made sure I had the libgeronimo-jms package when I did that. I had to setup 'instances-enabled' by typing the following:

$ cd /etc/activemq/instances-enabled
$ sudo ln -s ../instances-available/main . 

This copied the 'main' instance to the 'enabled' folder and after restarting activemq the demo programs worked.

I copied the mysql database layout with this command: mysqldump -u root -p --no-data acnn > acnn_setup.sql. I intend to use it with the command: mysql -u root -p acnn < acnn_setup.sql.

I am trying to copy the mysql jar to the $CATALINA_HOME/lib folder. This is because I get errors that the ContextListener cannot find that library. This is either '/usr/share/tomcat8/lib/' or '/var/lib/tomcat8/lib/', probably the latter. The jar version should be '5.1.27'.

I set the heap memory size to 4g. This involves including the command -Xmx4g in the file /usr/share/tomcat8/bin/ Somewhere in that file you must include the following line:


In this case the "$" is part of what you must include, not the prompt at the command line.

The web manager upload size must be changed. /user/share/tomcat8-admin/manager/WEB-INF/web.xml needs to have the following code:

  <!-- 52MB max -->

I added a zero to both numbers mentioned above.

Before building the project with ./ you will want to specify in the various xml files where your music collection is. You do this with the script. The commandline invocation would be as follows:

./ /path/to/Music/

If this does not work for you, mount the music directory at /mnt/acnn/Music/ by modifying your fstab file or using the 'mount' command. If you tried the shell script and it didn't work you may need to run it again with the directory '/mnt/acnn/Music/'.

Then you will want to build the desktop and server versions of the acnn project with the ./ script.

To build your neural network, run the command java -jar acnn-desktop.jar -train. You will be presented with a dialog that has options so that you can set different neural network options.