Skip to main content

A MIDI and music data manipulation library

Project description

S-Coda

GitHub Release GitHub Actions Workflow Status Python Version

DOI DOI

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()

    # 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
    Sequence.save = lambda *args: None
    detokenised_sequence.save("out/generated_sequence.mid")

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

scoda-2.1b2.tar.gz (39.2 kB view hashes)

Uploaded Source

Built Distribution

scoda-2.1b2-py3-none-any.whl (49.3 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