Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #40250

Re: Building midi message for a software synth

Path csiph.com!weretis.net!feeder8.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Mostowski Collapse <janburse@fastmail.fm>
Newsgroups comp.lang.javascript
Subject Re: Building midi message for a software synth
Date Sat, 26 Jun 2021 11:12:36 +0200
Message-ID <sb6r26$eh1$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> <sb4gai$5sa$1@solani.org> <de9322c6-876f-43eb-a2fe-f51324dcbbd2n@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
Injection-Date Sat, 26 Jun 2021 09:12:38 -0000 (UTC)
Injection-Info solani.org; logging-data="14881"; 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:++KIWN/hSIX4pjHRl/ct0EHA//8=
In-Reply-To <de9322c6-876f-43eb-a2fe-f51324dcbbd2n@googlegroups.com>
X-User-ID eJwNysEBwCAIA8CVVELAcTDK/iO09z43TipAJ7y9kcLR2EMwVvgryFvcWj1wO/scdtRS7DnzFXGIDLt2198/YzAV0Q==
Xref csiph.com comp.lang.javascript:40250

Show key headers only | View raw


 From the introduction:

"Audio on the web has been fairly primitive up to this point and until 
very recently has had to be delivered through plugins such as Flash and 
QuickTime. The introduction of the audio element in HTML5 is very 
important, allowing for basic streaming audio playback.

But, it is not powerful enough to handle more complex audio 
applications. For sophisticated web-based games or interactive 
applications, another solution is required. It is a goal of this 
specification to include the capabilities

found in modern game audio engines as well as some of the mixing, 
processing, and filtering tasks that are found in modern desktop
audio production applications."
https://www.w3.org/TR/2021/REC-webaudio-20210617/

Jonas Thörnvall schrieb:
> fredag 25 juni 2021 kl. 13:57:16 UTC+2 skrev Mostowski Collapse:
>> 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/
>>>
> There probably is but i am not much of a reader of content, i rather look at things done and see "if i can figure out"  what going on.
> 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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