Skip to main content

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:

  1. Select a musical key (C, C#/Db, D, etc.)
  2. Choose a genre
  3. 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:

  1. Chord Progression: Genre-specific chord progressions that form the harmonic foundation
  2. Melody: Intelligent melody generation that follows chord tones and scale degrees
  3. 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

  1. Clone the repository:
git clone https://github.com/JDCurry/midi-melody-generator.git
cd midi-melody-generator
  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midimelody-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midimelody-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file midimelody-0.1.0.tar.gz.

File metadata

  • Download URL: midimelody-0.1.0.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

Hashes for midimelody-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba09e9237b42aa32ee279afc0da828bcb2d6b864b0b9d937fa12b1515f83c1ce
MD5 47dd01c506ea3cc728b5c528a3349600
BLAKE2b-256 5fb109be8977a8b10693c727751b6b9cf305c3b8d2a2cfa6ada14a8ab464ffeb

See more details on using hashes here.

File details

Details for the file midimelody-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: midimelody-0.1.0-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

Hashes for midimelody-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55c71f59966a58b15412f0f842800ecccbd4840891ecbf231ea3e2d268854800
MD5 9df043c085a3fd9a0d9974e6e2ee0472
BLAKE2b-256 b94018bbfba1ba052bcaeb951f77454087d74f52ea541286f5c088d35c3adb73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page