Skip to main content

No project description provided

Project description

midigen

License PyPi GHA

Python library for generating simple chord progression midi files

demo

Installation

pip install midigen

Example usage

Command line

Play a ii-V-I-vi pattern in the key of G; loop it four times

midigen --key G --chords ii V I vi  --loop 4 --play

Python

from midigen.notes import Note
from midigen.keys import Key, Mode
from midigen.time import TimeSignature, Measure
from midigen.sequencer import Song, Track, open_output


port = open_output()

# play C minor scale
Key(Note.C, Mode.Minor).to_track().play(port)

# make a simple ii V I vi chord progression in the key of C
key = Key(Note.C, Mode.Major)
time_signature = TimeSignature(4, 4)
tempo = 90
progression = [2, 5, 1, 6]

chords = Track.from_measures([
    Measure.from_pattern(
        pattern=[
            key.relative_key(degree).chord(
                # default chords are the base triad - try adding extensions
                extensions=[7],
                # pick a voicing close to the root triad
                match_voicing=key.triad()
            )
        ] * time_signature.numerator,
        time_signature=time_signature,
        velocity=90
    )
    for degree in progression
])

# play to port
chords.play(port, tempo=tempo)

# write the song to a MIDI file
Song([chords]).to_midi('midigen.mid', tempo=tempo)

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

midigen-0.0.13.tar.gz (159.0 kB view details)

Uploaded Source

Built Distribution

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

midigen-0.0.13-py3-none-any.whl (157.5 kB view details)

Uploaded Python 3

File details

Details for the file midigen-0.0.13.tar.gz.

File metadata

  • Download URL: midigen-0.0.13.tar.gz
  • Upload date:
  • Size: 159.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for midigen-0.0.13.tar.gz
Algorithm Hash digest
SHA256 50fdbc39afd486c5dc20b78638bd7835e9f7d4880b87b66bec28a663cbc4ed0d
MD5 282f41ee766121bfa8d70d7049318ecc
BLAKE2b-256 e616191d23fa8161d6222ad4c7d541aba710c95a88f934a7fbfbed25ed0f838d

See more details on using hashes here.

Provenance

The following attestation bundles were made for midigen-0.0.13.tar.gz:

Publisher: publish.yml on dbjohnson/midigen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file midigen-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: midigen-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 157.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for midigen-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 81262d9e0a296c05592bb68ad6a1af2b1e39401df93e384b24f5d88a54d4b751
MD5 4c3aea31d06a59579b618b655f8f9cda
BLAKE2b-256 8b9e13a487d331d988c35fea451b7d98f190da66f32f0a2f22fbbf1e96850eda

See more details on using hashes here.

Provenance

The following attestation bundles were made for midigen-0.0.13-py3-none-any.whl:

Publisher: publish.yml on dbjohnson/midigen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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