Skip to main content

Python Sequencer for Gamelan Music

Project description

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.

Demo

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

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

Output should be a simple musical piece.

python -m gamelan_sequencer javanese_gamelan.json 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.

Requirements

  1. Python 2.6 or greater (or any version of Python 3)
  2. scipy library (only if you use a gamelan with detuning): pip install scipy
  3. a samples JSON file: a listing of gamelan samples in JSON format
    • see javanese_gamelan.json for example
    • all sounds referenced by this JSON must be WAV format and have the same framerate / bits-per-sample / num-channels.
  4. a score JSON file: a score that utilizes said instruments, also in JSON format
    • see /scores folder for examples

Usage

From the Command Line

python gamelan.py [SAMPLES_FILE] [SCORE_FILE] --mixdown=MIXDOWN_FILE --separates=SEPARATES_FOLDER

  • SAMPLES_FILE: path to gamelan JSON file (described above)
  • SCORE_FILE: path to score JSON file (described above)
  • Either (or both) of the following parameters:
    • MIXDOWN_FILE: record to a single file
    • SEPARATES_FOLDER: record to a folder of multiple files

From the Python Environment

from gamelan_sequencer import Gamelan

gamelan = Gamelan(SAMPLES_FILE) 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.

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.

Score Format

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 alphanumberic 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 gamelan JSON file, and then use the mapping in your corresponding score JSON files.

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.

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

gamelan_sequencer-1.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gamelan_sequencer-1.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file gamelan_sequencer-1.1.0.tar.gz.

File metadata

  • Download URL: gamelan_sequencer-1.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for gamelan_sequencer-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2b6292bb3888d6b12b2a133ea4db5dc9779f604ba8ebf62fb937482776392bc8
MD5 14ce29c9424048ee55e58e2176c0d637
BLAKE2b-256 fed367127b51295825b357f402ac96d50b3599e3afa881323833851d7817f5e9

See more details on using hashes here.

File details

Details for the file gamelan_sequencer-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: gamelan_sequencer-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for gamelan_sequencer-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d126ef12c0d218a82f8597574961b66d61bae3a72ad60eadf4f1178ae02fd14
MD5 d8799784a30dd26a671f5d919e447cdf
BLAKE2b-256 4ca8b51b608e8a5f00739668362801d62a3c47de6814f6289df9f65a60048724

See more details on using hashes here.

Supported by

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