Skip to main content

Gamelan Sequencer

Python Sequencer for Gamelan Music

Introduction

PROBLEM: Western scores and MIDI files aren't well suited for composing and playing pieces for a gamelan ensemble.

SOLUTION: Gamelan Sequencer uses a gamelan-friendly Kepatihan-inspired score format. When provided with instrument samples and a score, the provided Python script generates a recording of the music.

I was fortunate to find online samples of the UC Davis Gamelan Ensemble, recorded for ketuk-ketik.com by Elisa Hough, and with permission I'm using said samples to seed this system.

Installation

You can download this repository from GitHub, or grab it from PyPI:

$ pip install gamelan_sequencer

PyPI page is here: https://pypi.org/project/gamelan-sequencer/

Demo

Clone this repository and run the following (assuming you have Python installed):

[python -m] gamelan_sequencer scores/simple_score.json --mixdown=simple_score.wav

Output should be a simple musical piece.

[python -m] gamelan_sequencer scores/kotekan_sonatina.json --mixdown=kotekan_sonatina.wav

Output should sound something like this: https://youtu.be/6_ZQaYkq0q0

Note: The recording in the above video used the --separates option instead of --mixdown, which allowed me to make a custom mixdown from the individual tracks.

Get Involved

If you made a composition that you'd like to share, we'd be happy to add it to the "scores" folder.

If you made a recording with your composition, we'd be happy to feature it here as well.

Please raise any issues or suggestions for improvement!

Usage

Requirements

  • Python 2.6+ or any version of Python 3
  • Python packages: (only if you set detune_rate > 0) scipy
    • automatically installed if you use pip install below

From the Command Line

[python -m] gamelan_sequencer SCORE_FILE [--mixdown=MIXDOWN_FILE] [--separates=SEPARATES_FOLDER] [--samples=SAMPLES_FILE]

  • SCORE_FILE: path to a JSON-formatted score
    • see scores folder for examples
  • Either (or both) of the following parameters:
    • MIXDOWN_FILE: record to a single file
    • SEPARATES_FOLDER: record to a folder of multiple files
  • SAMPLES_FILE (optional): path to gamelan JSON file
    • defaults to provided javanese_gamelan.json
    • all sounds referenced by this JSON must be WAV format and have the same framerate / bits-per-sample / num-channels.

From the Python Environment

from gamelan_sequencer import Gamelan

gamelan = Gamelan()
score = gamelan.load_score(SCORE_FILE)
if score.load_errors == 0:
   score.write_mixdown(MIXDOWN_FILE)
   # and/or:
   score.write_separates(SEPARATES_FOLDER)

Output

Outputs will be WAV files with the same framerate / bits-per-sample / num-channels as your sample files.

If you provide a filename for --mixdown, the entire recording will be mixed down to a WAV file.

If you provide a folder path for --separates, you will get a separate WAV file for each unique instrument/name pair.

Score Format

See scores folder for examples.

Gamelan music has different variations of scale notations, but typically they're represented as numbers within an octave, with a dot above or below the number to represent a lower or higher octave, respectively.

For convenience I used alphanumeric values in the provided example:

                       .....
Kepatihan: 12356 12356 12356
           ·····

My format: 12356 ABCDE FGHIJ

You can specify any character mapping (even unicode) you choose in your samples JSON file, and then use the mapping in your corresponding score JSON files.

For example, in the default samples file javanese_gamelan.json we have these jenglong samples:

    "jenglong": { 
      "samples": {
      "1": "jenglong5lo.wav", 
      "2": "jenglong4.wav", 
      "3": "jenglong3.wav", 
      "5": "jenglong2.wav", 
      "6": "jenglong1.wav",
      "A": "jenglong5hi.wav"
      }
    }

And so, in our score we can reference these notes in a track like this:

{ "instrument": "jenglong", "notes": "5...6...A.6.5...6...A.6.5..." }

How Separates are split up

For example, if you have a sequence like this:

{ "instrument": "gong",                            "notes": "1..." },
{ "instrument": "bonang", "track_name": "polos",   "notes": "56.5" },
{ "instrument": "bonang", "track_name": "sangsih", "notes": "32.3" }

Then the notes will be recorded into the following files, respectively:

  • gong.wav
  • bonang_polos.wav
  • bonang_sangsih.wav

They will all be in sync, so you can drag them into an audio application of your choice for mixing.

License

Licensed under the MIT License.

NOTE: samples from ketuk-ketik.com are not covered by this license. Please refer to http://elisahough.com/sounds/sampler.html regarding those online samples.

Release files for gamelan-sequencer 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gamelan-sequencer 1.2.0
File Size Uploaded
gamelan_sequencer-1.2.0.tar.gz 12.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gamelan-sequencer 1.2.0
File Interpreter ABI Platform
gamelan_sequencer-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.7 kB

Release files / gamelan_sequencer-1.2.0.tar.gz

Download URL gamelan_sequencer-1.2.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
70218104161ea95fcf11812ede6c5043efbee227cdedd66c84b3a310d9a33cf9
BLAKE2b-256 checksum
How to use checksums
d48d7cce7636746b489d60853e4c4643359bea41ef89d0cbb7363a0da4bdc9da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.2.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

Release files / gamelan_sequencer-1.2.0-py3-none-any.whl

Download URL gamelan_sequencer-1.2.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80f5227eef7b5cbed37e61d4e041c560d2312b15723468429e814f03ded80801
BLAKE2b-256 checksum
How to use checksums
5a51c36eebfb39f5ba7b3ab4e4a5c667c8219b1d41c01cce24b4d65077ed795b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/60.2.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.9.0

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page