New JavaScript library

Asynchronous MIDI library for Node.js and HTML

Re: New JavaScript library

Postby Wayne McHugh » Sun Nov 15, 2015 8:03 pm

Hi Sema, as with all of us I'm very grateful for your continued work. For lack of time I've been avoiding facing the changes needed to deal with browser changes. In the previous html/js solution I did quite a bit of work with jzz.midifile.js and (to a much lesser extent) jzz.midi.js, in order to implement playback of midis customized in the browser. I just want to confirm that the old implementation is completely replaced in the new solution. I need to check before walking away from it, because I invested so much time getting it to all work.
Wayne McHugh
 
Posts: 8
Joined: Mon Feb 24, 2014 4:22 pm

Re: New JavaScript library

Postby sema » Mon Nov 16, 2015 8:00 pm

letoribo wrote:
Code: Select all
JZZ().openMidiOut().send([0xc0, 36, 0]).send([0x90,60,127])


It looks like WebMIDI API is too picky about the messages. Program change message must be 2 bytes: send([0xc0, 36])
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby sema » Mon Nov 16, 2015 8:09 pm

Wayne McHugh wrote:I just want to confirm that the old implementation is completely replaced in the new solution.

Old implementation still works fine in browsers that support NPAPI. Unfortunately, not in Chrome anymore.
If you want to be compatible with all browsers, use JZZ.js
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Tue Nov 17, 2015 2:39 am

yes,
Code: Select all
send([0xc0, 36])
works!
i've got one more question - JZZ.MidiOutList() ?
i couldn't invent anything better than this:
Code: Select all
var select_out = $("selectmidi");
var counter = -1;
var portNumber, midi_out_list = [];

var findMidiOut = setInterval(function(){
  counter++
  counter > midi_out_list.length ? window.clearTimeout(findMidiOut) : Open(counter);
}, 1500);

function Open(portNumber){
  JZZ().openMidiOut(portNumber).and(function(){
    midi_out_list.push(this.name());
    console.log('MIDI-Out' + portNumber + ' :', this.name());
    var opt = new Element('option').update(this.name());  //Prototype.js syntax
    select_out.insert(opt);
  })

Last edited by letoribo on Tue Nov 17, 2015 10:19 am, edited 1 time in total.
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Tue Nov 17, 2015 6:55 am

Sorry, I'm not sure I understand your question...
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Tue Nov 17, 2015 10:17 am

i asked about MidiOutList() for JZZ.js, because
outputs : an array of info objects for available output ports
does not work for me
Here is the link to the app:
http://intersonant.appspot.com/
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Tue Nov 17, 2015 3:05 pm

You don't need to open the device to get its info.
Check the source code of this page: http://jazz-soft.github.io/modules/index.html - it outputs the names of all available ports.
Code: Select all
JZZ().and(function(){
  var s1 = "";
  var outs = this.info().outputs;
  for (var i = 0; i < outs.length; i++) {
    s1 += "<li>" + outs[i].name + "<ul><li>v." + outs[i].version + " - " + outs[i].manufacturer + " (" + outs[i].engine + ")</li></ul></li>";
  }
  if (!outs.length) s1 += "<li>not found</li>";
  var s2 = "";
  var ins = this.info().inputs;
  for (var i = 0; i < ins.length; i++) {
    s2 += "<li>" + ins[i].name + "<ul><li>v." + ins[i].version + " - " + ins[i].manufacturer + " (" + ins[i].engine + ")</li></ul></li>";
  }
  if (!ins.length) s2 += "<li>not found</li>";
  out.innerHTML = "<p>MIDI Out:<ul>" + s1 + "</ul></p><p>MIDI In:<ul>" + s2 + "</ul></p>";
});
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Tue Nov 17, 2015 4:45 pm

for some reason this caused "Inspected target disconnected".
please, check out this snippet:

Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
<script src="JZZ.js"></script>
</head>
<body>
<script>
JZZ().and(function(){
  var outs = this.info().outputs;
  for (var i = 0; i < outs.length; i++) {
    console.log('MIDI-Out' + i + ' :', outs[i].name);
  }
});     
</script>
</body>
</html>
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Tue Nov 17, 2015 5:36 pm

Very interesting... If you remove prototype.js - it works!
I guess prototype.js redefines some fundamental functions.
Please check with the prototype.js experts (which I'm not) and let me know what is going on.
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Wed Nov 18, 2015 7:37 am

indeed, very interesting, considering that the application has prototype.js.
incompatibility is only with this expression:

Code: Select all
JZZ().and(function(){
  var outs = this.info().outputs;
  /*for (var i = 0; i < outs.length; i++) {
     console.log('MIDI-Out' + i + ' :', outs[i].name);
  }*/
});
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby letoribo » Thu Nov 19, 2015 5:27 am

Code: Select all
JZZ().and(function(){ console.log('?'); })
  .wait(1000).refresh().
  and(function(){
    var outs = this.info().outputs;
  }
});


Uncaught RangeError: Maximum call stack size exceeded
_clone @ JZZ.js:101
_clone @ JZZ.js:102

Why? :roll:
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Thu Nov 19, 2015 1:01 pm

I think that is caused by circular references when I'm trying to clone the objects.
Should be an easy fix. Thanks for catching it!
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby sema » Sun Nov 22, 2015 4:20 pm

I have just committed the fix. It should work fine with prototype.js now.
Thanks again for catching the bug!
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Thu Nov 26, 2015 9:48 am

thank you!
i'm trying to port this app: https://github.com/letoribo/midiplayer
to work with JZZ.js, and my question is how to get JZZ.MidiFile.js, JZZ.Midi.js and JZZ.js to work together?
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Thu Nov 26, 2015 12:00 pm

Either change all plugin calls to JZZ calls, or wait till I do it my self (that may take longer) :)
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Mon Jan 18, 2016 10:46 am

waiting for the official release
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby letoribo » Sun Jan 24, 2016 5:02 am

Sema how is the weather?
you are not covered with snow? :)
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby letoribo » Thu Jan 12, 2017 7:18 am

"Getting Started" example does not work in Chrome, although it works fine in Chrome Canary
https://letoribo.github.io/Cannot-start-MIDI-engine-/
Windows7
Chrome
Version 55.0.2883.87 m - does not work
Версия 57.0.2979.0 (Официальная сборка), canary (32 бит) - works fine
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

Re: New JavaScript library

Postby sema » Thu Jan 12, 2017 4:19 pm

Do you use the chrome extension or WebMIDI API?
Is there a MIDI instrrument connected to your PC?
sema
Site Admin
 
Posts: 317
Joined: Mon Oct 17, 2011 7:28 pm

Re: New JavaScript library

Postby letoribo » Thu Jan 12, 2017 11:16 pm

just copypasted "Getting Started" example:
https://github.com/letoribo/Cannot-start-MIDI-engine-
letoribo
 
Posts: 98
Joined: Fri Sep 13, 2013 8:25 am
Location: Odessa,Ukraine

PreviousNext

Return to JZZ.js

Who is online

Users browsing this forum: No registered users and 1 guest

cron