Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35720
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-09-29 06:00 -0700 |
| Message-ID | <4e6af619-e801-4f7c-8d72-32dbfea238d3@googlegroups.com> (permalink) |
| Subject | Build messages for websynth via small interface. |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
https://logue.github.io/smfplayer.js/wml2.html
I have this interface below that communicate with websynth above.
Howto send NoteOn / Off and its velocity is all clear to me just my looking at synth interface code.
But there is also a message protocol SendMessage that i am just to slow to grasp,"or it is to unclear".
//Synth interface
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, "*");
}
}
var synth = new Synth();
My confusion probably steem from i do not grasp function (sy,s) if this.sy what is sy, s here in send.Message?
Here is what they tell about the interface
===========================================
MIDI messages are sent with the Javascript window.postMessage() function in string format. This function can transport data without cross domain limitation. Then the string format is simply
"midi,nn[,nn...]"
The "midi" is a ID string and following "nn"s are comma-separated MIDI message bytes represented in hexadecimal.For example, Note-On event will be represented like this : "midi,90,c3,64"
The Web-Synth should be implemented at leaset support Note-On "9n,nn,nn", Note-Off "8n,nn,nn" and All-Sound-Off "bn,78,0". Or a instrument with a sequencer like a rhythm-machine may support MIDI sync messages.
The Host should post one MIDI message in one postMessage(). And should not use the MIDI running status abbreviation.
=================================================
This is the message format create comma separated "strings".
https://www.g200kg.com/en/docs/webmidilink/index.html
Tnn Tempo setting
A,B,C,D,E,F,G Note name. following number is duration.If the duration is 0, the note is polyphonic.
+,#,- sharp/flat
R rest
Vnn channel volume (nn=0-15) "midi,bx,7,(nn)*8"
@nn prog change (nn=0-127) "midi,cx,nn"
CHnn midi channel (nn=1-16)
Lnn default note duration
. Dotted note
Onn Octave
<,> Octave shift
& tie
This is the explanation
https://www.g200kg.com/en/docs/webmidilink/spec.html
It could be that the websynth i load to not support full protocol but i think it does, but probably my lack of reading code to create correct message.
Here is how i send note on/off
synth.NoteOff(message.data[1]));.
synth.NoteOn(message.data[1],message.data[2])}
Men hur sänder jag program eller midi kanals byte? Synthen är slav till sequensern så jag behöver aldrig använda protocol 1 som är för att läsa ut värden från synthen.
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 06:00 -0700
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 06:06 -0700
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 08:14 -0700
Re: Build messages for websynth via small interface. John G Harris <niam@jghnorth.org.uk.invalid> - 2018-09-29 19:01 +0100
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 11:33 -0700
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 11:47 -0700
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 11:52 -0700
Re: Build messages for websynth via small interface. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-09-29 22:29 -0700
csiph-web