Skip to main content

Tablature-style DSL for rendering guitar, drums, and custom events into hyperscore.

Project description

hyperscore-tablature

hyperscore-tablature is a compact tablature-style DSL for rendering guitar, drums, chords, and custom events into hyperscore.

It provides a small notation layer on top of hyperscore so that musical patterns can be written as tab-like strings, while timing and event generation remain explicit through TimeSpan and Score.

The library is designed for quick sketches, algorithmic composition, and custom event workflows rather than score engraving or full tablature transcription.


Minimal example

This minimal example demonstrates the core workflow: define a token-to-event factory, write a tab-like pattern, and render it into a hyperscore Score.

from hyperscore.core import NoteEvent, Score, TimeSpan, bpm_to_ms

from hyperscore_tablature import TUNINGS, TabRenderer

guitar = TabRenderer(
    factory=lambda line_index, token, span: NoteEvent(
        pitch=TUNINGS["guitar6"][line_index] + int(token, 32),
        velocity=80,
        span=span,
        channel=0,
    )
)

tab = [
    "____ ____ ____ ____ | ____ ____ ____ ____",
    "____ ____ ____ ____ | ____ ____ ____ ____",
    "____ ____ ____ ____ | ____ 2___ 4___ 5___",
    "____ ____ 2___ 3___ | 5___ ____ ____ ____",
    "3___ 5___ ____ ____ | ____ ____ ____ ____",
    "____ ____ ____ ____ | ____ ____ ____ ____",
]

bpm = 120
bar_ms = int(bpm_to_ms(bpm, 4))

score = Score()
guitar.render(score, TimeSpan(0, bar_ms * 2), tab)

This example intentionally keeps the mapping from tab tokens to musical events explicit. hyperscore-tablature parses the notation and allocates time spans; the factory decides what each token means.


Tablature syntax

0(12)2 01(2a)(8s) | 0_(4a)3 2(14)10
  • One normal character is one token: 0, x, *, ., ...
  • Parenthesized text is one token: (12) becomes "12"
  • _ is a rest
  • - extends the previous event by this token's duration
  • / repeats the previous token
  • % as a whole bar repeats the previous bar
  • | separates equal-length bars
  • : separates additive bars; each bar gets duration proportional to its token count
  • Spaces and tabs outside parentheses are ignored

Reserved characters can be used as normal tokens by wrapping them:

(-)(_)(/)(:)(|)(%)

Multiple events per token

A factory may return either a single event or a sequence of events. This is useful for chords, layered drums, or unison parts.

from hyperscore.core import NoteEvent, Score, TimeSpan

from hyperscore_tablature import TabRenderer

def chord_factory(line_index: int, token: str, span: TimeSpan) -> list[NoteEvent]:
    root = int(token)
    return [
        NoteEvent(pitch=60 + root, velocity=80, span=span, channel=0),
        NoteEvent(pitch=64 + root, velocity=80, span=span, channel=0),
        NoteEvent(pitch=67 + root, velocity=80, span=span, channel=0),
    ]

chords = TabRenderer(factory=chord_factory)

score = Score()
chords.render(score, TimeSpan(0, 1000), ["0 5 7 3"])

Custom events

hyperscore-tablature is not limited to NoteEvent. The factory can return any event type that exposes a span: TimeSpan attribute.

from dataclasses import dataclass

from hyperscore.core import Score, TimeSpan

from hyperscore_tablature import TabRenderer

@dataclass(frozen=True, slots=True)
class UserDefinedEvent:
    span: TimeSpan
    value: int

renderer: TabRenderer[UserDefinedEvent] = TabRenderer(
    factory=lambda line_index, token, span: UserDefinedEvent(span, int(token))
)

score: Score[UserDefinedEvent] = Score()
renderer.render(score, TimeSpan(0, 1000), ["1 | 2 | 3 | 4"])

What this library demonstrates

  • Tab-like strings can be used as a compact front-end for hyperscore
  • Time is still represented explicitly using immutable TimeSpan objects
  • Token interpretation is fully controlled by user-defined factories
  • A single token may produce one event, multiple events, or no events
  • NoteEvent and user-defined event types can share the same notation layer

For more advanced usage, see:

  • examples/guitar.py
  • examples/drums.py
  • examples/acid.py
  • examples/chord_progression.py
  • examples/user_defined_event.py
  • tests/test_tablature.py

Project status

  • Python >= 3.10
  • Typed (py.typed)
  • Experimental / research-oriented
  • API may evolve between minor versions

hyperscore-tablature favors compact notation and explicit event generation over completeness or traditional tablature semantics.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperscore_tablature-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperscore_tablature-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file hyperscore_tablature-0.1.0.tar.gz.

File metadata

  • Download URL: hyperscore_tablature-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hyperscore_tablature-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3934534fc1bb8642124d228aa10378dd81ba6c34fd7888165e199b7cb663258d
MD5 b9079e1d28187b4d48cd35d68882f278
BLAKE2b-256 e58cfbbe2b727b9b13963aa150a661d1783cbf818e5e00a1d4beb8ae1279dc03

See more details on using hashes here.

File details

Details for the file hyperscore_tablature-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hyperscore_tablature-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hyperscore_tablature-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7caeaada01c22a77f54b2106aa75a96ba2368b08bf5c6a3450a0343ef5607034
MD5 327b88ee032888371e88da0fc5f07a5e
BLAKE2b-256 4e161dcd080cd29de034f76913510d652110e261d08965405f9f97ac0367e3d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page