Gathering detailed insights and metrics for jzz-midi-smf
Gathering detailed insights and metrics for jzz-midi-smf
Gathering detailed insights and metrics for jzz-midi-smf
Gathering detailed insights and metrics for jzz-midi-smf
npm install jzz-midi-smf
Typescript
Module System
Node Version
NPM Version
JavaScript (94.58%)
HTML (5.42%)
Total Downloads
51,611
Last Day
14
Last Week
69
Last Month
983
Last Year
10,885
MIT License
43 Stars
294 Commits
6 Forks
3 Watchers
1 Branches
2 Contributors
Updated on Apr 13, 2025
Minified
Minified + Gzipped
Latest Version
1.9.8
Package Id
jzz-midi-smf@1.9.8
Unpacked Size
64.81 kB
Size
14.57 kB
File Count
5
NPM Version
8.4.1
Node Version
20.12.1
Published on
Apr 16, 2025
Cumulative downloads
Total Downloads
Last Day
133.3%
14
Compared to previous day
Last Week
-58.7%
69
Compared to previous week
Last Month
38.3%
983
Compared to previous month
Last Year
18.1%
10,885
Compared to previous year
1
Standard MIDI Files: read / write / play
(MIDI 1.0 and MIDI 2.0)
npm install jzz-midi-smf --save
or yarn add jzz-midi-smf
or get the full development version and minified scripts from GitHub
1<script src="JZZ.js"></script> 2<script src="JZZ.midi.SMF.js"></script> 3//...
1<script src="https://cdn.jsdelivr.net/npm/jzz"></script> 2<script src="https://cdn.jsdelivr.net/npm/jzz-midi-smf"></script> 3//...
1<script src="https://unpkg.com/jzz"></script> 2<script src="https://unpkg.com/jzz-midi-smf"></script> 3//...
1var JZZ = require('jzz'); 2require('jzz-midi-smf')(JZZ); 3//...
1import { JZZ } from 'jzz'; 2import { SMF } from 'jzz-midi-smf'; 3SMF(JZZ); 4//...
1require(['JZZ', 'JZZ.midi.SMF'], function(JZZ, dummy) { 2 // ... 3});
Supported file formats: .mid
, .kar
, .rmi
Please check the API Reference !
1var midiout = JZZ().openMidiOut(); 2var data = require('fs').readFileSync('file.mid', 'binary'); 3// data can be String, Buffer, ArrayBuffer, Uint8Array or Int8Array 4var smf = new JZZ.MIDI.SMF(data); 5var player = smf.player(); 6player.connect(midiout); 7player.play(); 8//... 9player.speed(0.5); // play twice slower
1console.log(smf.toString());
1var warn = smf.validate(); 2if (warn) console.log(warn);
1var smf = new JZZ.MIDI.SMF(0, 96); // type 0, 96 ticks per quarter note 2var trk = new JZZ.MIDI.SMF.MTrk(); 3smf.push(trk); 4// add contents: 5trk.add(0, JZZ.MIDI.smfSeqName('This is a sequence name')) 6 .add(0, JZZ.MIDI.smfBPM(90)) // tempo 90 bpm 7 .add(96, JZZ.MIDI.noteOn(0, 'C6', 127)) 8 .add(96, JZZ.MIDI.noteOn(0, 'Eb6', 127)) 9 .add(96, JZZ.MIDI.noteOn(0, 'G6', 127)) 10 .add(192, JZZ.MIDI.noteOff(0, 'C6')) 11 .add(192, JZZ.MIDI.noteOff(0, 'Eb6')) 12 .add(192, JZZ.MIDI.noteOff(0, 'G6')) 13 .add(288, JZZ.MIDI.smfEndOfTrack()); 14// or an alternative way: 15trk.smfSeqName('This is a sequence name').smfBPM(90).tick(96) 16 .noteOn(0, 'C6', 127).noteOn(0, 'Eb6', 127).noteOn(0, 'G6', 127) 17 .tick(96).noteOff(0, 'C6').noteOff(0, 'Eb6').noteOff(0, 'G6') 18 .tick(96).smfEndOfTrack(); 19// or even shorter: 20trk.smfSeqName('This is a sequence name').smfBPM(90).tick(96) 21 .ch(0).note('C6', 127, 96).note('Eb6', 127, 96).note('G6', 127, 96) 22 .tick(192).smfEndOfTrack();
One easy thing to remember: SMF
is an Array
of Track
s and Track
is an Array
of MIDI events:
1for (var i = 0; i < smf.length; i++) { 2 for (var j = 0; j < smf[i].length; j++) { 3 console.log('track:', i, 'tick:', smf[i][j].tt, smf[i][j].toString()); 4 // or do whatever else with the message 5 } 6}
1for (var i = 0; i < smf.length; i++) { 2 if (smf[i] instanceof JZZ.MIDI.SMF.MTrk) { 3 for (var j = 0; j < smf[i].length; j++) { 4 var note = smf[i][j].getNote(); 5 if (typeof note != 'undefined') { 6 if (smf[i][j].getChannel() != 9) { // skip the percussion channel 7 smf[i][j].setNote(note + 12); // transpose one octave up 8 } 9 } 10 } 11 } 12}
1var player = smf.player(); 2var dump = smf.dump(); 3console.log('Type:', player.type()); 4console.log('Number of tracks:', player.tracks()); 5console.log('Size:', dump.length, 'bytes'); 6console.log('Duration:', player.duration(), 'ticks'); 7console.log('Total time:', player.durationMS(), 'milliseconds');
1require('fs').writeFileSync('out.mid', smf.dump(), 'binary');
1var data = require('fs').readFileSync('file.syx', 'binary'); 2var syx = new JZZ.MIDI.SYX(data); 3syx.send([0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7]); 4syx.sxMasterVolumeF(0.5); 5var player = syx.player(); 6player.connect(midiout); 7player.play(); 8require('fs').writeFileSync('out.syx', syx.dump(), 'binary');
1var midiout = JZZ().openMidiOut(); 2var data = require('fs').readFileSync('file.midi2', 'binary'); 3var clip = new JZZ.MIDI.Clip(data); 4var player = clip.player(); 5// since the majority of today's MIDI devices only support MIDI 1.0, 6// we can use a converter: 7var conv = JZZ.M2M1(); 8conv.connect(midiout); 9player.connect(conv); 10player.play();
1var clip = new JZZ.MIDI.Clip(); 2clip.gr(0).ch(0).noteOn('C5').tick(96).noteOff('C5'); 3require('fs').writeFileSync('out.midi2', clip.dump(), 'binary');
1var player = clip.player(); 2var dump = clip.dump(); 3console.log(clip.toString()); 4console.log('Size:', dump.length, 'bytes'); 5console.log('Duration:', player.duration(), 'ticks'); 6console.log('Total time:', player.durationMS(), 'milliseconds');
Read MIDI file - from file, URL, Base64
Write MIDI file - create MIDI file from scratch
MIDI Player - various ways to play MIDI file
Karaoke - playing MIDI files in .kar format
const fs = require('fs');
const JZZ = require('jzz');
require('jzz-midi-smf')(JZZ);
if (process.argv.length != 4) {
console.log('Usage: node ' + process.argv[1] + ' <input.mid> <output.mid>');
process.exit(1);
}
var old_midi = new JZZ.MIDI.SMF(fs.readFileSync(process.argv[2], 'binary'));
var new_midi = new JZZ.MIDI.SMF(old_midi); // copy all settings from the old file
new_midi.length = 0; // remove all tracks
for (var i = 0; i < old_midi.length; i++) {
var old_track = old_midi[i];
if (!(old_track instanceof JZZ.MIDI.SMF.MTrk)) continue;
var new_track = new JZZ.MIDI.SMF.MTrk();
new_midi.push(new_track);
for (var j = 0; j < old_track.length; j++) {
var old_msg = old_track[j];
var tick = old_msg.tt; // change it if you like, e.g. tick = old_msg.tt / 2;
if (true) { // add your own condition
new_track.add(tick, old_msg);
}
else if (false) { // add new messages or don't add anything
var new_msg = JZZ.MIDI.whatever(READ_THE_REFERENCE);
new_track.add(tick, new_msg);
}
}
}
fs.writeFileSync(process.argv[3], new_midi.dump(), 'binary');
Test MIDI Files - these may be useful if you write a MIDI application...
Please visit https://jazz-soft.net for more information.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
no SAST tool detected
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More