Comparing version 0.9.5 to 1.0.0
# node-midi Changelog | ||
## Version 1.0.0 | ||
* Added isPortOpen (nroadley) | ||
* Improve examples in README (Simon Egersand) | ||
* Updated examples to es6 (Amila Welihinda) | ||
* Update mocha (The Repo Nanny) | ||
* Update rtmidi to 4.0.0 (Tim Susa) | ||
* Add license to package.json. | ||
* Use NAN to handle additional differences in modern nodejs versions. | ||
* Change supported nodejs version to 6, 8, 10, 12. | ||
* Better handling of Buffer for stream (jhorology) | ||
* Fixing read stream resume bug (justinjmoses) | ||
* Fix clean up of inputs. | ||
* Exception catching to prevent RtMidi errors crashing the node process (Jeremy Bernstein) | ||
* Split classes into different files. | ||
* Fix capitalisation on the classes. | ||
* Add some documentation about MIDI message formats. | ||
## Version 0.9.5 | ||
* Updated RtMidi to most recent version (Szymon Kaliski) | ||
* Updating NAN to the latest version. This allows node 6.2.0 to be used. (Michael Lawrence) | ||
## Version 0.9.4 | ||
* Upgrade to nan v2.0 (Julián Duque) | ||
* Call cancelCallback when closing port (Szymon Kaliski) | ||
## Version 0.9.3 | ||
@@ -4,0 +32,0 @@ |
16
midi.js
@@ -6,8 +6,12 @@ var midi = require('bindings')('midi'); | ||
var EventEmitter = require('events').EventEmitter; | ||
midi.input.prototype.__proto__ = EventEmitter.prototype; | ||
midi.Input.prototype.__proto__ = EventEmitter.prototype; | ||
// Backwards compatibility. | ||
midi.input = midi.Input; | ||
midi.output = midi.Output; | ||
module.exports = midi; | ||
midi.createReadStream = function(input) { | ||
input = input || new midi.input(); | ||
input = input || new midi.Input(); | ||
var stream = new Stream(); | ||
@@ -20,3 +24,3 @@ stream.readable = true; | ||
var packet = new Buffer(message); | ||
var packet = new Buffer.from(message); | ||
@@ -36,3 +40,3 @@ if (!stream.paused) { | ||
stream.paused = false; | ||
while (stream.queue.length && stream.write(queue.shift())) {} | ||
while (stream.queue.length && stream.emit('data', stream.queue.shift())) {} | ||
}; | ||
@@ -45,3 +49,3 @@ | ||
midi.createWriteStream = function(output) { | ||
output = output || new midi.output(); | ||
output = output || new midi.Output(); | ||
var stream = new Stream(); | ||
@@ -55,3 +59,3 @@ stream.writable = true; | ||
if (Buffer.isBuffer(d)) { | ||
d = [d[0], d[1], d[2]]; | ||
d = Array.prototype.slice.call(d, 0); | ||
} | ||
@@ -58,0 +62,0 @@ |
{ | ||
"name": "midi", | ||
"version": "0.9.5", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"test": "mocha test/unit-tests.js && node test/virtual-loopback-test-automated.js" | ||
"test": "mocha test/unit/*.js && node test/virtual-loopback-test-automated.js" | ||
}, | ||
@@ -35,2 +35,3 @@ "main": "midi.js", | ||
], | ||
"license": "MIT", | ||
"engines": { | ||
@@ -40,7 +41,7 @@ "node": ">=0.8.0" | ||
"dependencies": { | ||
"bindings": "~1.2.1", | ||
"bindings": "~1.5.0", | ||
"nan": "^2.3.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": ">= 2.1.0", | ||
"mocha": "^6.1.4", | ||
"should": ">= 5.0.1" | ||
@@ -47,0 +48,0 @@ }, |
@@ -35,20 +35,28 @@ ♪ ♫ ♩ ♬ | ||
From npm: | ||
```bash | ||
$ npm install midi | ||
``` | ||
$ npm install midi | ||
From source: | ||
```bash | ||
$ git clone https://github.com/justinlatimer/node-midi.git | ||
$ cd node-midi/ | ||
$ npm install | ||
``` | ||
$ git clone https://github.com/justinlatimer/node-midi.git | ||
$ cd node-midi/ | ||
$ npm install | ||
## Usage | ||
### MIDI Messages | ||
This library deals with MIDI messages as JS Arrays for both input and output. For example, `[144,69,127]` is MIDI message with status code 144 which means "Note on" on "Channel 1". | ||
For list of midi status codes, see http://www.midi.org/techspecs/midimessages.php | ||
### Input | ||
```js | ||
var midi = require('midi'); | ||
const midi = require('midi'); | ||
// Set up a new input. | ||
var input = new midi.input(); | ||
const input = new midi.Input(); | ||
@@ -62,3 +70,3 @@ // Count the available input ports. | ||
// Configure a callback. | ||
input.on('message', function(deltaTime, message) { | ||
input.on('message', (deltaTime, message) => { | ||
// The message is an array of numbers corresponding to the MIDI bytes: | ||
@@ -68,3 +76,3 @@ // [status, data1, data2] | ||
// information interpreting the messages. | ||
console.log('m:' + message + ' d:' + deltaTime); | ||
console.log(`m: ${message} d: ${deltaTime}`); | ||
}); | ||
@@ -87,3 +95,5 @@ | ||
// Close the port when done. | ||
input.closePort(); | ||
setTimeout(function() { | ||
input.closePort(); | ||
}, 100000); | ||
``` | ||
@@ -94,6 +104,6 @@ | ||
```js | ||
var midi = require('midi'); | ||
const midi = require('midi'); | ||
// Set up a new output. | ||
var output = new midi.output(); | ||
const output = new midi.Output(); | ||
@@ -124,10 +134,10 @@ // Count the available output ports. | ||
```js | ||
var midi = require('midi'); | ||
const midi = require('midi'); | ||
// Set up a new input. | ||
var input = new midi.input(); | ||
const input = new midi.Input(); | ||
// Configure a callback. | ||
input.on('message', function(deltaTime, message) { | ||
console.log('m:' + message + ' d:' + deltaTime); | ||
input.on('message', (deltaTime, message) => { | ||
console.log(`m: ${message} d: ${deltaTime}`); | ||
}); | ||
@@ -157,9 +167,9 @@ | ||
// create a readable stream | ||
var stream1 = midi.createReadStream(); | ||
const stream1 = midi.createReadStream(); | ||
// createReadStream also accepts an optional `input` param | ||
var input = new midi.input(); | ||
const input = new midi.Input(); | ||
input.openVirtualPort('hello world'); | ||
var stream2 = midi.createReadStream(input) | ||
const stream2 = midi.createReadStream(input) | ||
@@ -173,9 +183,9 @@ stream2.pipe(require('fs').createWriteStream('something.bin')); | ||
// create a writable stream | ||
var stream1 = midi.createWriteStream(); | ||
const stream1 = midi.createWriteStream(); | ||
// createWriteStream also accepts an optional `output` param | ||
var output = new midi.output(); | ||
const output = new midi.Output(); | ||
output.openVirtualPort('hello again'); | ||
var stream2 = midi.createWriteStream(output); | ||
const stream2 = midi.createWriteStream(output); | ||
@@ -182,0 +192,0 @@ require('fs').createReadStream('something.bin').pipe(stream2); |
@@ -18,9 +18,18 @@ /*! \mainpage The RtMidi Tutorial | ||
\section whatsnew What's New (Version 2.1.1) | ||
\section whatsnew What's New (Version 4.0.0) | ||
There were no API changes made in the current release. The primary changes involved updates to the build system and some small bug fixes. With respect to the previous release (2.1.0), a minor API change was made. The RtError class was renamed RtMidiError and embedded directly in RtMidi.h. Thus, all references to RtError should be renamed to RtMidiError and the RtError.h file should be deleted. The Windows Kernel Streaming code was moved to a separate branch because it was uncompilable and incomplete. | ||
The version number has been bumped to 4.0.0 because of some new functions added to the API and because some private class definitions were moved out of the header file. Changes in this release include: | ||
- see git history for complete list of changes | ||
- updates to test programs to clarify port numbering | ||
- new C API wrapper | ||
- new functions to get API names | ||
- miscellaneous sysex fixes in Jack and ALSA | ||
- new setPortName() method (for Jack and ALSA) | ||
- new setClientName() method (for ALSA) | ||
- various build system updates and code efficiencies | ||
\section download Download | ||
Latest Release (11 February 2016): <A href="http://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-2.1.1.tar.gz">Version 2.1.1</A> | ||
Latest Release (17 April 2019): <A href="http://www.music.mcgill.ca/~gary/rtmidi/release/rtmidi-4.0.0.tar.gz">Version 4.0.0</A> | ||
@@ -31,24 +40,4 @@ \section start Getting Started | ||
\code | ||
\include getting_started.cpp | ||
#include "RtMidi.h" | ||
int main() | ||
{ | ||
RtMidiIn *midiin = 0; | ||
// RtMidiIn constructor | ||
try { | ||
midiin = new RtMidiIn(); | ||
} | ||
catch (RtMidiError &error) { | ||
// Handle the exception here | ||
error.printMessage(); | ||
} | ||
// Clean up | ||
delete midiin; | ||
} | ||
\endcode | ||
Obviously, this example doesn't demonstrate any of the real functionality of RtMidi. However, all uses of RtMidi must begin with construction and must end with class destruction. Further, it is necessary that all class methods that can throw a C++ exception be called within a try/catch block. | ||
@@ -74,3 +63,3 @@ | ||
\section probing Probing Ports | ||
\section probing Probing Ports / Devices | ||
@@ -148,5 +137,7 @@ A client generally must query the available MIDI ports before deciding which to use. The following example outlines how this can be done. | ||
Note that the port enumeration is system specific and will change if any devices are unplugged or plugged (or a new virtual port opened or closed) by the user. Thus, the port numbers should be verified immediately before opening a port. As well, if a user unplugs a device (or closes a virtual port) while a port connection exists to that device/port, a MIDI system error will be generated. | ||
\section output MIDI Output | ||
The RtMidiOut class provides simple functionality to immediately send messages over a MIDI connection. No timing functionality is provided. | ||
The RtMidiOut class provides simple functionality to immediately send messages over a MIDI connection. No timing functionality is provided. Note that there is an overloaded RtMidiOut::sendMessage() function that does not use std::vectors. | ||
@@ -215,3 +206,3 @@ In the following example, we omit necessary error checking and details regarding OS-dependent sleep functions. For a complete example, see the \c midiout.cpp program in the \c tests directory. | ||
The RtMidiIn class uses an internal callback function or thread to receive incoming MIDI messages from a port or device. These messages are then either queued and read by the user via calls to the RtMidiIn::getMessage() function or immediately passed to a user-specified callback function (which must be "registered" using the RtMidiIn::setCallback() function). We'll provide examples of both usages. | ||
The RtMidiIn class uses an internal callback function or thread to receive incoming MIDI messages from a port or device. These messages are then either queued and read by the user via calls to the RtMidiIn::getMessage() function or immediately passed to a user-specified callback function (which must be "registered" using the RtMidiIn::setCallback() function). Note that if you have multiple instances of RtMidiIn, each may have its own thread. We'll provide examples of both usages. | ||
@@ -338,3 +329,3 @@ The RtMidiIn class provides the RtMidiIn::ignoreTypes() function to specify that certain MIDI message types be ignored. By default, system exclusive, timing, and active sensing messages are ignored. | ||
The Linux ALSA, Macintosh CoreMIDI and JACK APIs allow for the establishment of virtual input and output MIDI ports to which other software clients can connect. RtMidi incorporates this functionality with the RtMidiIn::openVirtualPort() and RtMidiOut::openVirtualPort() functions. Any messages sent with the RtMidiOut::sendMessage() function will also be transmitted through an open virtual output port. If a virtual input port is open and a user callback function is set, the callback function will be invoked when messages arrive via that port. If a callback function is not set, the user must poll the input queue to check whether messages have arrived. No notification is provided for the establishment of a client connection via a virtual port. | ||
The Linux ALSA, Macintosh CoreMIDI and JACK APIs allow for the establishment of virtual input and output MIDI ports to which other software clients can connect. RtMidi incorporates this functionality with the RtMidiIn::openVirtualPort() and RtMidiOut::openVirtualPort() functions. Any messages sent with the RtMidiOut::sendMessage() function will also be transmitted through an open virtual output port. If a virtual input port is open and a user callback function is set, the callback function will be invoked when messages arrive via that port. If a callback function is not set, the user must poll the input queue to check whether messages have arrived. No notification is provided for the establishment of a client connection via a virtual port. The RtMidi::isPortOpen() function does not report the status of ports created with the RtMidi::openVirtualPort() function. | ||
@@ -425,3 +416,5 @@ \section compiling Compiling | ||
- Stephen Sinclair (Git repo and build system) | ||
- Stephen Sinclair (Git repo, code and build system) | ||
- amosonn | ||
- Christopher Arndt | ||
- Atsushi Eno (C API) | ||
@@ -432,15 +425,36 @@ - Sebastien Alaiwan (JACK memory leaks, Windows kernel streaming) | ||
- Jason Champion (MSW project file for library build) | ||
- Chris Chronopoulos | ||
- JP Cimalando | ||
- Eduardo Coutinho (Windows device names) | ||
- Mattes D | ||
- Michael Dahl | ||
- Paul Dean (increment optimization) | ||
- Francisco Demartino | ||
- Luc Deschenaux (sysex issues) | ||
- John Dey (OS-X timestamps) | ||
- Christoph Eckert (ALSA sysex fixes) | ||
- Thiago Goulart | ||
- Ashley Hedges | ||
- Sam Hocevar | ||
- Rorey Jaffe | ||
- jgvictores | ||
- Martin Koegler (various fixes) | ||
- Immanuel Litzroth (OS-X sysex fix) | ||
- Bartek Lukawski | ||
- Andi McClure | ||
- Jon McCormack (Snow Leopard updates) | ||
- Phildo | ||
- Lane Spangler | ||
- Axel Schmidt (client naming) | ||
- Ryan Schmidt | ||
- Saga Musix | ||
- Bart Spaans | ||
- Alexander Svetalkin (JACK MIDI) | ||
- Ben Swift | ||
- Casey Tucker (OS-X driver information, sysex sending) | ||
- Bastiaan Verreijt (Windows sysex multi-buffer code) | ||
- Dan Wilcox | ||
- Yuri | ||
- Serge Zaitsev | ||
- Iohannes Zmölnig | ||
@@ -450,3 +464,3 @@ \section license License | ||
RtMidi: realtime MIDI i/o C++ classes<BR> | ||
Copyright (c) 2003-2016 Gary P. Scavone | ||
Copyright (c) 2003-2019 Gary P. Scavone | ||
@@ -453,0 +467,0 @@ Permission is hereby granted, free of charge, to any person |
@@ -1,5 +0,22 @@ | ||
RtMidi - a set of C++ classes that provides a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMidi & JACK), and Windows (Multimedia Library). | ||
RtMidi - a set of C++ classes that provides a common API for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI & JACK), and Windows (Multimedia Library). | ||
By Gary P. Scavone, 2003-2016 | ||
By Gary P. Scavone, 2003-2019 (with help from many others!) | ||
v.4.0.0: (17 April 2019) | ||
- see git history for complete list of changes | ||
- updates to test programs to clarify port numbering | ||
- new C API wrapper | ||
- new functions to get API names | ||
- miscellaneous sysex fixes in Jack and ALSA | ||
- new setPortName() method (for Jack and ALSA) | ||
- new setClientName() method (for ALSA) | ||
- various build system updates and code efficiencies | ||
v.3.0.0: (31 August 2017) | ||
- see git history for complete list of changes | ||
- new sendMessage() function that does not use std::vector | ||
- various std::string updates, including use of UTF8 for port names | ||
- fixes for the MIDI queue | ||
- various build system updates and code efficiencies | ||
v2.1.1: (11 February 2016) | ||
@@ -16,7 +33,7 @@ - updates to automake routines | ||
- renamed RtError class to RtMidiError and embedded it in RtMidi.h (and deleted RtError.h) | ||
- fix to CoreMidi implementation to support dynamic port changes | ||
- fix to CoreMIDI implementation to support dynamic port changes | ||
- removed global ALSA sequencer objects because they were not thread safe (Martin Koegler) | ||
- fix for ALSA timing ignore flag (Devin Anderson) | ||
- fix for ALSA incorrect use of snd_seq_create_port() function (Tobias Schlemmer) | ||
- fix for international character support in CoreMidi (Martin Finke) | ||
- fix for international character support in CoreMIDI (Martin Finke) | ||
- fix for unicode conversion in WinMM (Dan Wilcox) | ||
@@ -23,0 +40,0 @@ - added custom error hook that allows the client to capture an RtMidi error outside of the RtMidi code (Pavel Mogilevskiy) |
@@ -6,4 +6,4 @@ var midi = require("../midi.js"); | ||
var virtualOutput = new midi.output(); | ||
var virtualInput = new midi.input(); | ||
var virtualOutput = new midi.Output(); | ||
var virtualInput = new midi.Input(); | ||
@@ -22,4 +22,4 @@ virtualOutput.openVirtualPort(outputName); | ||
setTimeout(function() { | ||
var output = new midi.output(); | ||
var input = new midi.input(); | ||
var output = new midi.Output(); | ||
var input = new midi.Input(); | ||
@@ -26,0 +26,0 @@ input.on('message', function(deltaTime, message) { |
var midi = require("../midi.js"); | ||
var output = new midi.output(); | ||
var input = new midi.input(); | ||
var output = new midi.Output(); | ||
var input = new midi.Input(); | ||
@@ -6,0 +6,0 @@ output.openVirtualPort("node-midi Virtual Output"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 10 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2757620
174
2651
229
4
70
14
+ Addedbindings@1.5.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
- Removedbindings@1.2.1(transitive)
Updatedbindings@~1.5.0