Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedargrovestudios/circuitpython_midi_tools
A collection of CircuitPython methods for processing MIDI notes and Control Change codes.
https://github.com/cedargrovestudios/circuitpython_midi_tools
circuitpython circuitpython-community-bundle midi midi-converter
Last synced: 2 months ago
JSON representation
A collection of CircuitPython methods for processing MIDI notes and Control Change codes.
- Host: GitHub
- URL: https://github.com/cedargrovestudios/circuitpython_midi_tools
- Owner: CedarGroveStudios
- License: mit
- Created: 2022-10-29T04:45:20.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-16T05:38:50.000Z (over 1 year ago)
- Last Synced: 2023-09-16T14:25:20.888Z (over 1 year ago)
- Topics: circuitpython, circuitpython-community-bundle, midi, midi-converter
- Language: Python
- Homepage:
- Size: 430 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Introduction
============.. image:: https://img.shields.io/discord/327254708534116352.svg
:target: https://adafru.it/discord
:alt: Discord.. image:: https://github.com/CedarGroveStudios/CircuitPython_MIDI_Tools/workflows/Build%20CI/badge.svg
:target: https://github.com/CedarGroveStudios/CircuitPython_MIDI_Tools/actions
:alt: Build Status.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: BlackA CircuitPython method collection for processing MIDI notes and Control Change codes. It currently consists of seven
helpers for converting MIDI note values to and from frequency values and note name representations, and to provide
descriptions of MIDI Control Change (CC) controller codes.Dependencies
=============
This driver depends on:* `Adafruit CircuitPython `_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle `_
or individual libraries can be installed using
`circup `_.Installing to a Connected CircuitPython Device with Circup
==========================================================Make sure that you have ``circup`` installed in your Python environment.
Install it with the following command if necessary:.. code-block:: shell
pip3 install circup
With ``circup`` installed and your CircuitPython device connected use the
following command to install:.. code-block:: shell
circup install cedargrove_midi_tools
Or the following command to update an existing version:
.. code-block:: shell
circup update
Usage Example
=============``note_or_name(note)``
Bidirectionally translates a MIDI sequential note value to a note name
or a note name to a MIDI sequential note value. Note values are integers in
the range of 0 to 127 (inclusive). Note names are character strings
expressed in the format NoteOctave such as 'C4' or 'G#7'. Note names range
from 'C-1' (note value 0) to 'F#9' (note value 127). If the input value is
outside the note value or name range, the value of ``None`` is returned... code-block:: python
>>> from cedargrove_midi_tools import note_or_name
>>> note_or_name('G5')
79
>>> note_or_name(79)
'G5'``note_to_name(note)`` and ``name_to_note(name)``
Translates a MIDI sequential note value to a note name or note name to a note
value. Note values are integers in the range of 0 to 127 (inclusive).
Note names are strings expressed in the NoteOctave format, such as 'C4' or
'G#7'. Note names can range from 'C-1' (note value 0) to 'G9' (note value 127).
If the input value is outside the range, the value of ``None`` is returned... code-block:: python
>>> from cedargrove_midi_tools import note_to_name, name_to_note
>>> note_to_name(70)
'A#4'
>>> name_to_note('A#4')
70``note_to_frequency(note)`` and ``frequency_to_note(frequency)``
Translates a MIDI sequential note value to its corresponding frequency in
Hertz (Hz) or a frequency to a MIDI note value. Note values integers
in the range of 0 to 127 (inclusive). Frequency values are floating point.
If the input is outside of the range, the value ``None`` is returned.
Ref: MIDI Tuning Standard formula: https://en.wikipedia.org/wiki/MIDI_tuning_standard.. code-block:: python
>>> from cedargrove_midi_tools import note_to_frequency, frequency_to_note
>>> note_to_frequency(60)
261.625
>>> frequency_to_note(261.63)
60``frequency_to_note_cents(frequency)``
Translates a frequency in Hertz (Hz) to a MIDI sequential note value and
positive offset in cents. Frequency values are floating point. Note values
are integers in the range of 0 to 127 (inclusive). Cent values range from
0 to +100 cents. If the input frequency is less than the corresponding
frequency for note 0 or greater than note 127, the note value cannot be
determined and ``None`` is returned. Ref: MIDI Tuning Standard and cent
formulae:https://en.wikipedia.org/wiki/MIDI_tuning_standard
https://en.wikipedia.org/wiki/Cent_(music)
``cc_code_to_description(cc_code)``
Provides a controller description decoded from a Control Change controller code
value.
Ref: https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2.. code-block:: python
>>> from cedargrove_midi_tools import cc_code_to_description
>>> cc_code_to_description(24)
'Ctrl_24'
>>> cc_code_to_description(1)
'Modulation'Documentation
=============
API documentation for this library can be found `here `_.For information on building library documentation, please check out
`this guide `_.Contributing
============Contributions are welcome! Please read our `Code of Conduct
`_
before contributing to help this project stay welcoming.