473,395 Members | 2,253 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,395 software developers and data experts.

Getting a click from the PC-speaker?

Can javascript (easily) produce a click from the PC-speaker?
This is the speaker that is (well, used to be) directly on
the CPU-card and was -I believe- intended to give feedback
to the typist, making a click-sound on each keypress.

On Unix/Linux/MacOSX systems, you can hear this click by
typing ^g (control g) into a shell/terminal. This is also
the click made by ^g when it is typed in Emacs, or when
Emacs signals an error.

This doesn't involve the PC's sound card, nor downloading
".wav" files to the user's system.

My general question is: Can javascript make an audible
sound on the user's system (typically, as a consequence of
an "onclick=" event when user clicks on certain parts of
the window) WITHOUT some kind of sound file being
downloaded? (Indeed, the user's computer wouldn't even
need to HAVE a sound card; the PC-speaker is [or, used to
be] directly driven by the kernel.)

Sincerely, -Jonathan King, Mathematics, Univ. of Florida
Jun 27 '08 #1
10 2424
On Wed, 21 May 2008 22:03:44 -0700, gentsquash wrote:
Can javascript (easily) produce a click from the PC-speaker? This is the
speaker that is (well, used to be) directly on the CPU-card and was -I
believe- intended to give feedback to the typist, making a click-sound
on each keypress.
Easily? Not in a cross-platform way.

Your shell/terminal combo can do it because ^g is the ASCII character
for the bell, interpreted by the terminal. In days of old, it rang a
very literal bell on dumb teletype machines.
This doesn't involve the PC's sound card, nor downloading ".wav" files
to the user's system.
On my X11 setup, it does play a WAV file, even in the console. I don't
have a PC speaker so I set up my xterm that way. I have no true console
beep.
My general question is: Can javascript make an audible sound on the
user's system (typically, as a consequence of an "onclick=" event when
user clicks on certain parts of the window) WITHOUT some kind of sound
file being downloaded? (Indeed, the user's computer wouldn't even need
to HAVE a sound card; the PC-speaker is [or, used to be] directly driven
by the kernel.)
You might be able to embed the audio in the 'data' IRL. I've never tried
that though -- and it would fail under IE. (At least version 6, but I
don't think 7 or 8 support the data IRL either.)
Jun 27 '08 #2
On May 22, 12:04 pm, Jeremy J Starcher <r3...@yahoo.comwrote:
On Wed, 21 May 2008 22:03:44 -0700, gentsquash wrote:
Can javascript (easily) produce a click from the PC-speaker? This is the
speaker that is (well, used to be) directly on the CPU-card and was -I
believe- intended to give feedback to the typist, making a click-sound
on each keypress.

Easily? Not in a cross-platform way.

Your shell/terminal combo can do it because ^g is the ASCII character
for the bell, interpreted by the terminal. In days of old, it rang a
very literal bell on dumb teletype machines.
This doesn't involve the PC's sound card, nor downloading ".wav" files
to the user's system.

On my X11 setup, it does play a WAV file, even in the console. I don't
have a PC speaker so I set up my xterm that way. I have no true console
beep.
My general question is: Can javascript make an audible sound on the
user's system (typically, as a consequence of an "onclick=" event when
user clicks on certain parts of the window) WITHOUT some kind of sound
file being downloaded? (Indeed, the user's computer wouldn't even need
to HAVE a sound card; the PC-speaker is [or, used to be] directly driven
by the kernel.)

You might be able to embed the audio in the 'data' IRL. I've never tried
that though -- and it would fail under IE. (At least version 6, but I
don't think 7 or 8 support the data IRL either.)
Jun 27 '08 #3
(I apologize for my erroneous post.)

On May 22, 12:04 pm, Jeremy J Starcher wrote:
On Wed, 21 May 2008 22:03:44 -0700, gentsquash wrote:
Can javascript (easily) produce a click from the PC-speaker? ...
Easily? Not in a cross-platform way. ...
On my X11 setup, it does play a WAV file, even in the console. ...
Thank you Jeremy. Weakening my request...

* Can anyone point me to public-domain WAV (or other common
audio format) files that have a gentle click or beep?

* How do I attach the playing of the file to an "onclick="
event? (At least, under Firefox on MacOS.)

As a javascript beginner, I web-searched and found postings
on JS audio, which I did not understand. The only one that
worked for me was

<embed src="file.wav" autostart="true"
name="sound1" id="sound1"
>Worked for my FF on MacOSX</embed>
However, I have read that <embedis deprecated.
Jun 27 '08 #4
On Thu, 22 May 2008 14:05:53 -0700, gentsquash wrote:
(I apologize for my erroneous post.)
Tis OK, I've done enough of that myself here. Some day I'll learn how to
cancel posts.
On May 22, 12:04 pm, Jeremy J Starcher wrote:
>On Wed, 21 May 2008 22:03:44 -0700, gentsquash wrote:
Can javascript (easily) produce a click from the PC-speaker? ...
>Easily? Not in a cross-platform way. ...
>On my X11 setup, it does play a WAV file, even in the console. ...

Thank you Jeremy. Weakening my request...

* Can anyone point me to public-domain WAV (or other common
audio format) files that have a gentle click or beep?
I can't help you on that one.
>
* How do I attach the playing of the file to an "onclick="
event? (At least, under Firefox on MacOS.)
There was a fairly big discussion about that here earlier.

You can read it at

<URL: http://groups.google.com/group/comp....pt/browse_frm/
thread/42ee834db6d5ad7a/2460fe781cbcb7f3?lnk=st&q=play+audio+group%
3Acomp.lang.javascript#2460fe781cbcb7f3 >
(If that URL does not work, go to
groups.google.com and search for:

why is "how to play a sound with Javascript" such a rare topic?
)
That said, may I ask why you want to play a sound with every keypress?

In most applications I can't see this being a good idea.. sound tends to
annoy most users. (But I can see doing this in a typing tutor program or
a typewriter emulator ;) )
Jun 27 '08 #5
On May 22, 7:50 pm, Jeremy J Starcher <r3...@yahoo.comwrote:
On Thu, 22 May 2008 14:05:53 -0700, gentsquash wrote: ...
* How do I attach the playing of the file to an "onclick="
event? (At least, under Firefox on MacOS.)

There was a fairly big discussion about that here earlier [at]

<URL:http://groups.google.com/group/comp....pt/browse_frm/
thread/42ee834db6d5ad7a/2460fe781cbcb7f3?lnk=st&q=play+audio+group%
3Acomp.lang.javascript#2460fe781cbcb7f3 >
Jeremy, I appreciate the pointer, but it is too involved for my
knowledge
of JS, which started a week ago. I'm hoping that someone running
MacOS
and Firefox can post code that works just for that combination
(assuming
that Quicktime, Flash, and realplayer are installed).
.. may I ask why you want to play a sound with every keypress?

In most applications I can't see this being a good idea.. sound tends to
annoy most users.
The sound is not for a user --it is for ME, as I develop the program.
For
a future abstract algebra class I'll be teaching, I'm converting an
algebraic game that I wrote in Common Lisp into a graphical
version in JS, that my students can use.

It involves clicking on fairly smaller regions in a <table>, and
sometimes
the click isn't registered (it currently uses a "bubbling-up"
technique
that was kindly posted on c.l.j). The click (or rather, its lack) is
so
that *I* know, while developing the program, when a click was not
registered.

Yes, the audio feedback might be useful for a user too, but right now
it
is for me.
--gentsquash, Mathematics dept, Univ. of Florida
Jun 27 '08 #6
On Tue, 27 May 2008 06:10:32 -0700, gentsquash wrote:
On May 22, 7:50 pm, Jeremy J Starcher <r3...@yahoo.comwrote:
>On Thu, 22 May 2008 14:05:53 -0700, gentsquash wrote: ...
* How do I attach the playing of the file to an "onclick="
[URL and discussion snipped]
Jeremy, I appreciate the pointer, but it is too involved for my
knowledge
of JS, which started a week ago. I'm hoping that someone running MacOS
and Firefox can post code that works just for that combination (assuming
that Quicktime, Flash, and realplayer are installed).
That should be a fairly easy combo to find code for. Alas, I've never
actually worked with sound and HTML before so I can't point you towards a
good easy reference.

[On why the sound]
It involves clicking on fairly smaller regions in a <table>, and
sometimes
the click isn't registered (it currently uses a "bubbling-up" technique
that was kindly posted on c.l.j). The click (or rather, its lack) is so
that *I* know, while developing the program, when a click was not
registered.
Ah -- that makes perfect sense.

In similar settings I set up a one-line DIV at the top of the document
and use the much-debated innerHTML to set its status.

Something akin to this -- untested
(onclick -- assuming your table cells have IDs, or however you identify
them)
document.getElementById("status_div").innerHTML = "Click registered on
element " + this.id

(on mousemove)
document.getElementById("status_div").innerHTML = ""

Jun 27 '08 #7
VK
On May 27, 5:10 pm, gentsqu...@gmail.com wrote:
I'm hoping that someone running
MacOS
and Firefox can post code that works just for that combination
(assuming
that Quicktime, Flash, and realplayer are installed).
That supposes to work on any computer able to play .wav files: though
with MacOS and especially with Safari one never can be sure in
anything.
http://transmodal.sourceforge.net/tmp/click.html

Also note that the current Gecko media interfaces are _very_ slow so
it gives a noticeable delay on Firefox and Co. even on a quick
computer, and with quick typing stops playing at all. IE's interfaces
are quick enough unless one is a professional typer.
Jun 27 '08 #8
On May 27, 11:48 am, VK <schools_r...@yahoo.comwrote:
On May 27, 5:10 pm, gentsqu...@gmail.com wrote:
I'm hoping that someone running
MacOS
and Firefox can post code that works just for that combination
(assuming
that Quicktime, Flash, and realplayer are installed).

That supposes to work on any computer able to play .wav files: though
with MacOS and especially with Safari one never can be sure in
anything.http://transmodal.sourceforge.net/tmp/click.html

Also note that the current Gecko media interfaces are _very_ slow so
it gives a noticeable delay on Firefox and Co. even on a quick
computer, and with quick typing stops playing at all. IE's interfaces
are quick enough unless one is a professional typer.
Jun 27 '08 #9
(Somehow I'm misusing the G.G. interface; I'm reposting)

On May 27, 9:40 am, Jeremy J Starcher <r3...@yahoo.comwrote:
On Tue, 27 May 2008 06:10:32 -0700, gentsquash wrote:
On May 22, 7:50 pm, Jeremy J Starcher <r3...@yahoo.comwrote:
[On getting feedback for mouse-clicks]
In similar settings I set up a one-line DIV at the top of the
document and use the much-debated innerHTML to set its status.

Something akin to this -- untested (onclick -- assuming your
table cells have IDs, or however you identify them)

document.getElementById("status_div").innerHTML =
"Click registered on element " + this.id
Thanks Jeremy; that's a good technique that I've noted for future
use. My current need though is for a no-eyes method.

================================================== ==============

On May 27, 11:48 am, VK <schools_r...@yahoo.comwrote:
On May 27, 5:10 pm, gentsqu...@gmail.com wrote:
I'm hoping that someone running MacOS and Firefox can post
code that works just for that combination (assuming that
Quicktime, Flash, and realplayer are installed).

That supposes to work on any computer able to play .wav files:
though with MacOS and especially with Safari one never can be sure
in anything. http://transmodal.sourceforge.net/tmp/click.html
Well this is interesting. Typing in the box of "click.html"
produces no sound on FF (and no error in the Error Console) nor
on Camino. However it _does_ produce a click under Safari.
However, when I copy the small file (and put the sound file in
the appropriate place) then it produces no sound even in Safari.

The file has

<script type="text/javascript">
/*@cc_on @*/
/*@if (@_jscript)
var IE = true;
document.write(''.concat(
'<bgsound src="click.wav" id="Player">'
));
@else @*/
var IE = false;
document.write(''.concat(
'<embed src="click.wav" autostart="false" width="0" height="0" ',
'name="Player" enablejavascript="true"></embed>'
));
/*@end @*/
</script>

Are these @-constructions some kind of macro?

================================================== ==============

A few days ago I accidentally came across a webpage that played
a little whoosh every time the pointer passed over the word
"script". The source loaded tons of external
incomprehensible-to-me javascript files (which didn't seem to do
much, since the page was full of static advertising).

I got the impression that the page invoked Flash to play the
sound. Do any of you know how to do that --perhaps with the
`embed' tag?

Sincerely, -gentsquash, Mathematics dept, Univ. of Florida

Footnote: Unfortunately, I did not bookmark the page, and I
haven't been able to find it again.
Jun 27 '08 #10
On Wed, 28 May 2008 05:36:17 -0700, gentsquash wrote:

[Snip]
Well this is interesting. Typing in the box of "click.html" produces no
sound on FF (and no error in the Error Console) nor on Camino. However
it _does_ produce a click under Safari. However, when I copy the small
file (and put the sound file in the appropriate place) then it produces
no sound even in Safari.

The file has

<script type="text/javascript">
/*@cc_on @*/
/*@if (@_jscript)
var IE = true;
document.write(''.concat(
'<bgsound src="click.wav" id="Player">' ));
@else @*/
var IE = false;
document.write(''.concat(
'<embed src="click.wav" autostart="false" width="0" height="0" ',
'name="Player" enablejavascript="true"></embed>' ));
/*@end @*/
</script>

Are these @-constructions some kind of macro?

Those are a "conditional comment", an MSHTML (Internet explorer) specific
thing. In short, you wrap code in comments (so other browsers will
ignore it) and then tell IE that it is really code and not a comment
after all.
Jun 27 '08 #11

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

Similar topics

0
by: Tony Scarpelli | last post by:
I've been getting a "Server execution failed" error when I click on help lately in visual studio .net 2003. I haven't had the problem before, but I've been installing some of the Pocket PC sdk's...
0
by: raj | last post by:
I had a simple .NET application successfully developed and deployed to a production environment. Out client required another application, which is slightly different from the first application....
1
by: Yoshitha | last post by:
hi i've vb application and i migrated it to vb.net application and it is working fine when i run this in windows 2000 professional where am having dotnetframwork 1.1 and visual studio 2003....
1
by: ComputerGuyCJ | last post by:
I have an application that I've used click-once deployment to publish out to a shared network path. From there I installed the app on a few client machines, including my own. Since then I published...
2
by: CR | last post by:
I am working on the deployment portion of my first click once app. It was created using VS 2003, with an installer, but has been upgraded to VS 2005, and I would like to use click once. I tested...
1
by: Developer | last post by:
Dear Group Member, I am sorry if I have posted this query in wrong group, but since this is connected with ASPO.NET2.0, thought of posting here. I am doing a very simple program where I am...
9
by: ananth | last post by:
Hi all, I have a form which has a button in it.on button click it should generate the list of hardwares installed in a pc and store these values in a string values. how can it be done...
0
by: fredloh | last post by:
i have a database on a server. all users run windows xp and access 2002. running the database on some pc pose no problem while running on some other pc gives the following error message whenever...
41
by: LayneMitch via WebmasterKB.com | last post by:
I was just chating with a few webdevelopers and it was brought to my attention that I need some type of server technology installed on my computer so I could get a visual of how my sites would look...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.