Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Music Generation AI

A neural network that learns musical structure from classical MIDI recordings and generates new note sequences in a similar style. Trained separately on works by Beethoven and Schubert.

How it works

  1. Parsing — MIDI files are read with music21, which extracts the notes and chords played by the piano part of each piece.
  2. Preprocessing — notes that appear fewer than 50 times across the corpus are dropped, and the remaining sequence is split into overlapping 32-timestep windows. Each unique note/chord is mapped to an integer ID.
  3. Model — a 1D dilated convolutional network (WaveNet-style): an embedding layer feeds three Conv1D layers with increasing dilation and filter counts (64 → 128 → 256), each followed by dropout and max-pooling, then a GlobalMaxPool1D, a dense layer, and a softmax output over the note vocabulary.
  4. Training — an 80/20 train/test split (scikit-learn), trained for 50 epochs with a ModelCheckpoint callback that saves the best model by validation loss.
  5. Generation — starting from a random sequence pulled from the validation set, the model predicts the next notes one at a time and the result is written back out as a standalone MIDI file (music.mid).

Tech stack

Python · TensorFlow/Keras · music21 · NumPy · scikit-learn · matplotlib

Running it

pip install tensorflow music21 numpy scikit-learn matplotlib musicalbeeps
python main.py

Place a folder of .mid files (e.g. Beethoven/) alongside main.py before running — the script trains on whatever MIDI corpus is in that directory and writes its output to music.mid.

Possible next steps

  • Add a script/notebook that plays back music.mid inline for anyone browsing the repo.
  • Report a validation loss curve or a few generated samples in this README so results are visible without running the code.

About

Dilated CNN trained on classical MIDI (Beethoven, Schubert) to generate new music

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages