midium-core
This package contains the core functions for the Midium Web MIDI API wrapper. It can be used to receive and send custom messages to your MIDI compatible hardware.
Midium;
Documentation
Function reference
Midium.ready(callback)
Once the MIDI API is done with setting up things, it will call the passed function. Midium is not working until the Web MIDI API finished loading.
Midium;
new Midium(query)
Returns with a Midium instance, which is basically a collection of MIDI ports. See the documentation of Midium.portQuery.
Midium;
Midium.portQuery(query)
Returns an array of MIDI ports. You can select them by specifying
- the manufacturer id of the MIDI device.
- the name of the MIDI device.
- the port id.
- an array of port ids.
/* Returns with all of the available ports. */Midium;/* Lists all the ports of devices which were manufactured by m-audio. */Midium;/* Lists all the ports of devices which were named as keystation. */Midium;/* Returns with the port 12345 */Midium;/* Returns with ports 12345 and 6789 */Midium;
Midium.prototype.send(message);
You can send a message to the selected ports by passing it to this function. You can pass it as an integer or as a byte array. Web MIDI API is working with byte arrays, so for the best performance it is recommended to use them instead of integers.
Midium;
Midium.prototype.addEventListener(message, mask, callback)
Registers an event listener. The event listener matches the message argument with the received MIDI messages. With the mask you can set exactly which bits you want to match. For example you can match only the most significant nibble with the 0xf00000 mask, or the last significant bit with 0x000001. 0xf00000 is useful when you want to listen to a specific MIDI event (like note on) on every channel.
var devices = '';/* Checks the most significant byte, calls back if it's 0xa0. */var reference = devices;
It is recommended to remove unused event listeners to keep the performance of Midium on maximum. See the documentation of removeEventListener.
Midium.prototype.removeEventListener(reference)
Removes the specified event listener.
var devices = '';var reference = devices;devices;
It is recommended to remove unused event listeners to keep the performance of Midium on maximum.
Utility functions
Midium.byteArrayToInt(byteArray)
Converts the given byte array to a 24 bit integer.
/* It returns 0xaabbcc */Midium;
Midium.intToByteArray(int)
Converts the given 24 bit integer to a byte array.
/* It returns [0xaa, 0xbb, 0xcc] */Midium;