How trivedigaurav/tabla-js works
1. Project type and runtime
This is a small, static, browser-only proof of concept for sequencing and playing tabla compositions. There is no server application, build system, package manifest, database, or backend API in the repository. A browser loads example.html and executes the JavaScript directly.
2. Entry point: example.html
example.html is the runnable application shell and likely defines the demo UI plus script loading order. In an architecture diagram, it is the browser entry point that connects the user-facing page to the MIDI.js runtime, the tabla sample data, and the playback controller.
3. External playback engine: MIDI.js
The project is built around MIDI.js, an external browser audio/MIDI library. MIDI.js is the main audio abstraction boundary: application code expresses tabla strokes as MIDI note values, while MIDI.js resolves those notes into playable audio samples and schedules playback through browser audio capabilities.
4. Composition/playback controller: js/play.js
play.js is the application-specific orchestration layer. It contains mapBols, the important translation table from tabla bol notation—the textual names of strokes used in compositions—to MIDI note numbers. It is therefore the semantic boundary between Indian percussion notation and the generic MIDI/sample playback system.
5. Tabla notation-to-note flow
The central data flow is: a composition contains tabla bols; mapBols converts each bol into a MIDI note number; the playback logic submits those notes to MIDI.js; MIDI.js plays the corresponding tabla sample. Silence is also represented in the sample/note mapping, allowing rhythmic rests to be handled within the same sequence model.
6. Sample bank definition: js/tabla-mp3.js
tabla-mp3.js provides the tabla instrument/sample set in an MP3-compatible form. It is not composition logic; it is audio asset/configuration data that makes the MIDI note range usable as tabla sounds in browsers supporting MP3 playback.
7. Alternative sample bank definition: js/tabla-ogg.js
tabla-ogg.js provides the same functional instrument mapping with OGG audio data or references. Its role is browser codec compatibility rather than different musical behavior. The application can select or load the appropriate sample representation based on what the MIDI.js/browser environment supports.
8. Instrument mapping boundary
The sample banks map a constrained MIDI range to individual recorded tabla articulations. The README documents notes 21–42, from sounds such as Hi Vhoop, ge open, na, ta, and tin, through a silence entry. This note range is the contract shared by play.js and the sample-bank files.
9. Audio assets and provenance
The audio samples are derived from recordings by Pete Lockett, used with permission. They are part of the client-side playback dependency chain, not fetched from an application-owned media service according to the repository structure shown.
10. Primary execution sequence
At page load, the HTML page loads the playback dependencies and tabla soundfont/sample definition. After MIDI.js is ready, user interaction or demo initialization invokes code in play.js, which parses or iterates composition bols, maps them to notes, and schedules their audio playback.
11. Key architectural boundaries for a diagram
Draw four main browser-side nodes: example.html/UI, play.js composition and bol-mapping logic, MIDI.js as the external playback engine, and the MP3/OGG tabla sample-bank modules. The audio output is the browser’s audio subsystem. The only material external dependency is MIDI.js; the sample-bank modules are repository-provided instrument data.
12. Scope and limitations
This repository focuses narrowly on playback, not composition authoring, persistence, user accounts, synchronization, or server-side processing. Its architecture is intentionally lightweight: static files, in-browser sequencing, and sample-based audio rendering.
Main entry points: example.html Demo Page · play.js Playback Controller · tabla-mp3.js MP3 Sample Bank · tabla-ogg.js OGG Sample Bank
Components 7
Browser Application
Static client-side playback flow
- Demo Page · Loads the UI and browser-side playback dependencies.
example.html - Playback Controller · Maps tabla bol notation to MIDI notes and schedules composition playback.
js/play.js - MIDI.js · Browser MIDI/sample playback abstraction that resolves notes and schedules sound.
- Browser Audio · Browser audio capabilities render scheduled tabla sounds.
Tabla Instrument Data
Codec-specific tabla sample mappings
- MP3 Sample Bank · Repository-provided tabla samples and MIDI note mapping for MP3-capable browsers.
js/tabla-mp3.js - OGG Sample Bank · Alternative tabla samples and MIDI note mapping for OGG-capable browsers.
js/tabla-ogg.js - Tabla Note Range · Shared mapping range for tabla articulations and silence between bol notation and sample banks.
Connections 11
- Demo Page → Playback Controller: loads playback code
- Demo Page → MIDI.js: loads runtime
- Demo Page → MP3 Sample Bank: loads compatible bank
- Demo Page → OGG Sample Bank: loads compatible bank
- Playback Controller → Tabla Note Range: maps bols to notes
- Tabla Note Range → MP3 Sample Bank: defines sample notes
- Tabla Note Range → OGG Sample Bank: defines sample notes
- Playback Controller → MIDI.js: schedules MIDI notes
- MP3 Sample Bank → MIDI.js: provides MP3 instrument
- OGG Sample Bank → MIDI.js: provides OGG instrument
- MIDI.js → Browser Audio: renders tabla audio