Code Monkey home page Code Monkey logo

midi-abstraction's Introduction

midi_abstraction

Abstract midi pitches into keys, chords, modes, scales, and notes.

Installation

# From pip
pip install midi_abstraction

# From source
pip3 install --user --break-system-packages .
  • requires python 3.10 or newer

Usage

#!/usr/bin/env python3
import midi_abstraction as mab

# Get a midi note from a letter
octave = 4
middle_c = mab.NOTES["c"][octave]

# Get a letter note from a midi pitch
some_note = None
for k, v in mab.NOTES.items():
    if 48 in v:
        some_note = k
        break

# Get a pitch for a drum
side_stick = mab.Drum.SIDE_STICK.value

# Get a drum from a pitch
some_drum = mab.Drum(35)

# List all drums
list(mab.Drum)

# List all chord names
list(mab.Chord)

# Get the note names that a chord is made of
c_major_notes = mab.CHORDS['c_major']


# Get the notes and chords from any mode/key.
# These are a list of sets due to enharmonic equivalence.
c_major_chords = mab.MAJOR.chords('c')
eb_phrygian_notes = mab.PHRYGIAN.notes('eb')

# Get chords from scale degrees
third_degree_chord = next(iter(mab.MAJOR.chords('c')[2]))

# Get the notes for a chord in a particular octave
octave = 4
middle_c_major_notes = []
for note in mab.CHORDS['c_major']:
    middle_c_major_notes.append(mab.NOTES[note][octave])

midi-abstraction's People

Contributors

cyberrumor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.