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 renderheight(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:TitleM: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
- Clone the repository
- Install Python dependencies:
pip install -r requirements.txt - Install Node.js dependencies:
cd streamlit_abcjs_score/frontend && npm install
Building
- Build the frontend:
cd streamlit_abcjs_score/frontend && npm run build - Install the package:
pip install -e .
Testing
Run the example app:
streamlit run example.py
Next Steps
To complete the setup:
-
Install frontend dependencies:
cd streamlit_abcjs_score/frontend npm install
-
Build the frontend:
npm run build
-
Install the package locally:
pip install -e .
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d156924d984148be3faedb66edcc23f2df443f6ba0d9b8e2346a4b648751e341
|
|
| MD5 |
bc123b9eaaa3e1b884726ff656e0bc9b
|
|
| BLAKE2b-256 |
fbaee50acba0fa2a6685a063b3416d5a27ecad8bc14216baa2fdb2ab79300c70
|
File details
Details for the file streamlit_abcjs_score-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_abcjs_score-0.1.0-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33dc0e034d765beb4796287afdf2f7f60830c568d98416077ebbfb006a6f4d41
|
|
| MD5 |
60a0e6c4f54a03c559b57aa19a35d491
|
|
| BLAKE2b-256 |
1843a86d220e2bcb34f4874f4b2437b2965a7624a1eddde92881638abc679aaf
|