Skip to main content

Abstract MIDI pitches into keys, chords and notes.

Project description

midi_abstraction

Abstract midi pitches into keys, chords, and notes.

Installation

pip3 install midi_abstraction

Usage

#!/usr/bin/env python3
import random
import json
import midi_abstraction

if __name__ == '__main__':

	# get a list of all available keys.
	all_keys = midi_abstraction.list_key_names()
	print('list of all keys:')
	for option in all_keys:
		print(option)
	print()

	# get a key at random
	our_key = random.choice(all_keys)
	print(f'our_key: {our_key}')
	print()

	# Initialize the musical key object
	Song_key = midi_abstraction.Key(our_key)

	# Print all notes found in chords in the key, in the lowest octave.
	print(f'Song_key.notes_in_octave(0): {json.dumps(Song_key.notes_in_octave(0), indent = 4, sort_keys = True)}')
	print()

	# Print all chords in the key, in the lowest octave.
	print(f'Song_key.chords_in_octave(0): {json.dumps(Song_key.chords_in_octave(0), indent = 4, sort_keys = True)}')
	print()

	# Print key chords in all octaves.
	# print(f'Song_key.chords: {json.dumps(Song_key.chords, indent = 4, sort_keys = True)}')
	# or
	print(f'Song_key.chords_in_key(): {json.dumps(Song_key.chords_in_key(), indent = 4, sort_keys = True)}')


	# Print all notes in key, all octaves
	print(f'Song_key.notes_in_key(): {Song_key.notes_in_key()}')

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

midi-abstraction-0.8.6.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

midi_abstraction-0.8.6-py3-none-any.whl (15.9 kB view hashes)

Uploaded Python 3

Supported by

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