npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@muse-player/core

v1.0.0

Published

Core components and hooks for MXL/MusicXML score rendering and playback

Downloads

206

Readme

@muse-player/core

npm version license

React components and hooks for MXL/MusicXML score rendering and MIDI playback.

Installation

pnpm add @muse-player/core react react-dom

@muse-player/core depends on @muse-player/instruments for piano samples, and pulls in tone and @tonejs/midi as runtime dependencies. React 18+ is a peer dependency.

Components

<ScoreRenderer>

Renders an SVG score page inside a scrollable container.

import { ScoreRenderer } from "@muse-player/core";

<ScoreRenderer containerRef={ref} svg={svgString} />

| Prop | Type | Description | |------|------|-------------| | containerRef | RefObject<HTMLDivElement> | Ref to the scrollable container (used by auto-scroll and note highlight) | | svg | string | SVG markup for the current page |

UI controls such as <PlaybackControls> have moved to @muse-player/component.

Hooks

useScore()

Loads pre-rendered score data from a manifest URL (produced by @muse-player/server or @muse-player/cli).

const {
  loadResult,       // (url: string) => void — load manifest.json
  svg,              // current page SVG string
  currentPage,      // current page number (1-based)
  totalPages,       // total page count
  renderPage,       // (page: number) => void — switch page
  midiBase64,       // base64-encoded MIDI data
  timeMap,          // TimeMapEntry[] for note synchronization
  scoreData,        // { title, totalPages }
  getElementsAtTime,// (ms) => { notes: string[], page: number }
  getElementAttr,   // (xmlId) => Record<string, string>
  loading,          // boolean
  error,            // string | null
} = useScore();

usePlayback(midiBase64, timeMap, onTimeUpdate?, onNotesUpdate?, instrument?)

MIDI playback engine powered by Tone.js. Parses base64 MIDI, schedules notes, tracks current time/measure/active notes.

const {
  play,             // () => Promise<void>
  pause,            // () => void
  stop,             // () => void
  seek,             // (seconds: number) => void
  seekToMeasure,    // (index: number) => void
  updateTempo,      // (bpm: number) => void
  playing,          // boolean
  currentTime,      // seconds
  totalDuration,    // seconds
  currentMeasure,   // 0-based measure index
  tempo,            // current BPM
} = usePlayback(midiBase64, timeMap, onTimeUpdate, onNotesUpdate, instrument);

usePianoSampler(options?)

Loads piano samples from @muse-player/instruments via Tone.js Sampler. Returns a stateful object.

const { ready, loading, error, sampler } = usePianoSampler({
  baseUrl: "/piano/", // optional — override sample URL base
});

// Pass sampler to usePlayback for realistic audio
usePlayback(midiBase64, timeMap, onTimeUpdate, onNotesUpdate,
  ready ? { sampler } : null
);

useAutoScroll(containerRef, currentMeasure, isPlaying)

Auto-scrolls the score container to follow playback. Pauses on manual scroll (5s cooldown).

const { autoScrollEnabled, setAutoScrollEnabled } = useAutoScroll(
  containerRef, currentMeasure, playing
);

useNoteHighlight(containerRef, activeNoteIds, getElementAttribute)

Draws colored highlight overlays on active notes. Right hand (staff 1) is blue, left hand (staff 2) is red.

useNoteHighlight(containerRef, activeNoteIds, getElementAttr);

Types

interface TimeMapEntry {
  tstamp: number;   // milliseconds
  qstamp: number;
  on?: string[];    // note XML IDs starting at this time
  off?: string[];   // note XML IDs ending at this time
  tempo?: number;
}

interface ScoreManifest {
  data: string;           // path to data.json
  pages: string[];        // paths to page SVGs
  scoreData: { title: string; totalPages: number };
}

interface ScoreDataFile {
  elementAttributes: ElementAttributes;
  midiBase64: string;
  timemap: TimeMapEntry[];
}

interface ScoreRenderResult {
  elementAttributes: ElementAttributes;
  midiBase64: string;
  scoreData: { title: string; totalPages: number };
  svgPages: string[];
  timemap: TimeMapEntry[];
}

Build

pnpm build

Built with Rslib (ESM, unbundled, DTS generation, React plugin).

Related Packages

| Package | Description | |---------|-------------| | @muse-player/component | UI components (PlaybackControls) styled with StyleX | | @muse-player/server | Node.js server-side MXL rendering via Verovio WASM | | @muse-player/cli | CLI tool for pre-rendering MXL files to static assets | | @muse-player/instruments | Piano sample manifests and audio files |

License

MIT