Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #40246
| From | Mostowski Collapse <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Building midi message for a software synth |
| Date | 2021-06-25 13:57 +0200 |
| Message-ID | <sb4gai$5sa$1@solani.org> (permalink) |
| References | <419b4226-1b11-48ca-b1eb-4a3cbf9664e2n@googlegroups.com> <bfa16d76-b90e-4ab2-a945-02b68b5c51aen@googlegroups.com> <2f9df51d-3949-4b6e-8fdb-2c252e93f34cn@googlegroups.com> <7594c976-2202-40c4-8a34-70ad6ff73bcan@googlegroups.com> |
Is there something in it for you?
https://www.w3.org/TR/2021/REC-webaudio-20210617/
Jonas Thörnvall schrieb:
> torsdag 24 juni 2021 kl. 18:07:33 UTC+2 skrev Jonas Thörnvall:
>> torsdag 24 juni 2021 kl. 15:35:33 UTC+2 skrev Jonas Thörnvall:
>>> torsdag 24 juni 2021 kl. 15:07:40 UTC+2 skrev Jonas Thörnvall:
>>>> I am building midi messages "interfacing" a software synth. But i am so terrible reading others codes so i am not sure i understand it correct.
>>>>
>>>> Isn't the bank and modulation messages just checking if byte 1 equal 176 and byte 2 equal 1 if so one should call the modulation function and if byte 2 equal 0 one should call the bnk function?
>>>>
>>>> I will try again but i can't get the bnk and modulation messages to work.
>>>>
>>>> switch (message[0] & 0xf0) {
>>>> case 0x80: // NoteOff: 8n kk vv
>>>> synth.noteOff(channel, message[1], message[2]);
>>>> break;
>>>> case 0x90: // NoteOn: 9n kk vv
>>>> if (message[2] > 0) {
>>>> synth.noteOn(channel, message[1], message[2]);
>>>> } else {
>>>> synth.noteOff(channel, message[1], 0);
>>>> }
>>>> break;
>>>> case 0xB0: // Control Change: Bn cc dd
>>>> /** @type {number} */
>>>> const value = message[2];
>>>> switch (message[1]) {
>>>> case 0x00: // Bank Select MSB: Bn 00 dd
>>>> synth.bankSelectMsb(channel, value);
>>>> break;
>>>> case 0x01: // Modulation Depth
>>>> synth.modulationDepth(channel, value);
>>>> break;
>>>> case 0x05: // Portament Time
>>>> break;
>>>> case 0x06: // Data Entry(MSB): Bn 06 dd
>>>> if (this.rpnMode) {
>>>> // RPN
>>>> switch (this.RpnMsb[channel]) {
>>>> case 0:
>>>> switch (this.RpnLsb[channel]) {
>>>> case 0: // Pitch Bend Sensitivity
>>>> synth.pitchBendSensitivity(channel, value);
>>>> break;
>>>> case 1:
>>>> // console.log("fine");
>>>> break;
>>>> case 2:
>>>> // console.log("coarse");
>>>> break;
>>>> default:
>>>> // console.log("default");
>>>> break;
>>>> }
>>>> break;
>>>> default:
>>>> // console.log("default:", this.RpnMsb[channel], this.RpnLsb[channel]);
>>>> break;
>>>> }
>>> I think there is something very strange i can not quite wrap my head on with web midi link external synth calls, to me it seem what should be sent over net, rather should be a byte length?
>>> The function names are not sent as parameter anyway
>>>
>>> So one could just have 3 type of calls/function "3 byte calls", ""2 byte calls" and "sysex calls of variable length?".
>>> The decomposition is done on the receiver side anyway????
>>>
>>> Here is my sender, i practically send all CC over noteOn problem is bankchanges and modulation do not work and i do not understand why?
>>>
>>> var synth = new Synth();
>>> //To string 16 converts number to hexadecimal value
>>> function Synth() {
>>> this.sy = null;
>>> this.Load = function(url) {
>>> this.sy = window.open(url, "extSynth", "width=700,height=700,scrollbars=yes,resizable=yes");
>>> this.sy.focus();
>>> }
>>> this.NoteOn = function(SFM,note, velo) {
>>> SFM=parseInt(SFM);
>>> note=parseInt(note);
>>> velo=parseInt(velo);
>>> this.SendMessage(this.sy, "midi,"+SFM.toString(16)+"," + note.toString(16) + "," + velo.toString(16));
>>> }
>>> this.NoteOff = function(SFM,note) {
>>> SFM=parseInt(SFM);
>>> note=parseInt(note);
>>> this.SendMessage(this.sy, "midi,"+SFM.toString(16)+","+ note.toString(16) + ",0");
>>> }
>>> this.PGMchange = function(SFchan,SFprg) {
>>> SFprg=parseInt(SFprg);
>>> SFchan=parseInt(SFchan);
>>> this.SendMessage(this.sy, "midi,"+SFchan.toString(16)+","+SFprg.toString(16));
>>> }
>>> //////////Is PGMchange above not same message "type, not content" as noteOff two bytes sent?//////////////////////////////////
>>> /////////////////////////////////////////////////////////////////////////WHY SHOULD THESE FUNCTIONS BE NEEDED///////////////////////////////
>>> ///////////////////////////////////////Or are the function calls somehow passed as argument over net???//////////////////////////////////
>>> /////////////////////////////////////If so i should probably name them correct, but i don't think they are?///////////////////////////////////
>>> this.MODchange = function(SFchan,SFval) {
>>> SFchan=parseInt(SFchan);
>>> SFval=parseInt(SFval);
>>> this.SendMessage(this.sy, "midi,"+SFchan.toString(16)+","+SFval.toString(16));
>>> }
>>> this.BNKchange = function(SFchan,SFbnk) {
>>> SFchan=parseInt(SFchan);
>>> SFval=parseInt(SFbnk);
>>> this.SendMessage(this.sy, "midi,"+SFchan.toString(16)+","+SFbnk.toString(16));
>>> }
>>> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>>> /////////////////////////////////This is another type of message 1byte, probably could named it anything or????////////////////////
>>> this.AllSoundOff = function(offCh) {
>>> offCh=parseInt(offCh);
>>> this.SendMessage(this.sy, "midi,"+offCh.toString(16));
>>> }
>>>
>>> this.SendMessage = function(sy, s) {
>>> if(this.sy)
>>> this.sy.postMessage(s, "*");
>>> }
>>> }
>> If someone want to try send a bankchange message.
>> Here is how you invoke the synth.
>> synth.Load('https://logue.dev/smfplayer.js/wml.html');
>> And here is the actual sender of messages to the synth.
>> Notes, programs and CCmessages seems to work but can't get CC modulation to respond, and sustain that should be a range 0-127 seems to be implemented as a binary state on and off.
>>
>> But the most important thing to get working is bankchange, and i can not make it work.
>> var synth = new Synth();
>> //To string 16 converts number to hexadecimal value
>> function Synth() {
>> this.sy = null;
>> this.Load = function(url) {
>> this.sy = window.open(url, "extSynth", "width=700,height=700,scrollbars=yes,resizable=yes");
>> this.sy.focus();
>> }
>> this.NoteOn = function(SFM,note, velo) {
>> SFM=parseInt(SFM);
>> note=parseInt(note);
>> velo=parseInt(velo);
>> this.SendMessage(this.sy, "midi,"+SFM.toString(16)+"," + note.toString(16) + "," + velo.toString(16));
>> }
>> this.NoteOff = function(SFM,note) {
>> SFM=parseInt(SFM);
>> note=parseInt(note);
>> this.SendMessage(this.sy, "midi,"+SFM.toString(16)+","+ note.toString(16) + ",0");
>> }
>> this.PGMchange = function(SFchan,SFprg) {
>> SFprg=parseInt(SFprg);
>> SFchan=parseInt(SFchan);
>> this.SendMessage(this.sy, "midi,"+SFchan.toString(16)+","+SFprg.toString(16));
>> }
>> this.SendMessage = function(sy, s) {
>> if(this.sy)
>> this.sy.postMessage(s, "*");
>> }
>> }
> Give it a go on my phoneserver so no SSL
> https://84.217.163.187:80/
>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-24 06:07 -0700
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-24 06:35 -0700
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-24 09:07 -0700
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-24 14:00 -0700
Re: Building midi message for a software synth Mostowski Collapse <janburse@fastmail.fm> - 2021-06-25 13:57 +0200
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-25 11:11 -0700
Re: Building midi message for a software synth Mostowski Collapse <janburse@fastmail.fm> - 2021-06-26 11:12 +0200
Re: Building midi message for a software synth Mostowski Collapse <janburse@fastmail.fm> - 2021-06-26 11:19 +0200
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-26 04:20 -0700
Re: Building midi message for a software synth Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-06-26 04:33 -0700
csiph-web