473,574 Members | 18,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2445
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.co mwrote:
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/42ee834db6d5ad7 a/2460fe781cbcb7f 3?lnk=st&q=play +audio+group%
3Acomp.lang.jav ascript#2460fe7 81cbcb7f3 >
(If that URL does not work, go to
groups.google.c om 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.co mwrote:
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/42ee834db6d5ad7 a/2460fe781cbcb7f 3?lnk=st&q=play +audio+group%
3Acomp.lang.jav ascript#2460fe7 81cbcb7f3 >
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.co mwrote:
>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.getEle mentById("statu s_div").innerHT ML = "Click registered on
element " + this.id

(on mousemove)
document.getEle mentById("statu s_div").innerHT ML = ""

Jun 27 '08 #7
VK
On May 27, 5:10 pm, gentsqu...@gmai l.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...@y ahoo.comwrote:
On May 27, 5:10 pm, gentsqu...@gmai l.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.co mwrote:
On Tue, 27 May 2008 06:10:32 -0700, gentsquash wrote:
On May 22, 7:50 pm, Jeremy J Starcher <r3...@yahoo.co mwrote:
[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.getEle mentById("statu s_div").innerHT ML =
"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...@y ahoo.comwrote:
On May 27, 5:10 pm, gentsqu...@gmai l.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="fals e" width="0" height="0" ',
'name="Player" enablejavascrip t="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
incomprehensibl e-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

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

Similar topics

0
312
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 lately and something got messed up. I've un-installed VS 2003 and reinstalled it as well as the SDK's. I uninstalled the MSDN Library and...
0
1275
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. So I basically use the first application to develop the second application. I have successfully deployed the second application in my development...
1
1317
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. but when i run the same application in XP home edition which is having only framwork 1.1 i am getting the following error.
1
2109
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 a few updates that were recognized by the app, and the users installed them, so everyone's on the most current version. A couple of glitches are...
2
2898
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 the click once functionality for installing this app many times on development pc's and it works great. When I try to install it on a user pc which...
1
1618
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 inserting Grid control, SQL datasource control. I am attaching the default Northwind database to this Sql Datasource and binding this to the grid...
9
2909
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 ,Kindly suggest me some websites or codes that will be more helpfull for my project completion. Thanks in...
0
1211
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 any button on the forms are clicked. the error message is "The expression on click you entered as the event property setting produced the following...
41
3504
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 on the web. I'm completely new to the server technology stuff and don't need anything expensive - only for testing purposes and so other web...
0
1989
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 ((string)(this.GetPropertyValue("Address1")));
0
7820
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8081
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8258
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7835
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8121
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5325
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2255
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1084
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.