A MIDI and music data manipulation library
Project description
S-Coda
Overview
S-Coda is a Python library for handling MIDI files. S-Coda supports a plethora of different MIDI manipulation operations, such as:
- quantisation of notes
- quantisation of note lengths
- splitting sequences into bars
- transposing of sequences
- creating piano-roll visualisations of pieces
- judging the difficulty of pieces
S-Coda was used in our project PAUL-2 to process MIDI files. For information about how to use S-Coda we refer to chapter 5 of the thesis in which S-Coda was introduced.
Installation
We recommend installing S-Coda from PyPI using pip:
pip install scoda
Changelog
See CHANGELOG.md
for a detailed changelog.
Usage
We refer to the aforementioned thesis for a more in-depth guide on how to use S-Coda. We provide a short listing on how to use basic S-Coda functions:
# Load sequence, choose correct track (often first track contains only meta messages)
sequence = Sequence.sequences_load(file_path=RESOURCE_BEETHOVEN)[1]
# Quantise the sequence to thirty-seconds and thirty-second triplets (standard values)
sequence.quantise_and_normalise()
# Split the sequence into bars based on the occurring time signatures
bars = Sequence.sequences_split_bars([sequence], meta_track_index=0)[0]
# Prepare tokeniser and output tokens
tokeniser = StandardNotelikeTokeniser(running_value=True, running_pitch=True, running_time_sig=True)
tokens = []
difficulties = []
# Tokenise all bars in the sequence and calculate their difficulties
for bar in bars:
tokens.extend(tokeniser.tokenise(bar.sequence))
difficulties.append(bar.sequence.difficulty())
# (Conduct ML operations on tokens)
tokens = tokens
# Create sequence from tokens
detokenised_sequence = tokeniser.detokenise(tokens)
# Save sequence
detokenised_sequence.save("out/generated_sequence.mid")
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
scoda-2.1b6.tar.gz
(39.6 kB
view hashes)
Built Distribution
scoda-2.1b6-py3-none-any.whl
(50.2 kB
view hashes)