Giter Site home page Giter Site logo

carlosapedraza / midi-abstraction Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyberrumor/midi-abstraction

0.0 0.0 0.0 88 KB

Abstract midi pitches into keys, chords, and notes.

License: GNU General Public License v3.0

Python 98.82% Shell 1.18%

midi-abstraction's Introduction

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!

midi-abstraction's People

Contributors

cyberrumor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.