Skip to content

niusounds/miku.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7ee0084 · Mar 11, 2017

History

13 Commits
Mar 11, 2017
Aug 21, 2014
Mar 11, 2017
Mar 11, 2017
Nov 3, 2015
Aug 21, 2014
Mar 11, 2017
Mar 11, 2017
Mar 11, 2017
Nov 15, 2015
Mar 11, 2017
Mar 11, 2017
Mar 11, 2017
Mar 11, 2017
Mar 11, 2017

Repository files navigation

miku.js

JavaScript library for using NSX-39 with Web MIDI.

DEMO

How to use

// get instance
Miku.init()
  .then(miku => {
    // set lyrics
    miku.lyrics('こ', 'ん', 'に', 'ち', 'わ');

    // play
    miku.noteOn(69, 127, 0);

    // stop
    miku.noteOff(69, 0, 0);
  });

API

Set lyrics

Send MIDI message to set lyrics.

// Array of String
miku.lyrics(['あ', 'い', 'う', 'え', 'お']);

// Separated by space
miku.lyrics('あ い う え お');

// Separated by comma
miku.lyrics('こ,ん,に,ち,わ');

// unknown character is ignored
miku.lyrics('み t ddd く'); // Same as miku.lyrics('み く')

Play note

let noteNumber = 60;
let velocity   = 64;

miku.noteOn(noteNumber, velocity, 0);

...
// Some seconds after

miku.noteOff(noteNumber, velocity, 0);

Send other MIDI message

// bend value is 0 to 16384. Default value is 8192.
miku.pitchBend(4096);

// Modulation
miku.controlChange(1, 127);

Event listening

These events are also emitted from MIDI Input.

miku.on('noteOn', (noteNum, velocity) => {
  console.log('Note on', noteNum, velocity);
});

miku.on('noteOff', (noteNum, velocity) => {
  console.log('Note off', noteNum, velocity);
});

miku.on('pitchBend', (value) => {
  console.log('Pitch bend', value);
});

miku.on('sysEx', (dataArray) => {
  console.log('sys ex', dataArray);
});