Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35596 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2018-09-11 08:56 -0700 |
| Last post | 2018-09-26 03:22 -0700 |
| Articles | 11 — 3 participants |
Back to article view | Back to comp.lang.javascript
What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-11 08:56 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-11 10:26 -0700
Re: What happened to the web midi api? moltenvoltage@gmail.com - 2018-09-26 01:39 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 02:18 -0700
Re: What happened to the web midi api? tony@mountifield.org (Tony Mountifield) - 2018-09-26 10:34 +0000
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 04:27 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 13:55 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 14:23 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 14:56 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 15:06 -0700
Re: What happened to the web midi api? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-26 03:22 -0700
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-11 08:56 -0700 |
| Subject | What happened to the web midi api? |
| Message-ID | <85247887-9afe-415e-bf34-58873a916a8e@googlegroups.com> |
This is the latest draft of web midi api on howto send message to a deviceOut, output.send(message) to a connected midi device.
First off the idiots do not state what portID supposed to be anywhere in the API, if it is an integer or "Device name".
It **sounds** like a device name.
In XP, once you get the port from midiAccess object using index.
output = mid.outputs.get(outportindex);
But here they do not show anywhere in the API how to get it. If they change something, should they not fucking document it?
Can't they fucking stop playing with their anal beads, and make an example that actually work and do something?
Instead of 50 snippets doing nothing and probably not even coherent and working, a single snippet, to get midiaccess, read input and send it back out.
https://webaudio.github.io/web-midi-api/
4.10.5 Sending MIDI Messages to an Output Device
This example sends a middle C note on message immediately on MIDI channel 1 (MIDI channels are 0-indexed, but generally referred to as channels 1-16), and queues a corresponding note off message for 1 second later.
EXAMPLE 7
function sendMiddleC( midiAccess, portID ) {
var noteOnMessage = [0x90, 60, 0x7f]; // note on, middle C, full velocity
var output = midiAccess.outputs.get(portID);
output.send( noteOnMessage ); //omitting the timestamp means send immediately.
output.send( [0x80, 60, 0x40], window.performance.now() + 1000.0 ); // Inlined array creation- note off, middle C,
// release velocity = 64, timestamp = now + 1000ms.
}
If anyone can even get the portID"whatever that is supposed to be" code above i am impressed.
Even more impressive if someone manage to actually send something to midiout "output" using it.
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-11 10:26 -0700 |
| Message-ID | <ee9bd1bd-354b-4dc1-bd29-26fb22196666@googlegroups.com> |
| In reply to | #35596 |
Den tisdag 11 september 2018 kl. 17:56:23 UTC+2 skrev Jonas Thörnvall:
> This is the latest draft of web midi api on howto send message to a deviceOut, output.send(message) to a connected midi device.
>
> First off the idiots do not state what portID supposed to be anywhere in the API, if it is an integer or "Device name".
> It **sounds** like a device name.
>
> In XP, once you get the port from midiAccess object using index.
>
> output = mid.outputs.get(outportindex);
>
> But here they do not show anywhere in the API how to get it. If they change something, should they not fucking document it?
>
> Can't they fucking stop playing with their anal beads, and make an example that actually work and do something?
>
> Instead of 50 snippets doing nothing and probably not even coherent and working, a single snippet, to get midiaccess, read input and send it back out.
>
>
> https://webaudio.github.io/web-midi-api/
>
> 4.10.5 Sending MIDI Messages to an Output Device
> This example sends a middle C note on message immediately on MIDI channel 1 (MIDI channels are 0-indexed, but generally referred to as channels 1-16), and queues a corresponding note off message for 1 second later.
>
> EXAMPLE 7
> function sendMiddleC( midiAccess, portID ) {
> var noteOnMessage = [0x90, 60, 0x7f]; // note on, middle C, full velocity
> var output = midiAccess.outputs.get(portID);
> output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> output.send( [0x80, 60, 0x40], window.performance.now() + 1000.0 ); // Inlined array creation- note off, middle C,
> // release velocity = 64, timestamp = now + 1000ms.
> }
>
> If anyone can even get the portID"whatever that is supposed to be" code above i am impressed.
>
> Even more impressive if someone manage to actually send something to midiout "output" using it.
Well after three months i conclude that there is something inherently wrong with
var output = midiAccess.outputs.get(portID);
It simply doesn't work.
But i found another approach, i finally reach output, store the ports in an array that i reach.
Thanks for being indulgent, with my temper tantrums LoL
Now i can start program ***again*** finally.
Your life will become very quiet now...
Almost meaningless LoL
outmess.send(noteMessage);
outportarr=[];var outmess;
function listPorts(){
// Grab an array of all available devices
var iter = mid.outputs.values();
for (var i = iter.next(); i && !i.done; i = iter.next()) {
outportarr.push(i.value);
}
outmess=outportarr[outportindex];
//List ports in and out
portout = mid.outputs.values();
portin = mid.inputs.values();
for (listinput = portin.next(); listinput && !listinput.done; listinput = portin.next()) {
var deviceIn = listinput.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
}
for (listoutput = portout.next(); listoutput && !listoutput.done; listoutput = portout.next()) {
var deviceOut = listoutput.value.name;
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}
}
[toc] | [prev] | [next] | [standalone]
| From | moltenvoltage@gmail.com |
|---|---|
| Date | 2018-09-26 01:39 -0700 |
| Message-ID | <f6929b8d-ccb5-4e9a-b2f9-53ff8f8d04c3@googlegroups.com> |
| In reply to | #35596 |
I'm having the identical problem and the documentation on github is utter crap. I also tried Jonas' code but it spits out errors too. Maybe that code sample is incomplete? Do you have a full working example of sending a note (or any data) out via webmidi? Thanks!
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 02:18 -0700 |
| Message-ID | <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com> |
| In reply to | #35690 |
Den onsdag 26 september 2018 kl. 10:39:10 UTC+2 skrev molten...@gmail.com:
> I'm having the identical problem and the documentation on github is utter crap.
>
> I also tried Jonas' code but it spits out errors too. Maybe that code sample is incomplete?
>
> Do you have a full working example of sending a note (or any data) out via webmidi?
>
> Thanks!
Yes i got it working, but you have to read in the ports to an array outportarr.
// Create an array of all available devices
var iter = mid.outputs.values();
for (var i = iter.next(); i && !i.done; i = iter.next()) {
outportarr.push(i.value);
}
PORTout=outportarr[outportindex];
Then you simply send message by build the data you want to send here i send notes.
noteMessage = [track[0].midiMess[midEvent].data0,
track[0].midiMess[midEvent].data1, track[0].midiMess[midEvent].data2];
outportarr[outportindex].send(noteMessage);
Here build message and send to change program
sysexC=192+channelC-1;
settingChange = [sysexC,programC];
outportarr[outportindex].send(settingChange);
Here i build message and send to change midichannel
function sendMidiChannel(){
//Set midichannel on the track
channelC=document.getElementById("out_channel").selectedIndex+1;
if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
}
Which is not really a separate message, it simply "different hexcodes for note on, note off" messages for each channel. That is about what one need.
To send messages pitch bend and such are sent over notemessage in my recordings so you do not need any special cases "unless you build an advanced editor"
Probably you also want to "set midichannel volume i think the devices may use it" but i do not have the message that send channel volume implemented yet.
But it is 07 in hex so i guess the message would be something like
sysexC=07;
settingChange = [sysexC,volume];
outportarr[outportindex].send(settingChange);
Like above i construct and send any message i need using the midi standard table
https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2
[toc] | [prev] | [next] | [standalone]
| From | tony@mountifield.org (Tony Mountifield) |
|---|---|
| Date | 2018-09-26 10:34 +0000 |
| Message-ID | <pofnbh$1m6$1@softins.softins.co.uk> |
| In reply to | #35693 |
In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
>
> Here i build message and send to change midichannel
>
> function sendMidiChannel(){
> //Set midichannel on the track
> channelC=document.getElementById("out_channel").selectedIndex+1;
> if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> }
Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
But you can do it more efficiently like this, instead of all those ifs:
function sendMidiChannel(){
//Set midichannel on the track
var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
if (channelC >= 0 && channelC < 16) {
NOTE_ON = 0x90 + channelC;
NOTE_OFF = 0x80 + channelC;
}
}
Cheers
Tony
--
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 04:27 -0700 |
| Message-ID | <1ba7d3f1-f4d6-4684-9260-f0ee69c7c552@googlegroups.com> |
| In reply to | #35697 |
Den onsdag 26 september 2018 kl. 12:35:03 UTC+2 skrev Tony Mountifield:
> In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
> Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
> >
> > Here i build message and send to change midichannel
> >
> > function sendMidiChannel(){
> > //Set midichannel on the track
> > channelC=document.getElementById("out_channel").selectedIndex+1;
> > if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> > else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> > else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> > else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> > else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> > else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> > else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> > else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> > else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> > else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> > else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> > else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> > else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> > else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> > else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> > else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> > }
>
> Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
>
> But you can do it more efficiently like this, instead of all those ifs:
>
> function sendMidiChannel(){
> //Set midichannel on the track
> var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
> if (channelC >= 0 && channelC < 16) {
> NOTE_ON = 0x90 + channelC;
> NOTE_OFF = 0x80 + channelC;
> }
> }
>
> Cheers
> Tony
> --
> Tony Mountifield
> Work: tony@softins.co.uk - http://www.softins.co.uk
> Play: tony@mountifield.org - http://tony.mountifield.org
Yeah lol i did hexdec conversion i can see, i was att 100 LoL
Thanks for the code will swap immediately, much better and easier to read.
Cheers
Jonas
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 13:55 -0700 |
| Message-ID | <204fce2f-cdad-485f-a92e-d36ca2af132a@googlegroups.com> |
| In reply to | #35698 |
Den onsdag 26 september 2018 kl. 13:27:39 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 26 september 2018 kl. 12:35:03 UTC+2 skrev Tony Mountifield:
> > In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
> > Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
> > >
> > > Here i build message and send to change midichannel
> > >
> > > function sendMidiChannel(){
> > > //Set midichannel on the track
> > > channelC=document.getElementById("out_channel").selectedIndex+1;
> > > if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> > > else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> > > else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> > > else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> > > else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> > > else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> > > else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> > > else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> > > else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> > > else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> > > else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> > > else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> > > else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> > > else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> > > else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> > > else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> > > }
> >
> > Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
> >
> > But you can do it more efficiently like this, instead of all those ifs:
> >
> > function sendMidiChannel(){
> > //Set midichannel on the track
> > var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
> > if (channelC >= 0 && channelC < 16) {
> > NOTE_ON = 0x90 + channelC;
> > NOTE_OFF = 0x80 + channelC;
> > }
> > }
> >
> > Cheers
> > Tony
> > --
> > Tony Mountifield
> > Work: tony@softins.co.uk - http://www.softins.co.uk
> > Play: tony@mountifield.org - http://tony.mountifield.org
>
> Yeah lol i did hexdec conversion i can see, i was att 100 LoL
> Thanks for the code will swap immediately, much better and easier to read.
>
> Cheers
> Jonas
This is the webbased SF2 "GM synth" i decided to use for my sequenser project i figured out howto send notes vel on/off to it from my script, but i am pretty clueless howto change midichannel and program from my script. Well i see the functions, but i just can't interface the midichannel and program messages correct.
https://logue.github.io/smfplayer.js/wml2.html
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 14:23 -0700 |
| Message-ID | <6333c3ef-f1eb-482d-b658-178d3097da1a@googlegroups.com> |
| In reply to | #35703 |
Den onsdag 26 september 2018 kl. 22:55:21 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 26 september 2018 kl. 13:27:39 UTC+2 skrev Jonas Thörnvall:
> > Den onsdag 26 september 2018 kl. 12:35:03 UTC+2 skrev Tony Mountifield:
> > > In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
> > > Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
> > > >
> > > > Here i build message and send to change midichannel
> > > >
> > > > function sendMidiChannel(){
> > > > //Set midichannel on the track
> > > > channelC=document.getElementById("out_channel").selectedIndex+1;
> > > > if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> > > > else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> > > > else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> > > > else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> > > > else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> > > > else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> > > > else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> > > > else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> > > > else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> > > > else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> > > > else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> > > > else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> > > > else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> > > > else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> > > > else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> > > > else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> > > > }
> > >
> > > Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
> > >
> > > But you can do it more efficiently like this, instead of all those ifs:
> > >
> > > function sendMidiChannel(){
> > > //Set midichannel on the track
> > > var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
> > > if (channelC >= 0 && channelC < 16) {
> > > NOTE_ON = 0x90 + channelC;
> > > NOTE_OFF = 0x80 + channelC;
> > > }
> > > }
> > >
> > > Cheers
> > > Tony
> > > --
> > > Tony Mountifield
> > > Work: tony@softins.co.uk - http://www.softins.co.uk
> > > Play: tony@mountifield.org - http://tony.mountifield.org
> >
> > Yeah lol i did hexdec conversion i can see, i was att 100 LoL
> > Thanks for the code will swap immediately, much better and easier to read.
> >
> > Cheers
> > Jonas
>
> This is the webbased SF2 "GM synth" i decided to use for my sequenser project i figured out howto send notes vel on/off to it from my script, but i am pretty clueless howto change midichannel and program from my script. Well i see the functions, but i just can't interface the midichannel and program messages correct.
>
> https://logue.github.io/smfplayer.js/wml2.html
In mainmidi.js i initialse the synthcall by loading it.
synth.Load('https://logue.github.io/smfplayer.js/wml2.html');
I found some synth interface sample code with calls, but i can't figure out howto change the midichannel nor program. I tried to look in wml2.html and its scripts for program change but can't get it to work.
Below my synthcalls.js
function Synth() {
this.sy = null;
this.Load = function(url) {
this.sy = window.open(url, "right", "width=900,height=670,scrollbars=yes,resizable=yes");
}
this.NoteOn = function(note, velo) {
this.SendMessage(this.sy, "midi,90," + note.toString(16) + "," + velo.toString(16));
}
this.NoteOff = function(note) {
this.SendMessage(this.sy, "midi,80," + note.toString(16) + ",0");
}
this.AllSoundOff = function() {
this.SendMessage(this.sy, "midi,b0,78,0");
}
this.SendMessage = function(sy, s) {
if(this.sy)
this.sy.postMessage(s, "*");
}
// this.Prog = function(sy,p) {
//
//this.SendMessage(synth, "midi,c"+synth.ch+","+p.toString(16));
//}
}
var synth = new Synth();
So i manage to interface and send notes to the synth "play it" from my script, but i also would like to interface program and midichannel changes from my script.
Sending note to synth.
function sf2synth(message){
console.log(message.data[0]);
if (message.data[0]>127 && message.data[0]<144){synth.NoteOff(message.data[1]);console.log("noteoff");}
else if (message.data[0]>143 && message.data[0]<166){synth.NoteOn(message.data[1],message.data[2])}
}
But if someone see howto change program and midichannel show me the messages and synth. calls to do it.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 14:56 -0700 |
| Message-ID | <d4e894c2-6de4-4d37-a39d-97f8b6915573@googlegroups.com> |
| In reply to | #35704 |
Den onsdag 26 september 2018 kl. 23:23:44 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 26 september 2018 kl. 22:55:21 UTC+2 skrev Jonas Thörnvall:
> > Den onsdag 26 september 2018 kl. 13:27:39 UTC+2 skrev Jonas Thörnvall:
> > > Den onsdag 26 september 2018 kl. 12:35:03 UTC+2 skrev Tony Mountifield:
> > > > In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
> > > > Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
> > > > >
> > > > > Here i build message and send to change midichannel
> > > > >
> > > > > function sendMidiChannel(){
> > > > > //Set midichannel on the track
> > > > > channelC=document.getElementById("out_channel").selectedIndex+1;
> > > > > if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> > > > > else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> > > > > else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> > > > > else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> > > > > else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> > > > > else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> > > > > else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> > > > > else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> > > > > else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> > > > > else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> > > > > else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> > > > > else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> > > > > else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> > > > > else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> > > > > else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> > > > > else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> > > > > }
> > > >
> > > > Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
> > > >
> > > > But you can do it more efficiently like this, instead of all those ifs:
> > > >
> > > > function sendMidiChannel(){
> > > > //Set midichannel on the track
> > > > var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
> > > > if (channelC >= 0 && channelC < 16) {
> > > > NOTE_ON = 0x90 + channelC;
> > > > NOTE_OFF = 0x80 + channelC;
> > > > }
> > > > }
> > > >
> > > > Cheers
> > > > Tony
> > > > --
> > > > Tony Mountifield
> > > > Work: tony@softins.co.uk - http://www.softins.co.uk
> > > > Play: tony@mountifield.org - http://tony.mountifield.org
> > >
> > > Yeah lol i did hexdec conversion i can see, i was att 100 LoL
> > > Thanks for the code will swap immediately, much better and easier to read.
> > >
> > > Cheers
> > > Jonas
> >
> > This is the webbased SF2 "GM synth" i decided to use for my sequenser project i figured out howto send notes vel on/off to it from my script, but i am pretty clueless howto change midichannel and program from my script. Well i see the functions, but i just can't interface the midichannel and program messages correct.
> >
> > https://logue.github.io/smfplayer.js/wml2.html
>
> In mainmidi.js i initialse the synthcall by loading it.
> synth.Load('https://logue.github.io/smfplayer.js/wml2.html');
>
> I found some synth interface sample code with calls, but i can't figure out howto change the midichannel nor program. I tried to look in wml2.html and its scripts for program change but can't get it to work.
> Below my synthcalls.js
>
> function Synth() {
> this.sy = null;
> this.Load = function(url) {
> this.sy = window.open(url, "right", "width=900,height=670,scrollbars=yes,resizable=yes");
> }
> this.NoteOn = function(note, velo) {
> this.SendMessage(this.sy, "midi,90," + note.toString(16) + "," + velo.toString(16));
> }
> this.NoteOff = function(note) {
> this.SendMessage(this.sy, "midi,80," + note.toString(16) + ",0");
> }
> this.AllSoundOff = function() {
> this.SendMessage(this.sy, "midi,b0,78,0");
> }
> this.SendMessage = function(sy, s) {
> if(this.sy)
> this.sy.postMessage(s, "*");
> }
> // this.Prog = function(sy,p) {
> //
> //this.SendMessage(synth, "midi,c"+synth.ch+","+p.toString(16));
> //}
>
> }
> var synth = new Synth();
>
>
> So i manage to interface and send notes to the synth "play it" from my script, but i also would like to interface program and midichannel changes from my script.
> Sending note to synth.
> function sf2synth(message){
> console.log(message.data[0]);
> if (message.data[0]>127 && message.data[0]<144){synth.NoteOff(message.data[1]);console.log("noteoff");}
> else if (message.data[0]>143 && message.data[0]<166){synth.NoteOn(message.data[1],message.data[2])}
> }
>
> But if someone see howto change program and midichannel show me the messages and synth. calls to do it.
Well here it is more an outline for its intended functionality although it do change midichannels, program record and playup. The external websynth i hogged up yesterday, so there is no function playup to it after you record but it will be once i find out howto send messages for program and midichannel.
"This shell of sequenser is basicly for a "GM synth, module" on your mididevice".
There so many ideas not fully implementd, but supported ;)
There will be concurrent play and record once i find out a good way to do it.
http://anybase.co.nf/index.html
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 15:06 -0700 |
| Message-ID | <1470b913-edc2-4a4a-b0c7-aebf4b32012b@googlegroups.com> |
| In reply to | #35705 |
Den onsdag 26 september 2018 kl. 23:56:50 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 26 september 2018 kl. 23:23:44 UTC+2 skrev Jonas Thörnvall:
> > Den onsdag 26 september 2018 kl. 22:55:21 UTC+2 skrev Jonas Thörnvall:
> > > Den onsdag 26 september 2018 kl. 13:27:39 UTC+2 skrev Jonas Thörnvall:
> > > > Den onsdag 26 september 2018 kl. 12:35:03 UTC+2 skrev Tony Mountifield:
> > > > > In article <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com>,
> > > > > Jonas Thörnvall <jonas.thornvall@gmail.com> wrote:
> > > > > >
> > > > > > Here i build message and send to change midichannel
> > > > > >
> > > > > > function sendMidiChannel(){
> > > > > > //Set midichannel on the track
> > > > > > channelC=document.getElementById("out_channel").selectedIndex+1;
> > > > > > if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
> > > > > > else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
> > > > > > else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
> > > > > > else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
> > > > > > else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
> > > > > > else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
> > > > > > else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
> > > > > > else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
> > > > > > else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
> > > > > > else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
> > > > > > else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
> > > > > > else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
> > > > > > else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
> > > > > > else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
> > > > > > else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
> > > > > > else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
> > > > > > }
> > > > >
> > > > > Hi Jonas, it looks like you have the NOTE_ON values wrong for channels 11-16.
> > > > >
> > > > > But you can do it more efficiently like this, instead of all those ifs:
> > > > >
> > > > > function sendMidiChannel(){
> > > > > //Set midichannel on the track
> > > > > var channelC=document.getElementById("out_channel").selectedIndex; // don't need +1 here
> > > > > if (channelC >= 0 && channelC < 16) {
> > > > > NOTE_ON = 0x90 + channelC;
> > > > > NOTE_OFF = 0x80 + channelC;
> > > > > }
> > > > > }
> > > > >
> > > > > Cheers
> > > > > Tony
> > > > > --
> > > > > Tony Mountifield
> > > > > Work: tony@softins.co.uk - http://www.softins.co.uk
> > > > > Play: tony@mountifield.org - http://tony.mountifield.org
> > > >
> > > > Yeah lol i did hexdec conversion i can see, i was att 100 LoL
> > > > Thanks for the code will swap immediately, much better and easier to read.
> > > >
> > > > Cheers
> > > > Jonas
> > >
> > > This is the webbased SF2 "GM synth" i decided to use for my sequenser project i figured out howto send notes vel on/off to it from my script, but i am pretty clueless howto change midichannel and program from my script. Well i see the functions, but i just can't interface the midichannel and program messages correct.
> > >
> > > https://logue.github.io/smfplayer.js/wml2.html
> >
> > In mainmidi.js i initialse the synthcall by loading it.
> > synth.Load('https://logue.github.io/smfplayer.js/wml2.html');
> >
> > I found some synth interface sample code with calls, but i can't figure out howto change the midichannel nor program. I tried to look in wml2.html and its scripts for program change but can't get it to work.
> > Below my synthcalls.js
> >
> > function Synth() {
> > this.sy = null;
> > this.Load = function(url) {
> > this.sy = window.open(url, "right", "width=900,height=670,scrollbars=yes,resizable=yes");
> > }
> > this.NoteOn = function(note, velo) {
> > this.SendMessage(this.sy, "midi,90," + note.toString(16) + "," + velo.toString(16));
> > }
> > this.NoteOff = function(note) {
> > this.SendMessage(this.sy, "midi,80," + note.toString(16) + ",0");
> > }
> > this.AllSoundOff = function() {
> > this.SendMessage(this.sy, "midi,b0,78,0");
> > }
> > this.SendMessage = function(sy, s) {
> > if(this.sy)
> > this.sy.postMessage(s, "*");
> > }
> > // this.Prog = function(sy,p) {
> > //
> > //this.SendMessage(synth, "midi,c"+synth.ch+","+p.toString(16));
> > //}
> >
> > }
> > var synth = new Synth();
> >
> >
> > So i manage to interface and send notes to the synth "play it" from my script, but i also would like to interface program and midichannel changes from my script.
> > Sending note to synth.
> > function sf2synth(message){
> > console.log(message.data[0]);
> > if (message.data[0]>127 && message.data[0]<144){synth.NoteOff(message.data[1]);console.log("noteoff");}
> > else if (message.data[0]>143 && message.data[0]<166){synth.NoteOn(message.data[1],message.data[2])}
> > }
> >
> > But if someone see howto change program and midichannel show me the messages and synth. calls to do it.
>
> Well here it is more an outline for its intended functionality although it do change midichannels, program record and playup. The external websynth i hogged up yesterday, so there is no function playup to it after you record but it will be once i find out howto send messages for program and midichannel.
>
> "This shell of sequenser is basicly for a "GM synth, module" on your mididevice".
> There so many ideas not fully implementd, but supported ;)
> There will be concurrent play and record once i find out a good way to do it.
>
> http://anybase.co.nf/index.html
One thing that will change once it get recording and playup, simultaneous is that there is no need for the metronome to be called by setInterval. Better to generate it on a locked track.
Midi is just a stream so at playup all individual recorded tracks downmixed to a single stream. "track0". The tracks are there for the settings.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-26 03:22 -0700 |
| Message-ID | <0a238f37-6cec-49d8-b96b-4bd0f1b131c5@googlegroups.com> |
| In reply to | #35690 |
Den onsdag 26 september 2018 kl. 10:39:10 UTC+2 skrev molten...@gmail.com: > I'm having the identical problem and the documentation on github is utter crap. > > I also tried Jonas' code but it spits out errors too. Maybe that code sample is incomplete? > > Do you have a full working example of sending a note (or any data) out via webmidi? > > Thanks! Actually i found a nice web based SF2 synth, are you familiar with soundfonts this one is GM compatible. It is an YAMAHA XG soundfont, pretty responsive around 30-50 ms latency i should guess. I intend to use it so people without external synths can do GM midi songs with just a controller keyboard. You can send program changes, midichannel changes and midichannel volumes. Found it yesterday. https://logue.github.io/smfplayer.js/#zip=midifiles%2FYAMAHA%20mididata%20library.zip&file=LITE%2Fsummer.mid If you look at the code you can find wml2.html, you can download it and load it in a div or frame. There is a minimal interface for it called webmidilink. So basicly a great little synth for a sequenser, i have time read other peoples code so the hard part for me was loading the synth with my own interface, breaking it out from the webmidilink examples. When and if i finish the sequenser, will try do my own synth project using webaudio API, been looking around for VST, VSTI host in javascript, or something that convert a VSTI into some sort of in between bytecode that one could get the audiosynthesis from. Javascript is probably to slow and will cause latency, but i was surprised by the reasonable latency of the SF2 synth i found.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web