Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35697
| From | tony@mountifield.org (Tony Mountifield) |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: What happened to the web midi api? |
| Date | 2018-09-26 10:34 +0000 |
| Organization | Software Insight Ltd., Winchester, UK |
| Message-ID | <pofnbh$1m6$1@softins.softins.co.uk> (permalink) |
| References | <85247887-9afe-415e-bf34-58873a916a8e@googlegroups.com> <f6929b8d-ccb5-4e9a-b2f9-53ff8f8d04c3@googlegroups.com> <2ca2fbcc-8f70-4920-9527-5a6c2255495b@googlegroups.com> |
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
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web