A deep learning system that generates original musical compositions by learning patterns from MIDI files using LSTM and GRU networks.
NeuralBeat parses a corpus of ~1,200 MIDI files, extracts pitch, duration, and offset events, and trains a custom 3-layer LSTM/GRU model to generate coherent 30-second musical sequences. The model learns temporal structure in music and can compose new pieces in a similar style.
- MIDI parsing: Extracts ~50K note events from 1,200+ MIDI files using the Music21 library
- Sequence modeling: 100-step input sequences fed into a 3-layer LSTM/GRU architecture (512 hidden units)
- Overfitting control: Tuned dropout (0.3) and batch size (64) to stabilize training
- Music generation: Outputs novel 30-second compositions as playable MIDI files
- Framework flexibility: Implemented in both TensorFlow/Keras and PyTorch
| Metric | Value |
|---|---|
| Training accuracy | ~91% |
| Epochs to convergence | 150 |
| Composition length | 30 seconds |
- Python
- TensorFlow / Keras — primary training framework
- PyTorch — alternative implementation
- Music21 — MIDI parsing and music representation
- NumPy — sequence construction
Input (100-step sequence)
↓
LSTM / GRU Layer 1 (512 units) + Dropout (0.3)
↓
LSTM / GRU Layer 2 (512 units) + Dropout (0.3)
↓
LSTM / GRU Layer 3 (512 units) + Dropout (0.3)
↓
Dense → Softmax (over note vocabulary)
↓
Output (predicted next note)
- MIDI files are parsed with Music21; pitch, duration, and offset are extracted per note event
- Events are mapped to integer tokens and structured into overlapping 100-step sequences
- A 3-layer LSTM/GRU network is trained to predict the next note given a sequence
- At generation time, a seed sequence is fed in and outputs are sampled autoregressively
- The output token sequence is converted back into a MIDI file
git clone https://github.com/<your-username>/neuralbeat-music-composer
cd neuralbeat-music-composer
pip install -r requirements.txt
# Train
python train.py --data_dir ./midi_data --epochs 150
# Generate
python generate.py --model checkpoints/best_model.h5 --length 30