Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34419 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2018-01-02 00:44 -0800 |
| Last post | 2018-01-04 01:15 -0800 |
| Articles | 20 on this page of 22 — 2 participants |
Back to article view | Back to comp.lang.javascript
Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 00:44 -0800
Re: Reach MIDI ports using Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-02 11:46 +0100
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 07:14 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 07:23 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 13:53 -0800
Re: Reach MIDI ports using Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-02 22:59 +0100
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 15:22 -0800
Re: Reach MIDI ports using Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-01-03 00:30 +0100
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 16:06 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 16:39 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 16:42 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 16:57 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 01:21 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 09:49 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-02 15:26 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 11:38 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 12:22 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 12:31 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 12:32 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 12:37 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-03 18:00 -0800
Re: Reach MIDI ports using Javascript Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-01-04 01:15 -0800
Page 1 of 2 [1] 2 Next page →
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 00:44 -0800 |
| Subject | Reach MIDI ports using Javascript |
| Message-ID | <7f0b9029-85cc-4d1a-a66d-acf109ba73bf@googlegroups.com> |
Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that? If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated. For those who wonder what i talk about, take a look at Midi in/out on this page. Is it using an api to list the ports? http://www.multiplayerpiano.com/
[toc] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2018-01-02 11:46 +0100 |
| Message-ID | <XnsA85E77C564F0Eeejj99@194.109.6.166> |
| In reply to | #34419 |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02 Jan 2018 in comp.lang.javascript: > Hello i found a couple of sites that let you select windows multimedia > MME? MIDI ports. Is there an api that let you do that? > > If so can i make a local script "application" that generate and trigger > "midi note on off by mouse press", any link to API or a simple script > that just trigger a "note on, note off" using a midiport, would be > highly appreciated. > > For those who wonder what i talk about, take a look at Midi in/out on > this page. Is it using an api to list the ports? > > http://www.multiplayerpiano.com/ You don't start learning how to paint by looking at a confused modern Rembrandt, Picasso or even your 2 year old little couzin doing it. No, you start with the basics, steal somone else's work or go to class. <https://www.youtube.com/watch?v=Rkz80bz_a1g> <https://galactic.ink/midi-js/WhitneyMusicBox.html> <https://github.com/mudcube/MIDI.js/> <https://stackoverflow.com/questions/26910924/simple-midi-js-player-example> .... and tons of examples more. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 07:14 -0800 |
| Message-ID | <62fc710f-5309-4bdc-bf14-d006e7711549@googlegroups.com> |
| In reply to | #34420 |
Den tisdag 2 januari 2018 kl. 11:46:34 UTC+1 skrev Evertjan.: > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02 > Jan 2018 in comp.lang.javascript: > > > Hello i found a couple of sites that let you select windows multimedia > > MME? MIDI ports. Is there an api that let you do that? > > > > If so can i make a local script "application" that generate and trigger > > "midi note on off by mouse press", any link to API or a simple script > > that just trigger a "note on, note off" using a midiport, would be > > highly appreciated. > > > > For those who wonder what i talk about, take a look at Midi in/out on > > this page. Is it using an api to list the ports? > > > > http://www.multiplayerpiano.com/ > > You don't start learning how to paint by looking at a confused modern > Rembrandt, Picasso or even your 2 year old little couzin doing it. > > No, you start with the basics, steal somone else's work or go to class. > > <https://www.youtube.com/watch?v=Rkz80bz_a1g> > > <https://galactic.ink/midi-js/WhitneyMusicBox.html> > > <https://github.com/mudcube/MIDI.js/> > <https://stackoverflow.com/questions/26910924/simple-midi-js-player-example> > > .... and tons of examples more. > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) Well i do not think you need to be either Rembrandt or Picasso to do a little midi, it is basicly about echoing a signal to a midiport, so not even a multiplay site is hard because it is a linear stream of midi messages. What is hard for me is to learn the API for the midi device driver. To hookup and connect the stuff. An echoing server i think i can manage...
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 07:23 -0800 |
| Message-ID | <166af8d1-a728-468d-be88-4e81d1470c32@googlegroups.com> |
| In reply to | #34421 |
Den tisdag 2 januari 2018 kl. 16:14:43 UTC+1 skrev Jonas Thörnvall: > Den tisdag 2 januari 2018 kl. 11:46:34 UTC+1 skrev Evertjan.: > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02 > > Jan 2018 in comp.lang.javascript: > > > > > Hello i found a couple of sites that let you select windows multimedia > > > MME? MIDI ports. Is there an api that let you do that? > > > > > > If so can i make a local script "application" that generate and trigger > > > "midi note on off by mouse press", any link to API or a simple script > > > that just trigger a "note on, note off" using a midiport, would be > > > highly appreciated. > > > > > > For those who wonder what i talk about, take a look at Midi in/out on > > > this page. Is it using an api to list the ports? > > > > > > http://www.multiplayerpiano.com/ > > > > You don't start learning how to paint by looking at a confused modern > > Rembrandt, Picasso or even your 2 year old little couzin doing it. > > > > No, you start with the basics, steal somone else's work or go to class. > > > > <https://www.youtube.com/watch?v=Rkz80bz_a1g> > > > > <https://galactic.ink/midi-js/WhitneyMusicBox.html> > > > > <https://github.com/mudcube/MIDI.js/> > > <https://stackoverflow.com/questions/26910924/simple-midi-js-player-example> > > > > .... and tons of examples more. > > > > -- > > Evertjan. > > The Netherlands. > > (Please change the x'es to dots in my emailaddress) > > Well i do not think you need to be either Rembrandt or Picasso to do a little midi, it is basicly about echoing a signal to a midiport, so not even a multiplay site is hard because it is a linear stream of midi messages. What is hard for me is to learn the API for the midi device driver. To hookup and connect the stuff. An echoing server i think i can manage... I still could use an example though making a single beep tone using the default windows midi music playback device. Because then i can see how to reach interface and send a note, i've done midi before it is pretty rudimentary. And i have no intention generate the midi myself writing hexcode midimessages myself that i have midi instruments for... Possibly i will record a stream and maybe quantise it and save it. And maybe handle a little sysex midi.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 13:53 -0800 |
| Message-ID | <eed26591-7ef8-4d16-9075-6164d4e26dab@googlegroups.com> |
| In reply to | #34422 |
Den tisdag 2 januari 2018 kl. 16:23:23 UTC+1 skrev Jonas Thörnvall:
> Den tisdag 2 januari 2018 kl. 16:14:43 UTC+1 skrev Jonas Thörnvall:
> > Den tisdag 2 januari 2018 kl. 11:46:34 UTC+1 skrev Evertjan.:
> > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02
> > > Jan 2018 in comp.lang.javascript:
> > >
> > > > Hello i found a couple of sites that let you select windows multimedia
> > > > MME? MIDI ports. Is there an api that let you do that?
> > > >
> > > > If so can i make a local script "application" that generate and trigger
> > > > "midi note on off by mouse press", any link to API or a simple script
> > > > that just trigger a "note on, note off" using a midiport, would be
> > > > highly appreciated.
> > > >
> > > > For those who wonder what i talk about, take a look at Midi in/out on
> > > > this page. Is it using an api to list the ports?
> > > >
> > > > http://www.multiplayerpiano.com/
> > >
> > > You don't start learning how to paint by looking at a confused modern
> > > Rembrandt, Picasso or even your 2 year old little couzin doing it.
> > >
> > > No, you start with the basics, steal somone else's work or go to class.
> > >
> > > <https://www.youtube.com/watch?v=Rkz80bz_a1g>
> > >
> > > <https://galactic.ink/midi-js/WhitneyMusicBox.html>
> > >
> > > <https://github.com/mudcube/MIDI.js/>
> > > <https://stackoverflow.com/questions/26910924/simple-midi-js-player-example>
> > >
> > > .... and tons of examples more.
> > >
> > > --
> > > Evertjan.
> > > The Netherlands.
> > > (Please change the x'es to dots in my emailaddress)
> >
> > Well i do not think you need to be either Rembrandt or Picasso to do a little midi, it is basicly about echoing a signal to a midiport, so not even a multiplay site is hard because it is a linear stream of midi messages. What is hard for me is to learn the API for the midi device driver. To hookup and connect the stuff. An echoing server i think i can manage...
>
> I still could use an example though making a single beep tone using the default windows midi music playback device. Because then i can see how to reach interface and send a note, i've done midi before it is pretty rudimentary. And i have no intention generate the midi myself writing hexcode midimessages myself that i have midi instruments for... Possibly i will record a stream and maybe quantise it and save it.
>
> And maybe handle a little sysex midi.
Found a very nice little beginner JS snippet that works very well to access keyboard and beep
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
function success (midi) {
var inputs = midi.inputs.values();
// to tell how many entries there are:
// inputs is an Iterator
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
function failure () {
console.error('No access to your midi devices.')
}
function onMIDIMessage (message) {
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
Unfortunately it do not show how to import the actual port names, but i found a reference to the API on howto make it come into a option list. Problem is it says input undefined?
So what is input supposed to be below and how do i get it into the variable?
It seem it must be something from the midiaccess, as i get it imputportselector is the select ID in html? But what is inputs below and from where should the value be read in?
// to tell how many entries there are:
var numberOfMIDIInputs = inputs.size;
// add each of the ports to a <select> box
inputs.forEach( function( port, key ) {
var opt = document.createElement("option");
opt.text = port.name;
document.getElementById("inputportselector").add(opt);
});
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2018-01-02 22:59 +0100 |
| Message-ID | <XnsA85EE9CD321A0eejj99@194.109.6.166> |
| In reply to | #34421 |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02 Jan 2018 in comp.lang.javascript: > Well i do not think you need to be either Rembrandt or Picasso to do a > little midi, it is basicly about echoing a signal to a midiport, so not > even a multiplay site is hard because it is a linear stream of midi > messages. What is hard for me is to learn the API for the midi device > driver. To hookup and connect the stuff. An echoing server i think i can > manage... But the example you posted as an explanation to your selfconfessed beginners- question was an optimum of possibly confused complexity, full of jquery too. You do not need a professor in first grade. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 15:22 -0800 |
| Message-ID | <6da7ea27-e5cc-4c69-badd-2ab118e3e54c@googlegroups.com> |
| In reply to | #34424 |
Den tisdag 2 januari 2018 kl. 22:59:57 UTC+1 skrev Evertjan.: > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02 > Jan 2018 in comp.lang.javascript: > > > Well i do not think you need to be either Rembrandt or Picasso to do a > > little midi, it is basicly about echoing a signal to a midiport, so not > > even a multiplay site is hard because it is a linear stream of midi > > messages. What is hard for me is to learn the API for the midi device > > driver. To hookup and connect the stuff. An echoing server i think i can > > manage... > > But the example you posted as an explanation to your selfconfessed beginners- > question was an optimum of possibly confused complexity, full of jquery too. > > You do not need a professor in first grade. > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) Jquery there is no jquery into the first part it straightforward and simple just copy it into a js file and run invoked as scr from HTML it works perfect. ***If you have a midikeyboard*** Even i get what it is doing. It even render it's own sound. So it is very nice. The second snippet is from the API papers, and it never tells what inputs supposed to get its values from? **BUT THE JS*** work
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2018-01-03 00:30 +0100 |
| Message-ID | <XnsA85F529BD8E7eejj99@194.109.6.166> |
| In reply to | #34425 |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03 Jan 2018 in comp.lang.javascript: > Jquery there is no jquery into the first part it straightforward and > simple just copy it into a js file and run invoked as scr from HTML it > works perfect. ***If you have a midikeyboard*** Even i get what it is > doing. It even render it's own sound. So it is very nice. > > The second snippet is from the API papers, and it never tells what > inputs supposed to get its values from? You seem to forget what the link was in your first posting in the thread. It is dificult to respond on your postings that way. Perhaps we should not interfere and let you just answer your own postings? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 16:06 -0800 |
| Message-ID | <5346a1d5-d434-4d66-ade3-98d9c9a30db6@googlegroups.com> |
| In reply to | #34427 |
Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.: > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03 > Jan 2018 in comp.lang.javascript: > > > Jquery there is no jquery into the first part it straightforward and > > simple just copy it into a js file and run invoked as scr from HTML it > > works perfect. ***If you have a midikeyboard*** Even i get what it is > > doing. It even render it's own sound. So it is very nice. > > > > The second snippet is from the API papers, and it never tells what > > inputs supposed to get its values from? > > You seem to forget what the link was in your first posting in the thread. > > It is dificult to respond on your postings that way. > > Perhaps we should not interfere and let you just answer your own postings? > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) You have not answered anything so far just questioned.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 16:39 -0800 |
| Message-ID | <f5c3cfde-19fd-47c3-81b6-b85cdb6d2140@googlegroups.com> |
| In reply to | #34428 |
Den onsdag 3 januari 2018 kl. 01:06:48 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.:
> > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03
> > Jan 2018 in comp.lang.javascript:
> >
> > > Jquery there is no jquery into the first part it straightforward and
> > > simple just copy it into a js file and run invoked as scr from HTML it
> > > works perfect. ***If you have a midikeyboard*** Even i get what it is
> > > doing. It even render it's own sound. So it is very nice.
> > >
> > > The second snippet is from the API papers, and it never tells what
> > > inputs supposed to get its values from?
> >
> > You seem to forget what the link was in your first posting in the thread.
> >
> > It is dificult to respond on your postings that way.
> >
> > Perhaps we should not interfere and let you just answer your own postings?
> >
> > --
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
>
> You have not answered anything so far just questioned.
Halfway ;)managed to read in midi ports to select.
But why can't i get the out midi ports, it does not work?
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
//myinputs=MIDIAccess.inputs;
//myoutputs=MIDIAccess.outputs;
//document.write(myinputs);
// add each of the ports to a <select> box
//myinputs.forEach( function( port, key ) {
//
// opt.text = port.name;
// document.getElementById("inputportselector").add(devic);
//});
function success (midi) {
var inputs = midi.inputs.values();
var outputs = midi.outputs.values();
// inputs outputs are Iterators
// for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
// var deviceOut = output.value.name;
// var optout = document.createElement("option");
// optout.text = deviceOut;
// document.getElementById("out_portsel").add(optout);
// each time there is a midi message call the onMIDIMessage function
// output.value.onmidimessage = onMIDIMessage;
//}
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
function failure () {
console.error('No access to your midi devices.')
}
function onMIDIMessage (message) {
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 16:42 -0800 |
| Message-ID | <90a63410-0355-4981-b9ae-1cbcea915756@googlegroups.com> |
| In reply to | #34428 |
Den onsdag 3 januari 2018 kl. 01:06:48 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.:
> > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03
> > Jan 2018 in comp.lang.javascript:
> >
> > > Jquery there is no jquery into the first part it straightforward and
> > > simple just copy it into a js file and run invoked as scr from HTML it
> > > works perfect. ***If you have a midikeyboard*** Even i get what it is
> > > doing. It even render it's own sound. So it is very nice.
> > >
> > > The second snippet is from the API papers, and it never tells what
> > > inputs supposed to get its values from?
> >
> > You seem to forget what the link was in your first posting in the thread.
> >
> > It is dificult to respond on your postings that way.
> >
> > Perhaps we should not interfere and let you just answer your own postings?
> >
> > --
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
>
> You have not answered anything so far just questioned.
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
//myinputs=MIDIAccess.inputs;
//myoutputs=MIDIAccess.outputs;
//document.write(myinputs);
// add each of the ports to a <select> box
//myinputs.forEach( function( port, key ) {
//
// opt.text = port.name;
// document.getElementById("inputportselector").add(devic);
//});
I got the in ports to be read in to select.
function success (midi) {
var inputs = midi.inputs.values();
var outputs = midi.outputs.values();
// inputs outputs are Iterators
// for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
// var deviceOut = output.value.name;
// var optout = document.createElement("option");
// optout.text = deviceOut;
// document.getElementById("out_portsel").add(optout);
// each time there is a midi message call the onMIDIMessage function
// output.value.onmidimessage = onMIDIMessage;
//}
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
function failure () {
console.error('No access to your midi devices.')
}
function onMIDIMessage (message) {
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 16:57 -0800 |
| Message-ID | <64767e11-0e3c-4d6c-9351-787a5f5bc4e3@googlegroups.com> |
| In reply to | #34430 |
Den onsdag 3 januari 2018 kl. 01:42:34 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 01:06:48 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.:
> > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03
> > > Jan 2018 in comp.lang.javascript:
> > >
> > > > Jquery there is no jquery into the first part it straightforward and
> > > > simple just copy it into a js file and run invoked as scr from HTML it
> > > > works perfect. ***If you have a midikeyboard*** Even i get what it is
> > > > doing. It even render it's own sound. So it is very nice.
> > > >
> > > > The second snippet is from the API papers, and it never tells what
> > > > inputs supposed to get its values from?
> > >
> > > You seem to forget what the link was in your first posting in the thread.
> > >
> > > It is dificult to respond on your postings that way.
> > >
> > > Perhaps we should not interfere and let you just answer your own postings?
> > >
> > > --
> > > Evertjan.
> > > The Netherlands.
> > > (Please change the x'es to dots in my emailaddress)
> >
> > You have not answered anything so far just questioned.
>
> var context = new AudioContext(),
> oscillators = {};
>
> if (navigator.requestMIDIAccess) {
> navigator.requestMIDIAccess()
> .then(success, failure);
> }
>
> //myinputs=MIDIAccess.inputs;
> //myoutputs=MIDIAccess.outputs;
> //document.write(myinputs);
> // add each of the ports to a <select> box
> //myinputs.forEach( function( port, key ) {
> //
> // opt.text = port.name;
> // document.getElementById("inputportselector").add(devic);
> //});
>
>
>
> I got the in ports to be read in to select.
>
> function success (midi) {
> var inputs = midi.inputs.values();
> var outputs = midi.outputs.values();
>
> // inputs outputs are Iterators
> // for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
> // var deviceOut = output.value.name;
> // var optout = document.createElement("option");
> // optout.text = deviceOut;
> // document.getElementById("out_portsel").add(optout);
> // each time there is a midi message call the onMIDIMessage function
> // output.value.onmidimessage = onMIDIMessage;
> //}
> for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
> var deviceIn = input.value.name;
> var optin = document.createElement("option");
> optin.text = deviceIn;
> document.getElementById("in_portsel").add(optin);
> // each time there is a midi message call the onMIDIMessage function
> input.value.onmidimessage = onMIDIMessage;
> }
> }
>
> function failure () {
> console.error('No access to your midi devices.')
> }
>
> function onMIDIMessage (message) {
> var frequency = midiNoteToFrequency(message.data[1]);
>
> if (message.data[0] === 144 && message.data[2] > 0) {
> playNote(frequency);
> }
>
> if (message.data[0] === 128 || message.data[2] === 0) {
> stopNote(frequency);
> }
> }
>
> function midiNoteToFrequency (note) {
> return Math.pow(2, ((note - 69) / 12)) * 440;
> }
>
> function playNote (frequency) {
> oscillators[frequency] = context.createOscillator();
> oscillators[frequency].frequency.value = frequency;
> oscillators[frequency].connect(context.destination);
> oscillators[frequency].start(context.currentTime);
> }
>
> function stopNote (frequency) {
> oscillators[frequency].stop(context.currentTime);
> oscillators[frequency].disconnect();
> }
Got it, am satisfied with today.
<html>
<head>
<script src="midi.js"></script>
</head>
<body>
<select name="in_portsel" id="in_portsel" value="3">
</select>
<select name="out_portsel" id="out_portsel" value="3">
</select>
</body>
</html>
[MIDI.JS]
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
function success (midi) {
var inputs = midi.inputs.values();
var outputs = midi.outputs.values();
// inputs outputs are Iterators
for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
var deviceOut = output.value.name;
console.log(deviceOut);
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
// each time there is a midi message call the onMIDIMessage function
output.value.onmidimessage = onMIDIMessage;
}
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
function failure () {
console.error('No access to your midi devices.')
}
function onMIDIMessage (message) {
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 01:21 -0800 |
| Message-ID | <0e35ab20-f5b6-4d79-9144-cf236f52a77c@googlegroups.com> |
| In reply to | #34431 |
Den onsdag 3 januari 2018 kl. 01:57:26 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 01:42:34 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 3 januari 2018 kl. 01:06:48 UTC+1 skrev Jonas Thörnvall:
> > > Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.:
> > > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03
> > > > Jan 2018 in comp.lang.javascript:
> > > >
> > > > > Jquery there is no jquery into the first part it straightforward and
> > > > > simple just copy it into a js file and run invoked as scr from HTML it
> > > > > works perfect. ***If you have a midikeyboard*** Even i get what it is
> > > > > doing. It even render it's own sound. So it is very nice.
> > > > >
> > > > > The second snippet is from the API papers, and it never tells what
> > > > > inputs supposed to get its values from?
> > > >
> > > > You seem to forget what the link was in your first posting in the thread.
> > > >
> > > > It is dificult to respond on your postings that way.
> > > >
> > > > Perhaps we should not interfere and let you just answer your own postings?
> > > >
> > > > --
> > > > Evertjan.
> > > > The Netherlands.
> > > > (Please change the x'es to dots in my emailaddress)
> > >
> > > You have not answered anything so far just questioned.
> >
> > var context = new AudioContext(),
> > oscillators = {};
> >
> > if (navigator.requestMIDIAccess) {
> > navigator.requestMIDIAccess()
> > .then(success, failure);
> > }
> >
> > //myinputs=MIDIAccess.inputs;
> > //myoutputs=MIDIAccess.outputs;
> > //document.write(myinputs);
> > // add each of the ports to a <select> box
> > //myinputs.forEach( function( port, key ) {
> > //
> > // opt.text = port.name;
> > // document.getElementById("inputportselector").add(devic);
> > //});
> >
> >
> >
> > I got the in ports to be read in to select.
> >
> > function success (midi) {
> > var inputs = midi.inputs.values();
> > var outputs = midi.outputs.values();
> >
> > // inputs outputs are Iterators
> > // for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
> > // var deviceOut = output.value.name;
> > // var optout = document.createElement("option");
> > // optout.text = deviceOut;
> > // document.getElementById("out_portsel").add(optout);
> > // each time there is a midi message call the onMIDIMessage function
> > // output.value.onmidimessage = onMIDIMessage;
> > //}
> > for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
> > var deviceIn = input.value.name;
> > var optin = document.createElement("option");
> > optin.text = deviceIn;
> > document.getElementById("in_portsel").add(optin);
> > // each time there is a midi message call the onMIDIMessage function
> > input.value.onmidimessage = onMIDIMessage;
> > }
> > }
> >
> > function failure () {
> > console.error('No access to your midi devices.')
> > }
> >
> > function onMIDIMessage (message) {
> > var frequency = midiNoteToFrequency(message.data[1]);
> >
> > if (message.data[0] === 144 && message.data[2] > 0) {
> > playNote(frequency);
> > }
> >
> > if (message.data[0] === 128 || message.data[2] === 0) {
> > stopNote(frequency);
> > }
> > }
> >
> > function midiNoteToFrequency (note) {
> > return Math.pow(2, ((note - 69) / 12)) * 440;
> > }
> >
> > function playNote (frequency) {
> > oscillators[frequency] = context.createOscillator();
> > oscillators[frequency].frequency.value = frequency;
> > oscillators[frequency].connect(context.destination);
> > oscillators[frequency].start(context.currentTime);
> > }
> >
> > function stopNote (frequency) {
> > oscillators[frequency].stop(context.currentTime);
> > oscillators[frequency].disconnect();
> > }
>
> Got it, am satisfied with today.
> <html>
> <head>
> <script src="midi.js"></script>
> </head>
> <body>
> <select name="in_portsel" id="in_portsel" value="3">
> </select>
> <select name="out_portsel" id="out_portsel" value="3">
> </select>
> </body>
> </html>
>
> [MIDI.JS]
> var context = new AudioContext(),
> oscillators = {};
>
> if (navigator.requestMIDIAccess) {
> navigator.requestMIDIAccess()
> .then(success, failure);
> }
>
>
> function success (midi) {
> var inputs = midi.inputs.values();
> var outputs = midi.outputs.values();
>
> // inputs outputs are Iterators
> for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
> var deviceOut = output.value.name;
> console.log(deviceOut);
> var optout = document.createElement("option");
> optout.text = deviceOut;
> document.getElementById("out_portsel").add(optout);
> // each time there is a midi message call the onMIDIMessage function
> output.value.onmidimessage = onMIDIMessage;
> }
> for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
> var deviceIn = input.value.name;
> var optin = document.createElement("option");
> optin.text = deviceIn;
> document.getElementById("in_portsel").add(optin);
> // each time there is a midi message call the onMIDIMessage function
> input.value.onmidimessage = onMIDIMessage;
> }
> }
>
> function failure () {
> console.error('No access to your midi devices.')
> }
>
> function onMIDIMessage (message) {
> var frequency = midiNoteToFrequency(message.data[1]);
>
> if (message.data[0] === 144 && message.data[2] > 0) {
> playNote(frequency);
> }
>
> if (message.data[0] === 128 || message.data[2] === 0) {
> stopNote(frequency);
> }
> }
>
> function midiNoteToFrequency (note) {
> return Math.pow(2, ((note - 69) / 12)) * 440;
> }
>
> function playNote (frequency) {
> oscillators[frequency] = context.createOscillator();
> oscillators[frequency].frequency.value = frequency;
> oscillators[frequency].connect(context.destination);
> oscillators[frequency].start(context.currentTime);
> }
>
> function stopNote (frequency) {
> oscillators[frequency].stop(context.currentTime);
> oscillators[frequency].disconnect();
> }
What i find a little weird is why they placed the note on message in the loop, of reading in the names but i guess it is all just midi messages with different content?
I try to echo the imput to an output port, but i have not managed to figure out howto do it so far, onMidiMessage "message" hold the object content and you can use console.log to list for example note on message.data[1]
But how can i echo the message to an output port rather then the little oscillator?
If anyone can show me howto send the midi "message" object to one of the output ports i would be greatful.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 09:49 -0800 |
| Message-ID | <28eeca19-0ddf-4748-a379-a3f14882423a@googlegroups.com> |
| In reply to | #34434 |
Den onsdag 3 januari 2018 kl. 10:22:01 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 01:57:26 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 3 januari 2018 kl. 01:42:34 UTC+1 skrev Jonas Thörnvall:
> > > Den onsdag 3 januari 2018 kl. 01:06:48 UTC+1 skrev Jonas Thörnvall:
> > > > Den onsdag 3 januari 2018 kl. 00:30:35 UTC+1 skrev Evertjan.:
> > > > > =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 03
> > > > > Jan 2018 in comp.lang.javascript:
> > > > >
> > > > > > Jquery there is no jquery into the first part it straightforward and
> > > > > > simple just copy it into a js file and run invoked as scr from HTML it
> > > > > > works perfect. ***If you have a midikeyboard*** Even i get what it is
> > > > > > doing. It even render it's own sound. So it is very nice.
> > > > > >
> > > > > > The second snippet is from the API papers, and it never tells what
> > > > > > inputs supposed to get its values from?
> > > > >
> > > > > You seem to forget what the link was in your first posting in the thread.
> > > > >
> > > > > It is dificult to respond on your postings that way.
> > > > >
> > > > > Perhaps we should not interfere and let you just answer your own postings?
> > > > >
> > > > > --
> > > > > Evertjan.
> > > > > The Netherlands.
> > > > > (Please change the x'es to dots in my emailaddress)
> > > >
> > > > You have not answered anything so far just questioned.
> > >
> > > var context = new AudioContext(),
> > > oscillators = {};
> > >
> > > if (navigator.requestMIDIAccess) {
> > > navigator.requestMIDIAccess()
> > > .then(success, failure);
> > > }
> > >
> > > //myinputs=MIDIAccess.inputs;
> > > //myoutputs=MIDIAccess.outputs;
> > > //document.write(myinputs);
> > > // add each of the ports to a <select> box
> > > //myinputs.forEach( function( port, key ) {
> > > //
> > > // opt.text = port.name;
> > > // document.getElementById("inputportselector").add(devic);
> > > //});
> > >
> > >
> > >
> > > I got the in ports to be read in to select.
> > >
> > > function success (midi) {
> > > var inputs = midi.inputs.values();
> > > var outputs = midi.outputs.values();
> > >
> > > // inputs outputs are Iterators
> > > // for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
> > > // var deviceOut = output.value.name;
> > > // var optout = document.createElement("option");
> > > // optout.text = deviceOut;
> > > // document.getElementById("out_portsel").add(optout);
> > > // each time there is a midi message call the onMIDIMessage function
> > > // output.value.onmidimessage = onMIDIMessage;
> > > //}
> > > for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
> > > var deviceIn = input.value.name;
> > > var optin = document.createElement("option");
> > > optin.text = deviceIn;
> > > document.getElementById("in_portsel").add(optin);
> > > // each time there is a midi message call the onMIDIMessage function
> > > input.value.onmidimessage = onMIDIMessage;
> > > }
> > > }
> > >
> > > function failure () {
> > > console.error('No access to your midi devices.')
> > > }
> > >
> > > function onMIDIMessage (message) {
> > > var frequency = midiNoteToFrequency(message.data[1]);
> > >
> > > if (message.data[0] === 144 && message.data[2] > 0) {
> > > playNote(frequency);
> > > }
> > >
> > > if (message.data[0] === 128 || message.data[2] === 0) {
> > > stopNote(frequency);
> > > }
> > > }
> > >
> > > function midiNoteToFrequency (note) {
> > > return Math.pow(2, ((note - 69) / 12)) * 440;
> > > }
> > >
> > > function playNote (frequency) {
> > > oscillators[frequency] = context.createOscillator();
> > > oscillators[frequency].frequency.value = frequency;
> > > oscillators[frequency].connect(context.destination);
> > > oscillators[frequency].start(context.currentTime);
> > > }
> > >
> > > function stopNote (frequency) {
> > > oscillators[frequency].stop(context.currentTime);
> > > oscillators[frequency].disconnect();
> > > }
> >
> > Got it, am satisfied with today.
> > <html>
> > <head>
> > <script src="midi.js"></script>
> > </head>
> > <body>
> > <select name="in_portsel" id="in_portsel" value="3">
> > </select>
> > <select name="out_portsel" id="out_portsel" value="3">
> > </select>
> > </body>
> > </html>
> >
> > [MIDI.JS]
> > var context = new AudioContext(),
> > oscillators = {};
> >
> > if (navigator.requestMIDIAccess) {
> > navigator.requestMIDIAccess()
> > .then(success, failure);
> > }
> >
> >
> > function success (midi) {
> > var inputs = midi.inputs.values();
> > var outputs = midi.outputs.values();
> >
> > // inputs outputs are Iterators
> > for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
> > var deviceOut = output.value.name;
> > console.log(deviceOut);
> > var optout = document.createElement("option");
> > optout.text = deviceOut;
> > document.getElementById("out_portsel").add(optout);
> > // each time there is a midi message call the onMIDIMessage function
> > output.value.onmidimessage = onMIDIMessage;
> > }
> > for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
> > var deviceIn = input.value.name;
> > var optin = document.createElement("option");
> > optin.text = deviceIn;
> > document.getElementById("in_portsel").add(optin);
> > // each time there is a midi message call the onMIDIMessage function
> > input.value.onmidimessage = onMIDIMessage;
> > }
> > }
> >
> > function failure () {
> > console.error('No access to your midi devices.')
> > }
> >
> > function onMIDIMessage (message) {
> > var frequency = midiNoteToFrequency(message.data[1]);
> >
> > if (message.data[0] === 144 && message.data[2] > 0) {
> > playNote(frequency);
> > }
> >
> > if (message.data[0] === 128 || message.data[2] === 0) {
> > stopNote(frequency);
> > }
> > }
> >
> > function midiNoteToFrequency (note) {
> > return Math.pow(2, ((note - 69) / 12)) * 440;
> > }
> >
> > function playNote (frequency) {
> > oscillators[frequency] = context.createOscillator();
> > oscillators[frequency].frequency.value = frequency;
> > oscillators[frequency].connect(context.destination);
> > oscillators[frequency].start(context.currentTime);
> > }
> >
> > function stopNote (frequency) {
> > oscillators[frequency].stop(context.currentTime);
> > oscillators[frequency].disconnect();
> > }
>
> What i find a little weird is why they placed the note on message in the loop, of reading in the names but i guess it is all just midi messages with different content?
>
> I try to echo the imput to an output port, but i have not managed to figure out howto do it so far, onMidiMessage "message" hold the object content and you can use console.log to list for example note on message.data[1]
>
> But how can i echo the message to an output port rather then the little oscillator?
>
> If anyone can show me howto send the midi "message" object to one of the output ports i would be greatful.
This function call look weird to me?
value sent? input.value.onmidimessage = onMIDIMessage;
I do not get it, is input.value.onmidimessage the return value or the parameter to the function?
Also this, could anyone expalin?
input.onmidimessage = echoMIDIMessage;
I just do not get how to actually set the midi output port, and howto echo the midi in message to it. Could someone help me out, also i find the function calls to the left quite confusing?
JS CODE BELOW===============================
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
function echoMIDIMessage( event ) {
if (output) {
output.send( event.data, event.timestamp );
}
}
function failure () {
console.error('No access to your midi devices.'+ + msg )
}
function onMIDISuccess( midiAccess ) {
console.log( "MIDI ready!" );
var input = midiAccess.inputs.entries.next();
if (input)
input.onmidimessage = echoMIDIMessage;
output = midiAccess.outputs.values().next().value;
if (!input || !output)
console.log("Uh oh! Couldn't get i/o ports.");
}
function success (midi) {
var inputs = midi.inputs.values();
var outputs = midi.outputs.values();
// inputs outputs are Iterators
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
//How can i echo the input.value.onmidimessage to output port?
//output=input;
//output.value.onmidimessage = echoMIDIMessage;
}
for (var output = outputs.next(); output && !output.done; output = outputs.next()) {
var deviceOut = output.value.name;
console.log(deviceOut);
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}
}
function changeOutPort(){
HAVENOIDEAHOWTOSETOUTPORT = document.getElementById("out_portsel").value;
}
function onMIDIMessage (message) {
console.log(message.data[1]);
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function SelectElement(valueToSelect)
{
var element = document.getElementById('out_portsel');
element.value = valueToSelect;
return valueToSelect;
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-02 15:26 -0800 |
| Message-ID | <d4536b2c-0f2b-41f9-ada8-22c1402d0657@googlegroups.com> |
| In reply to | #34424 |
Den tisdag 2 januari 2018 kl. 22:59:57 UTC+1 skrev Evertjan.:
> =?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 02
> Jan 2018 in comp.lang.javascript:
>
> > Well i do not think you need to be either Rembrandt or Picasso to do a
> > little midi, it is basicly about echoing a signal to a midiport, so not
> > even a multiplay site is hard because it is a linear stream of midi
> > messages. What is hard for me is to learn the API for the midi device
> > driver. To hookup and connect the stuff. An echoing server i think i can
> > manage...
>
> But the example you posted as an explanation to your selfconfessed beginners-
> question was an optimum of possibly confused complexity, full of jquery too.
>
> You do not need a professor in first grade.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
If you can't get below to work i am not sure what is wrong, "you probably have not midikeyboard?"
HTML FILE
<html>
<head>
<script src="midi.js"></script>
</head>
<body>
</body>
</html>
JS FILE
var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}
function success (midi) {
var inputs = midi.inputs.values();
// inputs is an Iterator
for (var input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
}
function failure () {
console.error('No access to your midi devices.')
}
function onMIDIMessage (message) {
var frequency = midiNoteToFrequency(message.data[1]);
if (message.data[0] === 144 && message.data[2] > 0) {
playNote(frequency);
}
if (message.data[0] === 128 || message.data[2] === 0) {
stopNote(frequency);
}
}
function midiNoteToFrequency (note) {
return Math.pow(2, ((note - 69) / 12)) * 440;
}
function playNote (frequency) {
oscillators[frequency] = context.createOscillator();
oscillators[frequency].frequency.value = frequency;
oscillators[frequency].connect(context.destination);
oscillators[frequency].start(context.currentTime);
}
function stopNote (frequency) {
oscillators[frequency].stop(context.currentTime);
oscillators[frequency].disconnect();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 11:38 -0800 |
| Message-ID | <46403391-e9a8-41a9-b9b6-b7c42c008878@googlegroups.com> |
| In reply to | #34419 |
Den tisdag 2 januari 2018 kl. 09:45:04 UTC+1 skrev Jonas Thörnvall: > Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that? > > If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated. > > For those who wonder what i talk about, take a look at Midi in/out on this page. > Is it using an api to list the ports? > > http://www.multiplayerpiano.com/ I managed to send note data to correct midi out port, but i do not know howto echo midi in to midi out, can someone helpout?
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 12:22 -0800 |
| Message-ID | <3d306faa-4802-4567-956b-c8a0dd2b0b4a@googlegroups.com> |
| In reply to | #34437 |
Den onsdag 3 januari 2018 kl. 20:38:48 UTC+1 skrev Jonas Thörnvall:
> Den tisdag 2 januari 2018 kl. 09:45:04 UTC+1 skrev Jonas Thörnvall:
> > Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that?
> >
> > If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated.
> >
> > For those who wonder what i talk about, take a look at Midi in/out on this page.
> > Is it using an api to list the ports?
> >
> > http://www.multiplayerpiano.com/
>
> I managed to send note data to correct midi out port, but i do not know howto echo midi in to midi out, can someone helpout?
Now i manage to grab and play notes, but that is not what i do want. I just want to echo the in port to the outport and get sustain and other data when play notes. Anyone?
function playnote(message){
console.log(message.data[1]);
output = mid.outputs.get(outportindex);
var noteOnMessage = [0x90, message.data[1], 0x7f];
//Can play a note now but how can i echo the input.value.onmidimessage to output?
output.send( noteOnMessage ); //omitting the timestamp means send immediately.
console.log("was here");
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 12:31 -0800 |
| Message-ID | <7852f3f3-4b88-487d-a44c-cf364b653eb6@googlegroups.com> |
| In reply to | #34438 |
Den onsdag 3 januari 2018 kl. 21:22:46 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 20:38:48 UTC+1 skrev Jonas Thörnvall:
> > Den tisdag 2 januari 2018 kl. 09:45:04 UTC+1 skrev Jonas Thörnvall:
> > > Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that?
> > >
> > > If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated.
> > >
> > > For those who wonder what i talk about, take a look at Midi in/out on this page.
> > > Is it using an api to list the ports?
> > >
> > > http://www.multiplayerpiano.com/
> >
> > I managed to send note data to correct midi out port, but i do not know howto echo midi in to midi out, can someone helpout?
>
> Now i manage to grab and play notes, but that is not what i do want. I just want to echo the in port to the outport and get sustain and other data when play notes. Anyone?
>
> function playnote(message){
> console.log(message.data[1]);
> output = mid.outputs.get(outportindex);
> var noteOnMessage = [0x90, message.data[1], 0x7f];
> //Can play a note now but how can i echo the input.value.onmidimessage to output?
> output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> console.log("was here");
> }
Did it done for today
function playnote(message){
console.log(message.data[1]);
output = mid.outputs.get(outportindex);
var noteOnMessage = [message.data[0], message.data[1], message.data[2]];
//Can play a note now but how can i echo the input.value.onmidimessage to output?
output.send( noteOnMessage ); //omitting the timestamp means send immediately.
console.log("was here");
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 12:32 -0800 |
| Message-ID | <5e5b9bd3-34c4-403a-ba2b-57587215bbc4@googlegroups.com> |
| In reply to | #34439 |
Den onsdag 3 januari 2018 kl. 21:31:19 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 21:22:46 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 3 januari 2018 kl. 20:38:48 UTC+1 skrev Jonas Thörnvall:
> > > Den tisdag 2 januari 2018 kl. 09:45:04 UTC+1 skrev Jonas Thörnvall:
> > > > Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that?
> > > >
> > > > If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated.
> > > >
> > > > For those who wonder what i talk about, take a look at Midi in/out on this page.
> > > > Is it using an api to list the ports?
> > > >
> > > > http://www.multiplayerpiano.com/
> > >
> > > I managed to send note data to correct midi out port, but i do not know howto echo midi in to midi out, can someone helpout?
> >
> > Now i manage to grab and play notes, but that is not what i do want. I just want to echo the in port to the outport and get sustain and other data when play notes. Anyone?
> >
> > function playnote(message){
> > console.log(message.data[1]);
> > output = mid.outputs.get(outportindex);
> > var noteOnMessage = [0x90, message.data[1], 0x7f];
> > //Can play a note now but how can i echo the input.value.onmidimessage to output?
> > output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> > console.log("was here");
> > }
>
> Did it done for today
>
> function playnote(message){
> console.log(message.data[1]);
> output = mid.outputs.get(outportindex);
> var noteOnMessage = [message.data[0], message.data[1], message.data[2]];
> //Can play a note now but how can i echo the input.value.onmidimessage to output?
> output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> console.log("was here");
> }
Program and bankchanges tomorrow.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2018-01-03 12:37 -0800 |
| Message-ID | <5ead7ba0-3dd3-44d6-bbf2-4c4d31febdf6@googlegroups.com> |
| In reply to | #34440 |
Den onsdag 3 januari 2018 kl. 21:32:35 UTC+1 skrev Jonas Thörnvall:
> Den onsdag 3 januari 2018 kl. 21:31:19 UTC+1 skrev Jonas Thörnvall:
> > Den onsdag 3 januari 2018 kl. 21:22:46 UTC+1 skrev Jonas Thörnvall:
> > > Den onsdag 3 januari 2018 kl. 20:38:48 UTC+1 skrev Jonas Thörnvall:
> > > > Den tisdag 2 januari 2018 kl. 09:45:04 UTC+1 skrev Jonas Thörnvall:
> > > > > Hello i found a couple of sites that let you select windows multimedia MME? MIDI ports. Is there an api that let you do that?
> > > > >
> > > > > If so can i make a local script "application" that generate and trigger "midi note on off by mouse press", any link to API or a simple script that just trigger a "note on, note off" using a midiport, would be highly appreciated.
> > > > >
> > > > > For those who wonder what i talk about, take a look at Midi in/out on this page.
> > > > > Is it using an api to list the ports?
> > > > >
> > > > > http://www.multiplayerpiano.com/
> > > >
> > > > I managed to send note data to correct midi out port, but i do not know howto echo midi in to midi out, can someone helpout?
> > >
> > > Now i manage to grab and play notes, but that is not what i do want. I just want to echo the in port to the outport and get sustain and other data when play notes. Anyone?
> > >
> > > function playnote(message){
> > > console.log(message.data[1]);
> > > output = mid.outputs.get(outportindex);
> > > var noteOnMessage = [0x90, message.data[1], 0x7f];
> > > //Can play a note now but how can i echo the input.value.onmidimessage to output?
> > > output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> > > console.log("was here");
> > > }
> >
> > Did it done for today
> >
> > function playnote(message){
> > console.log(message.data[1]);
> > output = mid.outputs.get(outportindex);
> > var noteOnMessage = [message.data[0], message.data[1], message.data[2]];
> > //Can play a note now but how can i echo the input.value.onmidimessage to output?
> > output.send( noteOnMessage ); //omitting the timestamp means send immediately.
> > console.log("was here");
> > }
>
> Program and bankchanges tomorrow.
And midichannel maybe i manage to make something that can load play and save record the midi timed events tomorrow that would be nice.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.javascript
csiph-web