# trivedigaurav/tabla-js architecture

> Architecture diagram of the GitHub repository trivedigaurav/tabla-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/trivedigaurav/tabla-js
- Repository: https://github.com/trivedigaurav/tabla-js

## Overview

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`](https://github.com/trivedigaurav/tabla-js/blob/master/example.html) (Demo Page), [`js/play.js`](https://github.com/trivedigaurav/tabla-js/blob/master/js/play.js) (Playback Controller), [`js/tabla-mp3.js`](https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-mp3.js) (MP3 Sample Bank), [`js/tabla-ogg.js`](https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-ogg.js) (OGG Sample Bank)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Application"]
  node_page["Demo Page<br/>HTML entry point<br/>[example.html]"]
  node_controller["Playback Controller<br/>bol sequencing<br/>[play.js]"]
  node_midi{{"MIDI.js<br/>external audio engine"}}
  node_audio(("Browser Audio<br/>audio output"))
end

subgraph group_samples["Tabla Instrument Data"]
  node_mp3bank["MP3 Sample Bank<br/>instrument mapping<br/>[tabla-mp3.js]"]
  node_oggbank["OGG Sample Bank<br/>instrument mapping<br/>[tabla-ogg.js]"]
  node_notecontract["Tabla Note Range<br/>MIDI contract 21–42"]
end

node_page -->|"loads playback code"| node_controller
node_page -->|"loads runtime"| node_midi
node_page -.->|"loads compatible bank"| node_mp3bank
node_page -.->|"loads compatible bank"| node_oggbank
node_controller -->|"maps bols to notes"| node_notecontract
node_notecontract -->|"defines sample notes"| node_mp3bank
node_notecontract -->|"defines sample notes"| node_oggbank
node_controller -->|"schedules MIDI notes"| node_midi
node_mp3bank -->|"provides MP3 instrument"| node_midi
node_oggbank -->|"provides OGG instrument"| node_midi
node_midi -->|"renders tabla audio"| node_audio

click node_page "https://github.com/trivedigaurav/tabla-js/blob/master/example.html"
click node_controller "https://github.com/trivedigaurav/tabla-js/blob/master/js/play.js"
click node_mp3bank "https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-mp3.js"
click node_oggbank "https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-ogg.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_controller,node_midi,node_audio toneBlue
class node_mp3bank,node_oggbank,node_notecontract toneAmber
```

## Components

### Browser Application

Static client-side playback flow

- [Demo Page](https://github.com/trivedigaurav/tabla-js/blob/master/example.html): HTML entry point · Loads the UI and browser-side playback dependencies. · `example.html`
- [Playback Controller](https://github.com/trivedigaurav/tabla-js/blob/master/js/play.js): bol sequencing · Maps tabla bol notation to MIDI notes and schedules composition playback. · `js/play.js`
- **MIDI.js**: external audio engine · Browser MIDI/sample playback abstraction that resolves notes and schedules sound.
- **Browser Audio**: audio output · Browser audio capabilities render scheduled tabla sounds.

### Tabla Instrument Data

Codec-specific tabla sample mappings

- [MP3 Sample Bank](https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-mp3.js): instrument mapping · Repository-provided tabla samples and MIDI note mapping for MP3-capable browsers. · `js/tabla-mp3.js`
- [OGG Sample Bank](https://github.com/trivedigaurav/tabla-js/blob/master/js/tabla-ogg.js): instrument mapping · Alternative tabla samples and MIDI note mapping for OGG-capable browsers. · `js/tabla-ogg.js`
- **Tabla Note Range**: MIDI contract 21–42 · Shared mapping range for tabla articulations and silence between bol notation and sample banks.

## Connections

- 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
