1.4.0 • Published 5 months ago

jzz-midi-gm v1.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 months ago

JZZ-midi-GM

npm npm build Coverage Status

General MIDI / GM2 / GS / XG instrument names: MIDI to string / string to MIDI

Install

npm install jzz-midi-gm
or yarn add jzz-midi-gm
or get the full development version and minified scripts from GitHub

Usage

Plain HTML
<script src="JZZ.js"></script>
<script src="JZZ.midi.GM.js"></script>
//...
CDN (jsdelivr)
<script src="https://cdn.jsdelivr.net/npm/jzz"></script>
<script src="https://cdn.jsdelivr.net/npm/jzz-midi-gm"></script>
//...
CDN (unpkg)
<script src="https://unpkg.com/jzz"></script>
<script src="https://unpkg.com/jzz-midi-gm"></script>
//...
CommonJS
var JZZ = require('jzz');
require('jzz-midi-gm')(JZZ);
//...
TypeScript / ES6
import { JZZ } from 'jzz';
import { GM } from 'jzz-midi-gm';
GM(JZZ);
//...
AMD
require(['JZZ', 'JZZ.midi.GM'], function(JZZ, gm) {
  // ...
});

API

MIDI to string

JZZ.MIDI.programName(midi) -
map MIDI program value to a General MIDI instrument name.

JZZ.MIDI.programName(midi, msb, lsb) -
map MIDI program value and bank msb/lsb to a GM2/GS/XG instrument name.

JZZ.MIDI.groupName(midi) -
map MIDI program value to a General MIDI group name.

JZZ.MIDI.percussionName(midi) -
map MIDI note value to General a MIDI percussion name.

console.log(JZZ.MIDI.programName(60));
// => 'French Horn'

console.log(JZZ.MIDI.programName(24, 0, 1));
// => 'Ukulele' (GM2)

console.log(JZZ.MIDI.groupName(60));
// => 'Brass'

console.log(JZZ.MIDI.percussionName(60));
// => 'Hi Bongo'

string to MIDI

JZZ.MIDI.programValue(str) -
map instrument name to a MIDI program (GM only); if there is no exact match, try the best guess.

JZZ.MIDI.noteValue(str) -
map percussion name to a MIDI note number; if there is no exact match, try the best guess.

JZZ.MIDI.guessValue(str) -
map program or percussion name (whatever matches best) to a MIDI value; if the return value is negative, it's the percussion note value with a minus sign, otherwise, it's the program value.

console.log(JZZ.MIDI.programName(JZZ.MIDI.programValue('piano')));
// => 'Acoustic Grand Piano'

console.log(JZZ.MIDI.percussionName(JZZ.MIDI.noteValue('snare')));
// => 'Acoustic Snare'

var n = JZZ.MIDI.guessValue('crash');
if (n < 0) console.log(JZZ.MIDI.percussionName(-n));
else console.log(JZZ.MIDI.programName(n));
// => 'Crash Cymbal 1'

list all instruments

allGM2() / allGS() / allXG() -
return a complete list of GM2/GS/XG programs as an array of of triplets [program-number, bank-msb, bank-lsb].

JZZ helpers

note(...) / noteOn(...) / noteOff(...) / aftertouch(...) / program(...) -
when the module is loaded, JZZ helper functions will understand the instrument names where appropriate.

JZZ().openMidiOut()
  .ch(0).program('accordion').noteOn('C#6', 100)
  .ch(9).noteOn('cowbell', 127);

Demo

https://jazz-soft.net/demo/GmGsXg.html

More information

Please visit https://jazz-soft.net for more information.

1.4.0

5 months ago

1.3.7

1 year ago

1.3.9

12 months ago

1.3.8

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago