nsbradford / MusicVizML

Originally analyzing song structure, now just visualizing songs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MusicML / Viz

This project created a foundation for future work by WPI students in music information retrieval and machine learning. A Python system was first constructed to extract variable-length features from audio files. The problem of determining song structure was then approached with both supervised and unsupervised learning algorithms.

Mostly though, this is notable just producing some nice-looking visualizations of songs as a by-product of running K-means under certain conditions (here is "One" by Metallica):

Monster scatterplot

Installation

Optionally use virtualenv, and install requirements:

$ pip install requirements.txt

Usage

Demo, which loads up the song "One" and produces a visualization similar to the below:

$ python musicml.py -g

Full usage:

$ python musicml.py [-h] [-l] [-s {0,1,2,3,4,5,6,7,8,9,10,11}] [-a N_ART_GRAPHS]
                    [-p] [-g] [-c] [-e]

optional arguments:
  -h, --help            show this help message and exit
  -l, --is_all_songs    Run test on all songs.
  -s {0,1,2,3,4,5,6,7,8,9,10,11}, --song_index {0,1,2,3,4,5,6,7,8,9,10,11}
                        Index of the song in song_library.
  -a N_ART_GRAPHS, --n_art_graphs N_ART_GRAPHS
                        Number of output graphs.
  -p, --is_plot_data    Plot the raw data.
  -g, --is_not_graph    Do not graph output.
  -c, --is_cluster      Run clustering.
  -e, --is_elbow        Run elbow method for KMeans clustering.

Using your own song

  • Put your input .wav file in the /input folder (Warning: providing songs with COMPLETELY blank sections will mess with the numerical libraries)
  • Create a new instance of Song in library.py following the convention - the songs and verses are sets up tuples representing the start and end (in seconds) of a song verse or chorus.
  • Add a reference to your at index 0 in analyze.py's Analyst.song_library list
  • Run demo (defaults to picking the first song in the song_library)

Future Work

  • Refactor to run in a Jupyter notebook
  • Segment song and smooth to isolate Verse, Chorus sections (i.e. that way you don't have to manually specify choruses and verses in the configs)
  • Run anomaly detection before K-means to reduce outlier effects

The End Result

Workflow

The Processed Data

Monster scatterplot

Supervised Learning

K-nearest neighbor (K=5)

Monster scatterplot

Unsupervised Learning

K-means clustering algorithm:

K-means on Monster

About

Originally analyzing song structure, now just visualizing songs


Languages

Language:Python 100.0%