S1) BPscript

A Modern Language for the Bol Processor

Where does this article fit in?

This is the first article in the S series, dedicated to BPscript — a composition language that modernizes the writing of the Bol Processor (BP3, presented in I2). No technical prerequisites are necessary for this article: it presents the vision, not the syntax.


A Remarkable Formalism, Yet Demanding to Access

The Bol Processor possesses two rare formal properties. First, modular power: depending on the activated mechanisms, its grammar ranges from context-free (Type 2) to context-sensitive (Type 1), or even beyond — flags touch upon weakly context-sensitive, variables reach full context-sensitive (see B6). It’s a complexity slider, not a fixed class. Second, bidirectionality: it can generate music and recognize if a sequence belongs to a musical language (PROD/ANAL modes — see B8), a rare reversibility among musical systems (see L13).

Forty years of work by Bernard Bel and Jim Kippen — initially to model North Indian tabla improvisation — have given it weighted stochastic grammars (B3), native polymetry (B5), conditional flags (B4), master/slave patterns, seven derivation modes, and numerous performance control functions. TidalCycles cites it as an influence (M11).

This richness comes with two demands for anyone wanting to get started:

  • A dense syntax, inherited from forty years of enhancements, which takes time to master.
  • A C engine and a web interface stemming from a long history of development and porting.

The result: a rather high barrier to entry, so that few people ultimately benefit from a remarkable formalism that has remained difficult to access.


The Proposal: Preserve the Formalism, Modernize its Writing

BPscript does not replace BP3: it offers a modern way of writing it.

The idea can be summarized in one sentence:

BP3 knows when. BPscript makes it easier to read, typed, and executable in a browser.

Concretely: you write in a structured language, which is more direct to read, and the transpiler translates this code into native BP3 grammar. Bernard Bel’s derivation engine — is not reinvented: it is reused. And since it is ported to WebAssembly (execution format in the browser), it can be used without installation.

Here’s what a BPscript scene looks like:

 

@actor raga  alphabet:sargam  scale:sargam_22shruti  transport:webaudio

[phase==1] S -> { intro, motif }
[phase==2] S -> { developpement, motif } [phase=3]

intro        -> Sa _ Re Ga
developpement -> Sa Re Ga Pa Dha _ Ni Sa
motif        -> { Sa Pa, Ga Re }[speed:2]

 

Grammar rules (S ->, intro ->, etc.) are the structure that BP3 derives. The @actor line links an alphabet and a scale to an output. Flags ([phase==1], [phase=3]) condition and evolve the derivation.

The writing is more direct, typed, and compiles to the same formal power as BP3.


The Structure Sampler

To understand what BPscript brings, an analogy helps.

Paradigm What we “sample” Specificity
Magnetic tape sound, linearly we press Play, we wait for the end
Clip sampler loops, in a grid we launch, we combine, but the structure remains flat
BPscript grammars the structure is derived, conditioned, branched

The classic sampler cuts time into loops that are launched and combined. It’s powerful, but the structure remains flat — boxes stacked on top of each other.

BPscript allows sampling of structure. A raga (melodic form of Indian music) is not a melody: it is a set of derivation rules that generates melodies. A tabla pattern (Indian percussion, see I2) is not a loop: it is a grammar that produces variations.

BPscript does not sample sound. It samples structure.


Native Code When Needed

BPscript describes time — structure, durations, conditions. It does not seek to replace a synthesis engine. When concrete sound behavior is needed, native code is inserted between backticks:

 

`sc: SynthDef(\grain, { |freq, dens| GrainSin.ar(dens, freq) }).add`

 

BPscript does not seek to interpret this code: it entrusts it to the relevant runtime, at the right moment in the derivation. This is a language feature (detailed in S4).

Current status: backticks are evaluated in JavaScript and sound output is via Web Audio, in the downstream execution layer — the runtime, which consumes the timestamped sequence produced by the engine. The scope of BPscript itself is limited to the language + transpiler + BP3/WASM engine.


Where does BPscript come from?

BPscript relies entirely on the Bol Processor (BP3).

BP3 already knows how to:

  • Derive structures from weighted grammars (B3)
  • Superimpose temporal flows in polymetry (B5)
  • Condition rules with flags (B4)
  • Test whether a sequence belongs to the language (B8)
  • Learn rule weights through analysis (B8)

BPscript adds to this foundation, providing what facilitates interactive writing: an easier-to-read syntax, a type system adapted to live performance (gate / trigger / cv — see S3), an intercultural pitch system (six layers, from alphabet to Hz — S9), and the notion of actor to manage multiple instruments with different tunings (S3). BPscript is this layer: a language that compiles to the BP3 engine, ported to WebAssembly.


In a Sentence

The Bol Processor offers forty years of formal power whose access has remained demanding.

BPscript offers a more accessible way of writing it — more direct to read, typed, executable in a browser — serving the same formalism.


Key Takeaways

  1. BPscript is a composition language that compiles to BP3 grammar — it does not reinvent the derivation engine
  2. What it brings: making a rich formalism, which previously required time to master, more accessible
  3. BP3 knows when — BPscript makes it easier to read, typed, and executable in a browser via WebAssembly
  4. The structure sampler — we no longer sample sound but grammars that generate variations
  5. Native code between backticks — a language feature, evaluated by a downstream runtime (JS / Web Audio today)
  6. 40-year legacy — grammars with modular power (from context-free to context-sensitive and beyond) and bidirectional, stemming from Bernard Bel’s research
  7. The evolution — from the C engine ported to WASM to BPx, a new generation reactive engine

To Go Further

  • Bel, B. & Kippen, J. (1992) : “Modelling Music with Grammars: Formal Language Representation in the Bol Processor” — the foundational article of the Bol Processor. PDF Link
  • McLean, A. (2014) : “Making Programming Languages to Dance to: Live Coding with Tidal” — the origins of TidalCycles, influenced by Bel’s work. DOI:10.1145/2633638.2633647
  • bolprocessor.org : the official website of the Bol Processor — documentation, examples, source code

Glossary

  • Bol Processor (BP3) : a system of formal grammars for music, developed by Bernard Bel since 1989, initially for the North Indian tabla
  • Transpiler : a program that translates BPscript code into native BP3 grammar
  • Modular power : BP3 is not fixed to a Chomsky class — depending on the activated mechanisms, it ranges from context-free (Type 2) to context-sensitive (Type 1), or even beyond; see B6
  • Weakly context-sensitive : a class of languages more expressive than context-free grammars, but still parsable in polynomial time (TAG, CCG); BP3’s flags touch upon it, its variables exceed it; see L9
  • Bidirectional : capable of generating and recognizing; see L13
  • Backtick : the ` “ character used in BPscript to delimit native code intended for a runtime
  • Flag : a conditional variable that activates, deactivates, or evolves grammar rules according to its state
  • Polymetry : the superposition of temporal flows with potentially irrational duration ratios
  • Derivation : the process by which a grammar generates a sequence by successively applying its rules
  • Runtime : an execution environment that consumes the timestamped sequence produced by the engine (downstream layer)
  • WebAssembly (WASM) : a binary execution format that allows compiled code (here BP3, written in C) to run in a browser

Links in the Series

  • S2 (coming soon) — Three words and twenty-four symbols — the BPscript language in detail
  • I2 — Bol Processor: 40 years of innovation — the history of BP3
  • B3 — Derivation Rules — how BP3 generates sequences
  • B5 — Polymetry and temporal structures — the heart of BP3
  • M11 — TidalCycles and the Bel lineage — the BP3 → Tidal connection

Prerequisites : I2, B3
Reading time : 10 min
Tags : #BPscript #BP3 #bol-processor #live-coding #grammaires-formelles


Next article : S2 — Three words and twenty-four symbols


Back to index