Skip to main content

A Streamlit component for rendering ABC notation as musical scores using abc.js

Project description

Streamlit ABC.js Score Renderer

A Streamlit component for rendering ABC notation as beautiful sheet music using the abc.js library.

Features

  • 🎵 Real-time rendering of ABC notation as sheet music
  • 📱 Responsive design that adapts to container size
  • 🎛️ Customizable options (scale, dimensions, styling)
  • 🔧 Error handling with helpful error messages
  • 📚 Built-in examples for quick testing
  • 🎨 Theme support matching Streamlit's active theme

Installation

pip install streamlit-abcjs-score

Quick Start

import streamlit as st
from streamlit_abcjs_score import abc_score

# Simple example
notation = """T: Twinkle, Twinkle, Little Star
M: 4/4
L: 1/4
K: C
|: C C G G | A A G2 | F F E E | D D C2 :|"""

abc_score(notation=notation)

Usage

Basic Usage

from streamlit_abcjs_score import abc_score

# Render ABC notation
abc_score(
    notation="T: My Song\nM: 4/4\nL: 1/4\nK: C\nC D E F | G A B c |",
    height=400,
    scale=1.0
)

Advanced Usage

from streamlit_abcjs_score import abc_score, get_example_notation

# Use built-in examples
cooley_reel = get_example_notation("cooley_reel")
abc_score(
    notation=cooley_reel,
    height=500,
    scale=1.2,
    responsive=True,
    key="my_score"
)

Available Examples

from streamlit_abcjs_score import list_examples, get_example_notation

# List all available examples
examples = list_examples()
print(examples)  # ['twinkle_star', 'cooley_reel', 'mary_had_lamb']

# Get specific example
notation = get_example_notation("twinkle_star")

API Reference

abc_score(notation, height=400, width=None, scale=1.0, responsive=True, key=None)

Render ABC notation as sheet music.

Parameters:

  • notation (str): The ABC notation string to render
  • height (int, optional): Height of the container in pixels (default: 400)
  • width (int, optional): Width of the container in pixels (default: auto)
  • scale (float, optional): Scale factor for the rendered score (default: 1.0)
  • responsive (bool, optional): Whether to make the score responsive (default: True)
  • key (str, optional): Unique key for the component

get_example_notation(name)

Get example ABC notation by name.

Parameters:

  • name (str): Name of the example ("twinkle_star", "cooley_reel", "mary_had_lamb")

Returns:

  • str: The ABC notation string

list_examples()

List all available example names.

Returns:

  • list: List of available example names

ABC Notation Primer

ABC notation is a shorthand form of musical notation. Here are the basics:

  • T: Title
  • M: Meter (time signature, e.g., 4/4, 3/4)
  • L: Default note length (e.g., 1/4, 1/8)
  • K: Key signature (e.g., C, G, Am)
  • | Bar lines
  • Notes: A, B, C, D, E, F, G (lowercase for higher octave)
  • Rests: z
  • Accidentals: ^ (sharp), _ (flat), = (natural)

Example:

T: Mary Had a Little Lamb
M: 4/4
L: 1/4
K: C
E D C D | E E E2 | D D D2 | E G G2 |
E D C D | E E E2 | D D E D | C4 |

Development

Setup

  1. Clone the repository
  2. Install Python dependencies: pip install -r requirements.txt
  3. Install Node.js dependencies: cd streamlit_abcjs_score/frontend && npm install

Building

  1. Build the frontend: cd streamlit_abcjs_score/frontend && npm run build
  2. Install the package: pip install -e .

Testing

Run the example app:

streamlit run example.py

Next Steps

To complete the setup:

  1. Install frontend dependencies:

    cd streamlit_abcjs_score/frontend
    npm install
    
  2. Build the frontend:

    npm run build
    
  3. Install the package locally:

    pip install -e .
    
  4. Run the example:

    streamlit run example.py
    

Resources

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

streamlit_abcjs_score-0.1.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

streamlit_abcjs_score-0.1.0-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamlit_abcjs_score-0.1.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for streamlit_abcjs_score-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d156924d984148be3faedb66edcc23f2df443f6ba0d9b8e2346a4b648751e341
MD5 bc123b9eaaa3e1b884726ff656e0bc9b
BLAKE2b-256 fbaee50acba0fa2a6685a063b3416d5a27ecad8bc14216baa2fdb2ab79300c70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_abcjs_score-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33dc0e034d765beb4796287afdf2f7f60830c568d98416077ebbfb006a6f4d41
MD5 60a0e6c4f54a03c559b57aa19a35d491
BLAKE2b-256 1843a86d220e2bcb34f4874f4b2437b2965a7624a1eddde92881638abc679aaf

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