swaralipi-js

swaralipi-js

A JSON spec, Unicode-Bengali viewer, and Tone.js player for Rabindrasangeet swaralipi (Tagore's আকারমাত্রিক notation). GPL-2.0-only, framework-agnostic.

Live demo →  Spec · Creator · GitHub

pnpm add @ugfoundation/swaralipi-js

Three building blocks

Spec

A Zod-validated JSON document. One note per cell; akarmatrik extensions; lossless.

Viewer

<swaralipi-sheet> — Unicode Bengali + CSS, shadow-DOM, embeddable.

Player

SwaralipiPlayer — piano/tabla/tanpura via Tone.js, synced highlight.

View

import { defineSwaralipiSheet } from '@ugfoundation/swaralipi-js/viewer';
defineSwaralipiSheet();

// <swaralipi-sheet src="/notation/4270.json" lang="bn"></swaralipi-sheet>

Pure SSR renderer too: renderToHtml(doc, { lang }) + SWARALIPI_CSS. Print/PDF via .print().

Play

import { SwaralipiPlayer } from '@ugfoundation/swaralipi-js/player';

const player = new SwaralipiPlayer();      // zero-config: samples from the project CDN
player.load(doc);
player.bindSheet(document.querySelector('swaralipi-sheet')); // highlight sync
playButton.onclick = () => player.play();  // needs a user gesture (AudioContext)

Embed

Drop a sheet + player into any page or iframe — the demo builds a copy-paste <iframe> snippet for you against the bare /embed route.

Subpath exports

/specschema, types, parseSwaralipi
/viewer<swaralipi-sheet>, renderToHtml, print
/playerSwaralipiPlayer + pure scheduler
/convertarchival HTML → JSON (Node-only)