A MIDI melody generator supporting multiple musical genres
Project description
Musical MIDI Generator
A Python-based MIDI melody generator that creates musical compositions across different genres with sophisticated chord progressions, melodic patterns, and basslines.
Features
- Multiple genre support including:
- Pop/Rock
- Jazz
- Blues
- Latin
- Folk/Acoustic
- Electronic
- Epic/Film Score
- R&B/Soul
- Intelligent chord progression generation based on genre
- Dynamic melody creation with genre-specific patterns
- Accompanying bassline generation
- Support for different musical keys
- Multi-track MIDI output (melody, chords, and bass)
- Genre-appropriate rhythmic patterns
- Verse and chorus section generation
Installation
You can install this package in two ways:
1. Using pip (Recommended)
pip install --index-url https://maven.pkg.github.com/JDCurry/midi-melody-generator/ midimelody
2. From source
git clone https://github.com/JDCurry/midi-melody-generator.git
cd midi-melody-generator
pip install -e .
Usage
As a Python Package
from midimelody import generate_midi
# Generate a new MIDI composition
generate_midi()
From Command Line
If installed from source, you can run directly:
python melody_generator.py
Follow the interactive prompts to:
- Select a musical key (C, C#/Db, D, etc.)
- Choose a genre
- The program will generate a MIDI file with a unique name in your current directory
How It Works
The generator creates music in three layers:
- Chord Progression: Genre-specific chord progressions that form the harmonic foundation
- Melody: Intelligent melody generation that follows chord tones and scale degrees
- Bassline: Complementary bass patterns that match the genre and harmony
Each genre has its own characteristics:
- Pop/Rock: Standard chord progressions with catchy melodic patterns
- Jazz: Sophisticated harmony with extended chords
- Blues: Traditional 12-bar patterns with blue notes
- Latin: Syncopated rhythms and specific harmonic movements
- Folk: Simple, traditional progressions
- Electronic: Modern, repetitive patterns
- Epic/Film Score: Dramatic progressions and wide melodic ranges
- R&B/Soul: Soulful progressions with rhythmic emphasis
Development
Setting up for development
- Clone the repository:
git clone https://github.com/JDCurry/midi-melody-generator.git
cd midi-melody-generator
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e ".[dev]"
Running Tests
python -m unittest tests/test_generator.py
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Areas for Improvement
- Additional genres and sub-genres
- More sophisticated rhythm generation
- User interface improvements
- Additional instrument tracks
- Custom tempo support
- Scale mode options (minor, dorian, etc.)
- MIDI file naming conventions
- Export options for different file formats
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built using the Mido library for MIDI file handling
- Inspired by music theory and common chord progressions across different genres
LICENSE
MIT License
Copyright (c) 2025 JD Curry
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.gitignore
Python
pycache/ *.py[cod] *$py.class *.so .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg
Generated MIDI files
*.mid
Virtual Environment
venv/ ENV/
IDE
.idea/ .vscode/ *.swp *.swo
OS
.DS_Store Thumbs.db
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midimelody-0.1.1.tar.gz.
File metadata
- Download URL: midimelody-0.1.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3ea5f61bf4fcd4ab8009056b91e92c127075b9200459ac178d47a5f377a9fe2
|
|
| MD5 |
0061249083faf0cf0566c1a091d227f5
|
|
| BLAKE2b-256 |
0d914e96c7a8de4829b05cba5244e757d136a9992c9685265bb955f8912b5eed
|
File details
Details for the file midimelody-0.1.1-py3-none-any.whl.
File metadata
- Download URL: midimelody-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce7019dcf9649c364aa43ee9eff8fe4aa5a4acc626a33609ca7bdd4e4e0ae3c2
|
|
| MD5 |
91517390e467ab91cd2f3044466d52c0
|
|
| BLAKE2b-256 |
2a1b187516841ca8bb4eff20e19a00aa31319bc974ad1a73306cd56a4e7e525e
|