Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35720 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2018-09-29 06:00 -0700 |
| Last post | 2018-09-29 22:29 -0700 |
| Articles | 8 — 2 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 06:00 -0700 |
| Subject | Build messages for websynth via small interface. |
| Message-ID | <4e6af619-e801-4f7c-8d72-32dbfea238d3@googlegroups.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.
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 06:06 -0700 |
| Message-ID | <b2e51f4f-8ea9-4f32-a9a2-987c86ca6e89@googlegroups.com> |
| In reply to | #35720 |
Den lördag 29 september 2018 kl. 15:00:57 UTC+2 skrev Jonas Thörnvall:
> 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.
Sorry about the swenglish, having a little wine.....
But howto send program or channel change messages, the synth is slave so i do not need the other double way protocol.
You guys probably adjusted to read other peoples code i just get confused.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 08:14 -0700 |
| Message-ID | <c660e1fb-958e-47f4-b457-1c6b4f397453@googlegroups.com> |
| In reply to | #35721 |
Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
> Den lördag 29 september 2018 kl. 15:00:57 UTC+2 skrev Jonas Thörnvall:
> > 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.
>
> Sorry about the swenglish, having a little wine.....
>
> But howto send program or channel change messages, the synth is slave so i do not need the other double way protocol.
> You guys probably adjusted to read other peoples code i just get confused.
This is the message i send to change program channel according to console.log what is wrong with it?
testMess="midi,@,"+programC;
console.log(testMess);
synth.SendMessage(testMess);
console.log outputs message "midi,192,14"
synth.js:24 Uncaught TypeError: Cannot read property 'split' of undefined
at S.g.onmessage (synth.js:24)
[toc] | [prev] | [next] | [standalone]
| From | John G Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2018-09-29 19:01 +0100 |
| Message-ID | <odfvqdhpcspvs22fb7d6eralrhj4c76a7u@4ax.com> |
| In reply to | #35722 |
On Sat, 29 Sep 2018 08:14:41 -0700 (PDT), Jonas Thörnvall
<jonas.thornvall@gmail.com> wrote:
>Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
>> > this.SendMessage = function(sy, s) {
> synth.SendMessage(testMess);
Compare those two lines
John
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 11:33 -0700 |
| Message-ID | <48f4be81-5b11-4086-a368-c7e8e743ee4e@googlegroups.com> |
| In reply to | #35723 |
Den lördag 29 september 2018 kl. 20:01:17 UTC+2 skrev John G Harris:
> On Sat, 29 Sep 2018 08:14:41 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
> >Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
>
> >> > this.SendMessage = function(sy, s) {
>
> > synth.SendMessage(testMess);
>
> Compare those two lines
>
> John
Yeah and i asked you what is sy, s?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 11:47 -0700 |
| Message-ID | <83ae72f5-03ee-4eed-9e0f-c6e590aef0ba@googlegroups.com> |
| In reply to | #35723 |
Den lördag 29 september 2018 kl. 20:01:17 UTC+2 skrev John G Harris:
> On Sat, 29 Sep 2018 08:14:41 -0700 (PDT), Jonas Thörnvall
> <jonas.thornvall@gmail.com> wrote:
>
> >Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
>
> >> > this.SendMessage = function(sy, s) {
>
> > synth.SendMessage(testMess);
>
> Compare those two lines
>
> John
Should i just put a zero, and think the other argument is the string?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 11:52 -0700 |
| Message-ID | <91309641-2564-4c32-a036-498e4ff97ab7@googlegroups.com> |
| In reply to | #35725 |
Den lördag 29 september 2018 kl. 20:47:24 UTC+2 skrev Jonas Thörnvall:
> Den lördag 29 september 2018 kl. 20:01:17 UTC+2 skrev John G Harris:
> > On Sat, 29 Sep 2018 08:14:41 -0700 (PDT), Jonas Thörnvall
> > <jonas.thornvall@gmail.com> wrote:
> >
> > >Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
> >
> > >> > this.SendMessage = function(sy, s) {
> >
> > > synth.SendMessage(testMess);
> >
> > Compare those two lines
> >
> > John
>
> Should i just put a zero, and think the other argument is the string?
Well i tried it does not change the patch/program/sound.
testMess="midi,@,"+programC;
synth.SendMessage(0,testMess);
What is sy?
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");
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-09-29 22:29 -0700 |
| Message-ID | <d371042c-e68e-482c-9c07-3caa746cd99f@googlegroups.com> |
| In reply to | #35726 |
Den lördag 29 september 2018 kl. 20:52:54 UTC+2 skrev Jonas Thörnvall:
> Den lördag 29 september 2018 kl. 20:47:24 UTC+2 skrev Jonas Thörnvall:
> > Den lördag 29 september 2018 kl. 20:01:17 UTC+2 skrev John G Harris:
> > > On Sat, 29 Sep 2018 08:14:41 -0700 (PDT), Jonas Thörnvall
> > > <jonas.thornvall@gmail.com> wrote:
> > >
> > > >Den lördag 29 september 2018 kl. 15:06:42 UTC+2 skrev Jonas Thörnvall:
> > >
> > > >> > this.SendMessage = function(sy, s) {
> > >
> > > > synth.SendMessage(testMess);
> > >
> > > Compare those two lines
> > >
> > > John
> >
> > Should i just put a zero, and think the other argument is the string?
>
> Well i tried it does not change the patch/program/sound.
> testMess="midi,@,"+programC;
> synth.SendMessage(0,testMess);
>
> What is sy?
> 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");
> }
Well i just can't get the messages to change program or midi channel, but it must work because they use it in this midiplayer.
https://logue.github.io/smfplayer.js/#zip=midifiles%2FYAMAHA%20mididata%20library.zip&file=CLASSIC%2Fcl42xg.mid
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web