Skip to content

Repository files navigation

NeuralBeat: AI Music Composer

A deep learning system that generates original musical compositions by learning patterns from MIDI files using LSTM and GRU networks.

Overview

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.

Features

  • 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

Results

Metric Value
Training accuracy ~91%
Epochs to convergence 150
Composition length 30 seconds

Tech Stack

  • Python
  • TensorFlow / Keras — primary training framework
  • PyTorch — alternative implementation
  • Music21 — MIDI parsing and music representation
  • NumPy — sequence construction

Architecture

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)

How It Works

  1. MIDI files are parsed with Music21; pitch, duration, and offset are extracted per note event
  2. Events are mapped to integer tokens and structured into overlapping 100-step sequences
  3. A 3-layer LSTM/GRU network is trained to predict the next note given a sequence
  4. At generation time, a seed sequence is fed in and outputs are sampled autoregressively
  5. The output token sequence is converted back into a MIDI file

Usage

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages