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

musicxml2json-drum

v0.1.7

Published

MusicXML to JSON for drum.

Readme

musicxml2json-drum

musicxml2json-drum 是一个用于将 MusicXML 格式的乐谱文件转换为 JSON 格式的工具,专为打击乐器(如鼓)乐谱的转换而设计。它可以帮助开发者将 MusicXML 数据转换成易于处理和操作的 JSON 格式,以便于进一步的分析、渲染或存储。

安装

你可以通过 npm 或 yarn 安装 musicxml2json-drum

npm install musicxml2json-drum

或者:

yarn add musicxml2json-drum

使用

基本用法

  1. 导入 musicxml2json-drum
import { parseMusicXML } from 'musicxml2json-drum';
  1. 使用 parseMusicXML 函数将 MusicXML 字符串转换为 JSON 数据:
const xmlStr = `<?xml version="1.0" encoding="UTF-8"?><musicxml>...</musicxml>`;

const jsonData = parseMusicXML(xmlStr);
console.log(jsonData);

配置选项

你可以传递配置参数来定制转换过程。可用的配置选项包括:

  • debug (可选): 如果设置为 true,将输出调试信息。
  • speed (可选): 用于指定音乐的速度,单位为每分钟拍数 (BPM)。
  • instrumentConfig (必填): 一个包含乐器配置信息的对象。
const config = {
  debug: true,
  speed: 120,
  instruments: {
    36: { code: 36, name: 'Kick', value: [36], index: 0 },
    37: { code: 37, name: 'Snare', value: [37], index: 1 },
    38: { code: 38, name: 'Snare', value: [38, 125], index: 2 },
    42: { code: 42, name: 'Hi-Hat', value: [22, 42], index: 3 }
  }
};

const jsonData = parseMusicXML(xmlStr, config);

可用函数

  • parseMusicXML(xmlStr: string, config: PropsType): MusicData: 解析 MusicXML 字符串并返回转换后的 JSON 数据。

获取乐器和音符数据

你可以通过提供的 API 获取指定乐器和音符的数据:

  • getMeasureById(id: string): 根据小节 ID 获取小节信息。
  • getNoteById(id: string): 根据音符 ID 获取音符信息。
const measure = parser.getMeasureById('M_1');
const note = parser.getNoteById('N_1_1');

文档

完整 API 文档

Demo

Demo

GitHub

GitHub 仓库

License

MIT