Abstract MIDI pitches into keys, chords, modes, notes, and octaves.
Project description
midi_abstraction
Abstract midi pitches into keys, chords, modes, scales, and notes.
This, combined with a midi file creation package like 'mido', and maybe a little help from builtin 'random', is all you need to procedurally generate music.
Installation
pip install midi_abstraction
Usage
#!/usr/bin/env python3
import midi_abstraction
# create a key object. Note + either major or minor or modename
k = midi_abstraction.Key('d_dorian')
# available list methods
k.list_notes()
k.list_chords()
k.list_notes_in_octave(3)
k.list_notes_in_pentatonic_minor()
k.list_notes_in_pentatonic_major()
# available dict methods
k.chords_in_octave(3)
k.notes_in_pentatonic_minor()
k.notes_in_pentatonic_major()
# attributes
k.name
k.seniority
k.mode
k.chords
k.notes
### functions not tied to a class ###
# get the midi pitches of a specific note
midi_abstraction.notes('a')
# get midi pitch of a specific note in specific cotave
midi_abstraction.notes('cs')[4]
# get a list of all available notes
midi_abstraction.list_notes()
# get a list of major and minor keys (doesn't list modal keys)
midi_abstraction.list_keys()
# get a list of mode names
midi_abstraction.list_modes()
# if you need to iterate through note names and don't want to hit an out of range index, use universe:
midi_abstraction.universe()
# get the midi pitches of notes in a specific chord:
midi_abstraction.chords('c_major')
# you can also invent your own chords like this if you want to get weird.
midi_abstraction.chords('cs_e_ab')
#### examples of how to use ######
# get a random modal key and create an instance of it.
import random
n = random.choice(midi_abstraction.list_notes())
m = random.choice(midi_abstraction.list_keys())
k = midi_abstraction.Key(n + '_' + m)
# get some chords
first = k.list_chords()[0]
second = random.choice(k.list_chords())
third = random.choice(k.list_chords())
# you need mido to write midi files
import mido
# you can use a loop on [first, second, third] to push the pitches into mido tracks. Good luck!
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
midi-abstraction-1.0.2.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for midi_abstraction-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4efe6c4e1f9b467f058bfaf659828ad5e118febb328804838b66fd0abbb57a3b |
|
MD5 | 98cf1770d3f2c26c66ef46d750ed1ccc |
|
BLAKE2b-256 | a20b7ef8d0d11acea4c570d20402cb974f5876a709ce031b522f0daf5f60ac23 |