Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34423
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-01-02 13:53 -0800 |
| References | <7f0b9029-85cc-4d1a-a66d-acf109ba73bf@googlegroups.com> <XnsA85E77C564F0Eeejj99@194.109.6.166> <62fc710f-5309-4bdc-bf14-d006e7711549@googlegroups.com> <166af8d1-a728-468d-be88-4e81d1470c32@googlegroups.com> |
| Message-ID | <eed26591-7ef8-4d16-9075-6164d4e26dab@googlegroups.com> (permalink) |
| Subject | Re: Reach MIDI ports using Javascript |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
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);
});
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web