Socket
Socket
Sign inDemoInstall

midifile-ts

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    midifile-ts

[![npm version](https://badge.fury.io/js/midifile-ts.svg)](https://badge.fury.io/js/midifile-ts) [![Actions Status](https://github.com/ryohey/midifile-ts/workflows/CI/badge.svg?branch=master)](https://github.com/ryohey/midifile-ts/actions) [![License: MIT


Version published
Maintainers
1
Install size
187 kB
Created

Readme

Source

npm version Actions Status License: MIT

midifile-ts

TypeScript MIDI file parser forked from jasmid https://github.com/gasman/jasmid

Installation

npm install midifile-ts --save

Usage

import { read } from "midifile-ts"

const midi = read(data) // { header, tracks }

Parse MIDI on node.js

import { read } from "midifile-ts"

const data = fs.readFileSync("song.mid")
const midi = read(data)

Parse MIDI on the browser

import { read, MidiFile } from "midifile-ts"

const changeFileInput = (
  input: HTMLInputElement,
  callback: (midi: MidiFile|null) => void
) => {
  if (input.files === null || input.files.length === 0) {
    return
  }

  const file = input.files[0]
  const reader = new FileReader()

  reader.onload = e => {
    if (e.target == null) {
      callback(null)
      return
    }
    const buf = e.target.result as ArrayBuffer
    const midi = read(buf)
    callback(midi)
  }

  reader.readAsArrayBuffer(file)
}

FAQs

Last updated on 19 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc