Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

midifile-ts

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
100
decreased by-56.52%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 06 Oct 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc