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

Comparing version 1.0.3 to 1.1.0

19

dist/index.d.ts

@@ -145,12 +145,17 @@ /// <reference types="node" />

}
declare const _default: {
declare const MIDIChannelEvents: {
[key: string]: number;
};
declare const MIDIMetaEvents: {
[key: string]: number;
};
declare function serialize(e: AnyEvent, includeDeltaTime?: boolean): number[];
declare function write(tracks: AnyEvent[][], ticksPerBeat?: number): Uint8Array;
export { _default as MIDIChannelEvents };
export { _default as MIDIControlEventNames };
export { _default as MIDIControlEvents };
export { _default as MIDIMetaEventNames };
export { _default as MIDIMetaEvents };
export { read, MidiFile, MidiHeader, write, serialize, deserialize, StreamSource, Event, MetaEvent, SequenceNumberEvent, TextEvent, CopyrightNoticeEvent, TrackNameEvent, InstrumentNameEvent, LyricsEvent, MarkerEvent, CuePointEvent, ChannelPrefixEvent, PortPrefixEvent, EndOfTrackEvent, SetTempoEvent, SmpteOffsetEvent, TimeSignatureEvent, KeySignatureEvent, SequencerSpecificEvent, UnknownMetaEvent, ChannelEvent, NoteOffEvent, NoteOnEvent, NoteAftertouchEvent, ProgramChangeEvent, ChannelAftertouchEvent, PitchBendEvent, UnknownChannelEvent, ControllerEvent, SysExEvent, DividedSysExEvent, AnyEvent };
declare const MIDIControlEventNames: string[];
declare const MIDIControlEvents: {
[key: string]: number;
};
declare const MIDIMetaEventNames: {
[key: number]: string;
};
export { read, MidiFile, MidiHeader, write, serialize, deserialize, MIDIChannelEvents, MIDIControlEventNames, MIDIControlEvents, MIDIMetaEventNames, MIDIMetaEvents, StreamSource, Event, MetaEvent, SequenceNumberEvent, TextEvent, CopyrightNoticeEvent, TrackNameEvent, InstrumentNameEvent, LyricsEvent, MarkerEvent, CuePointEvent, ChannelPrefixEvent, PortPrefixEvent, EndOfTrackEvent, SetTempoEvent, SmpteOffsetEvent, TimeSignatureEvent, KeySignatureEvent, SequencerSpecificEvent, UnknownMetaEvent, ChannelEvent, NoteOffEvent, NoteOnEvent, NoteAftertouchEvent, ProgramChangeEvent, ChannelAftertouchEvent, PitchBendEvent, UnknownChannelEvent, ControllerEvent, SysExEvent, DividedSysExEvent, AnyEvent };

@@ -25,3 +25,3 @@ 'use strict';

else {
throw new Error("not supported type: " + (typeof buf));
throw new Error("not supported type: " + typeof buf);
}

@@ -693,75 +693,75 @@ }

var MIDIControlEventNames = {
"0": "Bank Select",
"1": "Modulation",
"2": "Breath Controller",
"4": "Foot Pedal",
"5": "Portamento Time",
"6": "Data Entry",
"7": "Volume",
"8": "Balance",
"10": "Pan",
"11": "Expression",
"12": "Effect Control 1",
"13": "Effect Control 2",
"14": "Undefined",
"15": "Undefined",
"16": "General Purpose Slider 1",
"17": "General Purpose Slider 2",
"18": "General Purpose Slider 3",
"19": "Knob 2 General Purpose Slider 4",
"20": "Knob 3",
"21": "Knob 4",
"32": "Bank Select",
"33": "Modulation Wheel",
"34": "Breath controller",
"36": "Foot Pedal",
"37": "Portamento Time",
"38": "Data Entry",
"39": "Volume",
"40": "Balance",
"42": "Pan position",
"43": "Expression",
"44": "Effect Control 1",
"45": "Effect Control 2",
"64": "Hold Pedal",
"65": "Portamento",
"66": "Sustenuto Pedal",
"67": "Soft Pedal",
"68": "Legato Pedal",
"69": "Hold 2 Pedal",
"70": "Sound Variation",
"71": "Resonance",
"72": "Sound Release Time",
"73": "Sound Attack Time",
"74": "Frequency Cutoff",
"75": "Sound Control 6",
"76": "Sound Control 7",
"77": "Sound Control 8",
"78": "Sound Control 9",
"79": "Sound Control 10",
"80": "Decay",
"81": "High Pass Filter Frequency",
"82": "General Purpose Button 3",
"83": "General Purpose Button 4",
"91": "Reverb Level",
"92": "Tremolo Level",
"93": "Chorus Level",
"94": "Detune",
"95": "Phaser Level",
"96": "Data Button Increment",
"97": "Data Button Decrement",
"98": "NRPN (LSB)",
"99": "NRPN (MSB)",
"100": "RPN (LSB)",
"101": "RPN (MSB)",
"120": "All Sound Off",
"121": "All Controllers Off",
"122": "Local Keyboard",
"123": "All Notes Off",
"124": "Omni Mode Off",
"125": "Omni Mode On",
"126": "Mono Operation",
"127": "Poly Operation"
};
var MIDIControlEventNames = [
"Bank Select",
"Modulation",
"Breath Controller",
"Foot Pedal",
"Portamento Time",
"Data Entry",
"Volume",
"Balance",
"Pan",
"Expression",
"Effect Control 1",
"Effect Control 2",
"Undefined",
"Undefined",
"General Purpose Slider 1",
"General Purpose Slider 2",
"General Purpose Slider 3",
"Knob 2 General Purpose Slider 4",
"Knob 3",
"Knob 4",
"Bank Select",
"Modulation Wheel",
"Breath controller",
"Foot Pedal",
"Portamento Time",
"Data Entry",
"Volume",
"Balance",
"Pan position",
"Expression",
"Effect Control 1",
"Effect Control 2",
"Hold Pedal",
"Portamento",
"Sustenuto Pedal",
"Soft Pedal",
"Legato Pedal",
"Hold 2 Pedal",
"Sound Variation",
"Resonance",
"Sound Release Time",
"Sound Attack Time",
"Frequency Cutoff",
"Sound Control 6",
"Sound Control 7",
"Sound Control 8",
"Sound Control 9",
"Sound Control 10",
"Decay",
"High Pass Filter Frequency",
"General Purpose Button 3",
"General Purpose Button 4",
"Reverb Level",
"Tremolo Level",
"Chorus Level",
"Detune",
"Phaser Level",
"Data Button Increment",
"Data Button Decrement",
"NRPN (LSB)",
"NRPN (MSB)",
"RPN (LSB)",
"RPN (MSB)",
"All Sound Off",
"All Controllers Off",
"Local Keyboard",
"All Notes Off",
"Omni Mode Off",
"Omni Mode On",
"Mono Operation",
"Poly Operation"
];

@@ -841,3 +841,3 @@ var MIDIControlEvents = {

MONO1: 0x7e,
MONO2: 0x7f,
MONO2: 0x7f
};

@@ -844,0 +844,0 @@

{
"name": "midifile-ts",
"version": "1.0.3",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,4 +0,4 @@

import toCharCodes from "./toCharCodes"
import { toCharCodes } from "./toCharCodes"
export default class Buffer {
export class Buffer {
private data: number[] = []

@@ -38,3 +38,3 @@ private position: number = 0

this.writeStr(id)
const chunkBuf = new Buffer()

@@ -41,0 +41,0 @@ func(chunkBuf)

@@ -1,2 +0,2 @@

export default {
export const MIDIChannelEvents: { [key: string]: number } = {
noteOff: 0x08,

@@ -9,2 +9,2 @@ noteOn: 0x09,

pitchBend: 0x0e
} as { [key: string]: number }
}

@@ -1,73 +0,73 @@

export default {
"0": "Bank Select",
"1": "Modulation",
"2": "Breath Controller",
"4": "Foot Pedal",
"5": "Portamento Time",
"6": "Data Entry",
"7": "Volume",
"8": "Balance",
"10": "Pan",
"11": "Expression",
"12": "Effect Control 1",
"13": "Effect Control 2",
"14": "Undefined",
"15": "Undefined",
"16": "General Purpose Slider 1",
"17": "General Purpose Slider 2",
"18": "General Purpose Slider 3",
"19": "Knob 2 General Purpose Slider 4",
"20": "Knob 3",
"21": "Knob 4",
"32": "Bank Select",
"33": "Modulation Wheel",
"34": "Breath controller",
"36": "Foot Pedal",
"37": "Portamento Time",
"38": "Data Entry",
"39": "Volume",
"40": "Balance",
"42": "Pan position",
"43": "Expression",
"44": "Effect Control 1",
"45": "Effect Control 2",
"64": "Hold Pedal",
"65": "Portamento",
"66": "Sustenuto Pedal",
"67": "Soft Pedal",
"68": "Legato Pedal",
"69": "Hold 2 Pedal",
"70": "Sound Variation",
"71": "Resonance",
"72": "Sound Release Time",
"73": "Sound Attack Time",
"74": "Frequency Cutoff",
"75": "Sound Control 6",
"76": "Sound Control 7",
"77": "Sound Control 8",
"78": "Sound Control 9",
"79": "Sound Control 10",
"80": "Decay",
"81": "High Pass Filter Frequency",
"82": "General Purpose Button 3",
"83": "General Purpose Button 4",
"91": "Reverb Level",
"92": "Tremolo Level",
"93": "Chorus Level",
"94": "Detune",
"95": "Phaser Level",
"96": "Data Button Increment",
"97": "Data Button Decrement",
"98": "NRPN (LSB)",
"99": "NRPN (MSB)",
"100": "RPN (LSB)",
"101": "RPN (MSB)",
"120": "All Sound Off",
"121": "All Controllers Off",
"122": "Local Keyboard",
"123": "All Notes Off",
"124": "Omni Mode Off",
"125": "Omni Mode On",
"126": "Mono Operation",
"127": "Poly Operation"
} as { [key: string]: string }
export const MIDIControlEventNames = [
"Bank Select",
"Modulation",
"Breath Controller",
"Foot Pedal",
"Portamento Time",
"Data Entry",
"Volume",
"Balance",
"Pan",
"Expression",
"Effect Control 1",
"Effect Control 2",
"Undefined",
"Undefined",
"General Purpose Slider 1",
"General Purpose Slider 2",
"General Purpose Slider 3",
"Knob 2 General Purpose Slider 4",
"Knob 3",
"Knob 4",
"Bank Select",
"Modulation Wheel",
"Breath controller",
"Foot Pedal",
"Portamento Time",
"Data Entry",
"Volume",
"Balance",
"Pan position",
"Expression",
"Effect Control 1",
"Effect Control 2",
"Hold Pedal",
"Portamento",
"Sustenuto Pedal",
"Soft Pedal",
"Legato Pedal",
"Hold 2 Pedal",
"Sound Variation",
"Resonance",
"Sound Release Time",
"Sound Attack Time",
"Frequency Cutoff",
"Sound Control 6",
"Sound Control 7",
"Sound Control 8",
"Sound Control 9",
"Sound Control 10",
"Decay",
"High Pass Filter Frequency",
"General Purpose Button 3",
"General Purpose Button 4",
"Reverb Level",
"Tremolo Level",
"Chorus Level",
"Detune",
"Phaser Level",
"Data Button Increment",
"Data Button Decrement",
"NRPN (LSB)",
"NRPN (MSB)",
"RPN (LSB)",
"RPN (MSB)",
"All Sound Off",
"All Controllers Off",
"Local Keyboard",
"All Notes Off",
"Omni Mode Off",
"Omni Mode On",
"Mono Operation",
"Poly Operation"
]

@@ -1,2 +0,2 @@

export default {
export const MIDIControlEvents: { [key: string]: number } = {
MSB_BANK: 0x00,

@@ -74,3 +74,3 @@ MSB_MODWHEEL: 0x01,

MONO1: 0x7e,
MONO2: 0x7f,
MONO2: 0x7f
}

@@ -1,2 +0,2 @@

export default {
export const MIDIMetaEventNames: { [key: number]: string } = {
0x00: "sequenceNumber",

@@ -3,0 +3,0 @@ 0x01: "text",

@@ -1,2 +0,2 @@

export default {
export const MIDIMetaEvents: { [key: string]: number } = {
sequenceNumber: 0x00,

@@ -18,2 +18,2 @@ text: 0x01,

sequencerSpecific: 0x7f
} as { [key: string]: number }
}

@@ -31,5 +31,5 @@ import {

} from "./event"
import Stream from "./stream"
import { Stream } from "./stream"
export default function deserialize(
export function deserialize(
stream: Stream,

@@ -36,0 +36,0 @@ lastEventTypeByte: number,

@@ -1,13 +0,11 @@

export { default as read, MidiFile, MidiHeader } from "./read"
export { default as write } from "./write"
export { default as serialize } from "./serialize"
export { default as deserialize } from "./deserialize"
export { default as MIDIChannelEvents } from "./constants/MIDIChannelEvents"
export {
default as MIDIControlEventNames
} from "./constants/MIDIControlEventNames"
export { default as MIDIControlEvents } from "./constants/MIDIControlEvents"
export { default as MIDIMetaEventNames } from "./constants/MIDIMetaEventNames"
export { default as MIDIMetaEvents } from "./constants/MIDIMetaEvents"
export { read, MidiFile, MidiHeader } from "./read"
export { write } from "./write"
export { serialize } from "./serialize"
export { deserialize } from "./deserialize"
export { MIDIChannelEvents } from "./constants/MIDIChannelEvents"
export { MIDIControlEventNames } from "./constants/MIDIControlEventNames"
export { MIDIControlEvents } from "./constants/MIDIControlEvents"
export { MIDIMetaEventNames } from "./constants/MIDIMetaEventNames"
export { MIDIMetaEvents } from "./constants/MIDIMetaEvents"
export { StreamSource } from "./stream"
export * from "./event"
import assert from "assert"
import read from "./read"
import { read } from "./read"
import fs from "fs"

@@ -4,0 +4,0 @@

import { AnyEvent } from "./event"
import Stream, { StreamSource } from "./stream"
import deserialize from "./deserialize"
import { Stream, StreamSource } from "./stream"
import { deserialize } from "./deserialize"
export interface MidiHeader {
formatType: number
trackCount: number
ticksPerBeat: number
formatType: number
trackCount: number
ticksPerBeat: number
}

@@ -20,3 +20,3 @@

*/
export default function read(data: StreamSource): MidiFile {
export function read(data: StreamSource): MidiFile {
function readChunk(stream: Stream) {

@@ -23,0 +23,0 @@ const id = stream.readStr(4)

import { toVLQ } from "./vlq"
import toCharCodes from "./toCharCodes"
import MIDIChannelEvents from "./constants/MIDIChannelEvents"
import MIDIMetaEvents from "./constants/MIDIMetaEvents"
import { toCharCodes } from "./toCharCodes"
import { MIDIChannelEvents } from "./constants/MIDIChannelEvents"
import { MIDIMetaEvents } from "./constants/MIDIMetaEvents"
import { AnyEvent } from "./event"
export default function serialize(e: AnyEvent, includeDeltaTime = true) {
export function serialize(e: AnyEvent, includeDeltaTime = true) {
const bytes: number[] = []

@@ -9,0 +9,0 @@

@@ -1,5 +0,10 @@

export type StreamSource = DataView | number[] | ArrayBuffer | Buffer | Uint8Array
export type StreamSource =
| DataView
| number[]
| ArrayBuffer
| Buffer
| Uint8Array
/* Wrapper for accessing strings through sequential reads */
export default class Stream {
export class Stream {
private buf: DataView

@@ -20,3 +25,3 @@ private position = 0

} else {
throw new Error("not supported type: " + (typeof buf))
throw new Error("not supported type: " + typeof buf)
}

@@ -23,0 +28,0 @@ }

@@ -1,2 +0,2 @@

export default function toCharCodes(str: string): number[] {
export function toCharCodes(str: string): number[] {
const bytes: number[] = []

@@ -3,0 +3,0 @@ for (let i = 0; i < str.length; i++) {

import assert from "assert"
import write from "./write"
import read from "./read"
import { write } from "./write"
import { read } from "./read"
import fs from "fs"

@@ -9,3 +9,10 @@

const bytes = write([], 480)
assert.equal(String.fromCharCode(...Array.from(bytes).slice(0, 4).map(e => (e))), "MThd")
assert.equal(
String.fromCharCode(
...Array.from(bytes)
.slice(0, 4)
.map(e => e)
),
"MThd"
)
})

@@ -12,0 +19,0 @@ it("read and write back", () => {

import { AnyEvent } from "./event"
import Buffer from "./buffer"
import serialize from "./serialize"
import { Buffer } from "./buffer"
import { serialize } from "./serialize"
//https://sites.google.com/site/yyagisite/material/smfspec#format
export default function write(tracks: AnyEvent[][], ticksPerBeat = 480) {
export function write(tracks: AnyEvent[][], ticksPerBeat = 480) {
const buf = new Buffer()

@@ -28,2 +28,1 @@

}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc