abudaan / midibridge-js Goto Github PK
View Code? Open in Web Editor NEWA Javascript API for interacting with MIDI devices
Home Page: http://www.abumarkub.net/abublog/?p=576
A Javascript API for interacting with MIDI devices
Home Page: http://www.abumarkub.net/abublog/?p=576
The docs at http://abumarkub.net/abublog/?page_id=399#documentation say that
connectAllInputsToFirstOutput defaults to true, but it seems to default to false.
Midibridge 5.0.2: Testing http://abumarkub.net/midibridge/examples/base64.html.
Hitting the stop button while playing a file results in the following console message (from MidiBridge.js line 250):
"weird MIDI message intercepted 191".
Maybe there should be a flag we could set for a "verbose" mode?
If messages are sent, they should be more helpful. In this case, nothing more serious seems to have happened than
"performance stopped".
This example works fine from your web site, but not from my local hard disk.
To get it to work here, I have to comment out line 8 of playmidifile.js:
"use strict;"
If I don't comment out that line, I get an "uncaught reference error" at line 66:
sliderThumb = document.createElement("div");
Very odd!
What, exactly does"use strict;"
do? Sorry if that's a silly question, but I can't see any documentation for it.
Two quibbles:
I've now been through all the examples in version 5.0.2, and very impressive the are too! Wonderful stuff!! Bravo!
On Mac OSX Lion in Chrome 15, when I open up "index.html," the page content doesn't load and in the console it complains that it can't find "/midibridge-js/net.abumarkub.midi.applet.MidiApplet."
Sending a PROGRAM_CHANGE message causes an infinite loop.
Try the following code:
midiBridge.init({
ready: function (msg)
{
},
data: function (midiEvent)
{
contentDiv.innerHTML += "Sending PROGRAM CHANGE<br/>";
midiBridge.sendMidiEvent(midiBridge.PROGRAM_CHANGE, 0, 13, 0);
}
});
Playing any key on the midi input device triggers the infinite loop.
(Stop it by putting a break point inside the data function!)
Since I've now got all the examples working, and I want to get to know midibridge as well as possible (and get more familiar with Javascript), I've decided to go through the documentation at
http://abumarkub.net/abublog/?page_id=399#documentation
systematically.
I've already discovered quite a lot that seems out of date, or I think could be improved, so I'm rewriting as I go. (A beginner's outside perspective on all this is probably a help.) I'll post the result here as a wiki page when I'm done. Fortunately, midibridge is fairly small, so this should not take too long.
Apropos: I think midibridge should resist attempts to add new features! Small is beautiful! :-)
I think you could/should eventually move the main docs out of their current page, and just provide a link to the up-to-date docs kept here. You will, of course, be able to edit/delete anything I post. I'm doing this for me! :-)
Best,
j
I know I said you should resist requests for new features, but this is different! :-)
I want to program a button to play a simple sequence of midiEvents. Pressing the button should play the sequence.
Currently, as far as I can see, the only way to do this is to use the sequencer to send a standard midi file (as illustrated in the playmidifile example), but it would be very useful if the sequence could be defined some other way.
The best way to do this would, I think, be to define a new static member midiBridge.SLEEP, which would be used like this:
midiBridge.sendMidiEvent(midiBridge.SLEEP, number_of_milliseconds);
A button could then be programmed to play a simple sequence as follows:
btnPlay = document.createElement("div"); btnPlay.innerHTML = "PLAY"; btnPlay.className = "button"; controls.appendChild(btnPlay); btnPlay.addEventListener("click", function() { midiBridge.sendMidiEvent(midiBridge.NOTE_ON, 1, 84, 100); midiBridge.sendMidiEvent(midiBridge.SLEEP, 513); midiBridge.sendMidiEvent(midiBridge.NOTE_OFF, 1, 84, 0); midiBridge.sendMidiEvent(midiBridge.NOTE_ON, 1, 85, 100); midiBridge.sendMidiEvent(midiBridge.SLEEP, 1001); midiBridge.sendMidiEvent(midiBridge.NOTE_OFF, 1, 85, 0); midiBridge.sendMidiEvent(midiBridge.SLEEP, 700); midiBridge.sendMidiEvent(midiBridge.NOTE_ON, 1, 86, 100); midiBridge.sendMidiEvent(midiBridge.SLEEP, 602); midiBridge.sendMidiEvent(midiBridge.NOTE_OFF, 1, 86, 0); midiBridge.sendMidiEvent(midiBridge.NOTE_ON, 1, 87, 100); midiBridge.sendMidiEvent(midiBridge.SLEEP, 286); midiBridge.sendMidiEvent(midiBridge.NOTE_OFF, 1, 87, 0); }, false);
This example was adapted from the PLAY button in the playmidifile example. In the original example, a whole sequencer has had to be set up and loaded with a file, and the eventListener then calls
midiBridge.startSequencer();
If you choose not to implement this, I could probably find a way to write my own javascript Sleep() function, but I think this is something a lot of people might like to have, and it makes for far more elegant code.
Is there already a way to do this, that I've overlooked?
best, j
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.