MusaDSL

A Ruby framework for algorithmic sound and musical thinking and composition

Open Source
LGPL 3.0 License
Free to use, modify & share
Musa-DSL code example

About MusaDSL

Musa-DSL is a domain-specific language based on Ruby designed for sonic and musical composition. It emphasizes the creation of complex temporal structures independently of the audio rendering engine, providing composers and developers with powerful tools for algorithmic composition, generative music, and musical notation.

The framework separates timing and compositional logic from sound production. Rather than coupling musical ideas to particular synthesizers or DAWs, Musa-DSL focuses on the deeper structures—sequences, rhythms, harmonic progressions, and formal compositional systems.

Who is it for?

  • Composers exploring algorithmic composition
  • Musicians interested in generative music systems
  • Developers building music applications
  • Researchers in computational musicology
  • Live coders and interactive music performers

MusaDSL in detail

MusaDSL separates compositional logic from audio rendering, letting you build complex musical structures independently of the devices used to play them.

The devices can be anything you can connect to via MIDI (Synths, DAWs, etc.), OSC (Max/MSP, SuperCollider, PD, etc.) or any other protocol you implement to connect to your sound generating artifacts.

This architecture supports the exploration of generative systems, algorithmic composition and live coding.

Key features

  • Advanced sequencer with microsecond precision for polyrhythmic and polytemporal structures, with multiple clock sources (internal, MIDI, external).
  • Generative tools: Markov chains, Variatio, Rules (L-systems), GenerativeGrammar and Darwin genetic algorithms.
  • Series: lazy iterators with functional operations (transform, filter, invert, combine, slice, repeat) and specialised generators (Fibonacci, harmonic series, constrained random).
  • 30+ scales and modes in 9 families (Greek modes, pentatonic, blues, symmetric, bebop, ethnic, melodic minor…) with equal-temperament and just-intonation support.
  • Chord system with quality, extensions, voicings and chord–scale navigation.
  • Datasets and Score: structured representation of musical events (scale grades, MIDI pitches, dynamics) with multi-voice organisation.
  • Neumalang — textual notation system with support for scale grades and ornaments.
  • Matrix operations for transforming sonic and musical structures.
  • Transcription to MIDI and score generation in MusicXML with ornament expansion.
  • Cross-platform MIDI communication for connecting to instruments and controllers.
  • Polyphonic MIDI voice management with automatic voice allocation.

Licensed under LGPL 3.0 or GPL 3.0, depending on the component.

Main Ecosystem Components

Core Framework

Musa-DSL

The core Ruby framework for algorithmic sound and musical composition. Features include: advanced sequencer with microsecond precision for polyrhythmic and polytemporal structures, multiple clock sources (internal, MIDI, external), generative tools (Markov chains, Variatio, Rules, GenerativeGrammar, Darwin genetic algorithms), Neumalang text-based notation system, transcription to MIDI and MusicXML with ornament expansion, and comprehensive scale/tuning support.

MIDI Libraries Suite

A comprehensive set of Ruby libraries for MIDI communication. This suite is based on Ari Russo's libraries with modifications and optimizations for use with Musa-DSL.

Library Function Repository Documentation API Docs
midi-events MIDI event representation and object-oriented message handling GitHub README API
midi-parser MIDI data parsing, converts raw bytes to event objects GitHub README API
midi-communications Cross-platform MIDI communication with instruments and control surfaces GitHub README API
midi-communications-macos Low-level MIDI interface for macOS (CoreMIDI) GitHub README API

Getting Started

Recommended Editor

RubyMine

RubyMine provides the best experience for MusaDSL development — intelligent autocomplete of methods and parameters, hover documentation, and type inference help you discover the API as you code.

Free licenses available:

Download on: jetbrains.com/ruby

Visual Studio Code

VSCode with the Ruby LSP extension also works well, though Ruby autocomplete and hover documentation are less complete than in RubyMine.

Download on: code.visualstudio.com

Framework Installation

Requirements: Ruby 3.4+

Install the core Musa-DSL gem:

gem install musa-dsl

Documentation

For detailed documentation, see the README and API docs of each project:

Project README API Docs
Musa-DSL README API
midi-events README API
midi-parser README API
midi-communications README API
midi-communications-macos README API

Demo Projects

A comprehensive collection of 22+ working examples demonstrating MusaDSL capabilities, from basic setup to advanced multi-phase compositions:

  • Basic concepts: Setup, series, neumas, canon
  • Generative tools: Markov, Variatio, Darwin, Grammar, Rules, Matrix
  • DAW integration: MIDI sync, live coding, clock modes
  • External protocols: OSC with SuperCollider and Max/MSP
  • Advanced patterns: Event architecture, parameter automation, multi-phase compositions

Each demo is a complete, runnable project with documentation explaining the concepts demonstrated.

musadsl-demo Repository

Author

MusaDSL is created and maintained by yeste.studio, exploring the intersection of sound, music, technology, and algorithmic composition.

LGPL 3.0 License

Source code on GitHub.