473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using javascript to handle midi events?

Hey, I've been searching for info on this for days now, but to no
avail. I'm starting to think it's impossible, but anyway!

I've coded a little virtual keyboard, which has two octaves worth of
keys on it, and when the keyboard image is clicked, it uses the
coordinates to determine what key was pressed, then some stuff happens
that we needn't worry about. I want to make the keys play the
appropriate note when clicked, and I can't figure out how to do it.
Obviously I could create individual midis for each note that could be
pressed, and maybe preload the entire thing for quicker response. But
that is trash, especially if I expand the keyboard to full size (which
I will dammit).

Is there a way to just send a midi event, consisting only of the one
note, and have it play?

Sep 25 '06 #1
6 2010

di***********@gmail.com wrote:
Hey, I've been searching for info on this for days now, but to no
avail. I'm starting to think it's impossible, but anyway!

I've coded a little virtual keyboard, which has two octaves worth of
keys on it, and when the keyboard image is clicked, it uses the
coordinates to determine what key was pressed, then some stuff happens
that we needn't worry about. I want to make the keys play the
appropriate note when clicked, and I can't figure out how to do it.
Obviously I could create individual midis for each note that could be
pressed, and maybe preload the entire thing for quicker response. But
that is trash, especially if I expand the keyboard to full size (which
I will dammit).

Is there a way to just send a midi event, consisting only of the one
note, and have it play?
If you're using a web browser that supports data URIs
(http://en.wikipedia.org/wiki/Data:_URI ), then you can basically write
a one note MIDI file as a data URL to the source of an embed or other
media type that supports MIDI.

Unfortunately, guess which widely prevalent browser doesn't support
data URIs?

It may be IE has some other kind of built-in proprietary media object
that can handle this, tho'.

Sep 25 '06 #2
weston wrote:
di***********@gmail.com wrote:
>Hey, I've been searching for info on this for days now, but to no
avail. I'm starting to think it's impossible, but anyway!

I've coded a little virtual keyboard, which has two octaves worth of
keys on it, and when the keyboard image is clicked, it uses the
coordinates to determine what key was pressed, then some stuff happens
that we needn't worry about. I want to make the keys play the
appropriate note when clicked, and I can't figure out how to do it.
Obviously I could create individual midis for each note that could be
pressed, and maybe preload the entire thing for quicker response. But
that is trash, especially if I expand the keyboard to full size (which
I will dammit).

Is there a way to just send a midi event, consisting only of the one
note, and have it play?

If you're using a web browser that supports data URIs
(http://en.wikipedia.org/wiki/Data:_URI ), then you can basically write
a one note MIDI file as a data URL to the source of an embed or other
media type that supports MIDI.

Unfortunately, guess which widely prevalent browser doesn't support
data URIs?

It may be IE has some other kind of built-in proprietary media object
that can handle this, tho'.
That is fascinating. I had never heard of that scheme before.

I wonder what the overhead would be of opening a one-note midi file
every time a note is played? I would probably just pre-load some wave
sounds using a large set of embedded sound files and play the
appropriate one on the click of a certain key.

Jeremy
Sep 25 '06 #3
ASM
di***********@gmail.com a écrit :
>
Is there a way to just send a midi event, consisting only of the one
note, and have it play?
No ! not by JavaScript.

Long time ago NC came with AudioLive, a plug-in to play midi files
that you could send JS commands (in certain conditions not so easy).

Now, there are so much plug-in to play sounds, you can no more address
whatever it is

Best way would be to create a Flash file for your piano.
(but Flash knows only mp3)

--
ASM
Sep 26 '06 #4

ASM wrote:
Best way would be to create a Flash file for your piano.
(but Flash knows only mp3)
I know little about Flash, but if Flash knows QuickTime, then it could
possibly also do MIDI.

Of course, you're back to the same problem: can you actually generate
the MIDI data and then play it? Or do you have preload a few
dozen/hundred MIDI/Quicktime files, one for each playable note?

I also understand QuickTime is scriptable via Javascript... though I
don't know to what degree. Still, if you could even tell it to play a
segment of a movie containing MIDI events, you could load a single
movie and play time-addressed portions of it according to which notes
you wanted to play....

Oct 2 '06 #5
On 2006-10-03 01:30:36 +0200, "weston"
<no***********************************@canncentral .orgsaid:
I also understand QuickTime is scriptable via Javascript... though I
don't know to what degree. Still, if you could even tell it to play a
segment of a movie containing MIDI events, you could load a single
movie and play time-addressed portions of it according to which notes
you wanted to play....
QuickTime is indeed scriptable to that extent, but only in Safari so
far (they're working to make a standardized interface that would work
in FF).
I'm not sure it would respond fast enough, but the theory is correct.

For the full specifications of the plugin's JavaScript interface, see
http://developer.apple.com/documenta...singJavaScript
--
David Junger

Oct 3 '06 #6

di***********@gmail.com wrote:
I've coded a little virtual keyboard, which has two octaves worth of
keys on it, and when the keyboard image is clicked, it uses the [...]

Is there a way to just send a midi event, consisting only of the one
note, and have it play?
I don't know about MIDI, but if you Google for "javascript piano",
there's some stuff that might help.

Kev

Oct 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Max M | last post by:
If anybody is interrested in Midi, but are not on the Python Midi list, I will just notify that I have released the first version of a high level midi package for Python. It is fully functional....
2
by: Mad Scientist Jr | last post by:
any sample code or information would be most appreciated i have been wanting to learn MIDI programming but would rather learn it in my current language (either vb.net or c#)
11
by: Kuba Araszkiewicz | last post by:
Hello! I have to write a program, which would convert midi files to notes, notes to midi files and which would make one MIDI file from two different. I'm totally lame in C (and any other...
2
by: david | last post by:
1.I am considering doing a midi file generator for my 4th year project in B.SC. 2.I would do it using c language, but i'm not sure abou t the level of difficulyt involved 3.Basically, the...
9
by: outstretchedarm | last post by:
How exactly does HTML/Javascript handle playing midi files? Does it have a player imbedded in it? Or does it borrow from the computer's midi player? How could you make a webpage play certain...
6
by: shror | last post by:
i want to add a midi file to my pages and i want to put two radio buttons so that on is on and the other is off so that the users can start or stop the file playing by choosing one of the radio...
6
by: Gilly | last post by:
Hi I am trying to create an application that uses some form of input to create a midi file. I would like for this to be a 'real time' process. In other words, I want to be able to begin playing...
6
by: =?ISO-8859-2?Q?Maciej_Blizi=F1ski?= | last post by:
For the last couple of days, I've been looking for a Python midi library. I'm generally interested in sending MIDI events via ALSA. It seems like everything out there is pretty old; packages are...
1
by: dj_redface | last post by:
Hello, For a university project I am trying to write a program that will turn vocal commands into MIDI events. For example if the user says A, a note "A" will be played. I am trying to write...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.