Path: csiph.com!weretis.net!feeder8.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mostowski Collapse Newsgroups: comp.lang.javascript Subject: Re: Building midi message for a software synth Date: Fri, 25 Jun 2021 13:57:06 +0200 Message-ID: References: <419b4226-1b11-48ca-b1eb-4a3cbf9664e2n@googlegroups.com> <2f9df51d-3949-4b6e-8fdb-2c252e93f34cn@googlegroups.com> <7594c976-2202-40c4-8a34-70ad6ff73bcan@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 25 Jun 2021 11:57:06 -0000 (UTC) Injection-Info: solani.org; logging-data="6026"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:60.0) Gecko/20100101 Firefox/60.0 SeaMonkey/2.53.8 Cancel-Lock: sha1:/Icg5E/rFHhjtYcsN1N8SMlLSLk= X-User-ID: eJwNx8EBwCAIA8CVSk0gjAMq+4/Q3u+43HwHnA4OZzH1aiDU3VetzT4KRf035nNcMGJQDLdzLurtZnZ2h+cHVToVtg== In-Reply-To: <7594c976-2202-40c4-8a34-70ad6ff73bcan@googlegroups.com> Xref: csiph.com comp.lang.javascript:40246 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/ >