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

smf-parser

v0.1.3

Published

smf parser

Downloads

9

Readme

SMF-Parser

SMF-Parser(Standard MIDI File Parser)は、MIDIファイルを解析して再生するためのTypeScriptライブラリです。

機能

  • パース: MIDIファイル(.mid)をバイナリデータとして読み込み、解析可能な形式に変換
  • 解析: MIDIデータを音符、テンポ、拍子などの音楽情報に変換
  • 再生: 解析されたMIDIデータをブラウザのWeb Audio APIを使用して再生

インストール

npmを使用してインストールできます:

npm install smf-parser

使用方法

MIDIファイルのパースと解析

import { parse, analyze } from 'smf-parser';

// ファイル選択イベントなどからFileオブジェクトを取得
const file = event.target.files[0];

// MIDIファイルをパースして解析
async function processMidiFile(file) {
  try {
    // ファイルをパース
    const smfBinary = await parse(file);
    
    // パースされたデータを解析
    const smfData = analyze(smfBinary);
    
    console.log('MIDI情報:', smfData);
    // smfDataには以下の情報が含まれます:
    // - header: フォーマット、トラック数、分解能
    // - tempos: テンポ情報の配列
    // - beats: 拍子情報の配列
    // - track: 16チャンネル分の音符情報
  } catch (error) {
    console.error('MIDIファイルの処理中にエラーが発生しました:', error);
  }
}

MIDIデータの再生

import { parse, analyze, SmfPlayer } from 'smf-parser';

async function playMidiFile(file) {
  try {
    // ファイルをパースして解析
    const smfBinary = await parse(file);
    const smfData = analyze(smfBinary);
    
    // プレイヤーを作成
    const player = new SmfPlayer(smfData);
    
    // 再生開始
    player.play();
    
    // 一時停止
    // player.pause();
    
    // 再開
    // player.resume();
    
    // 停止
    // player.stop();
  } catch (error) {
    console.error('MIDIファイルの再生中にエラーが発生しました:', error);
  }
}

API

parse(file: File): Promise<SmfBinary>

MIDIファイルをパースし、バイナリデータを返します。

analyze(smfBinary: SmfBinary): SmfData

パースされたバイナリデータを解析し、音楽情報を含むオブジェクトを返します。

SmfPlayer

MIDIデータを再生するためのクラス。

  • constructor(smfData: SmfData): プレイヤーを初期化
  • play(): 再生を開始
  • pause(): 再生を一時停止
  • resume(): 一時停止した再生を再開
  • stop(): 再生を停止

型定義

// SMFのバイナリデータ
type SmfBinary = {
  headerBinary: ArrayBuffer;
  trackBinarys: ArrayBuffer[];
}

// 解析されたSMFデータ
type SmfData = {
  header: Header;
  tempos: Tempo[];
  beats: Beat[];
  track: Notes[];
}

// その他の型定義は、ライブラリをインポートして参照してください

開発

前提条件

  • Node.js (v14以上)
  • npm (v6以上)

セットアップ

# リポジトリをクローン
git clone https://github.com/yourusername/smf-parser.git
cd smf-parser

# 依存関係をインストール
npm install

# ビルド
npm run build

# テスト
npm test