473,748 Members | 2,353 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making the computer speaker beep

Hi everyone,

Let's see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer
speaker beep. I know that whether the computer speaker actually beeps
or not is largely dependent on the OS I'm using. But I'm not so much
concerned about that (at this stage). I just want to know if ANSI C++
provides for this functionality. I'm only interested in ANSI C++, and
not C++ prior to standardization or non-standard C++. I don't want to
know about workarounds in Assembly or another programming language -
this is strictly an ANSI C++ question.

Any help greatly appreciated.

Cheers,

Deets
Jul 22 '05 #1
19 56686
Anon Email wrote:
Hi everyone,

Let's see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer
speaker beep. I know that whether the computer speaker actually beeps
or not is largely dependent on the OS I'm using. But I'm not so much
concerned about that (at this stage). I just want to know if ANSI C++
provides for this functionality. I'm only interested in ANSI C++, and
not C++ prior to standardization or non-standard C++. I don't want to
know about workarounds in Assembly or another programming language -
this is strictly an ANSI C++ question.

Any help greatly appreciated.

There is NO strictly C++ standard API to make and audible beep.

This is platform specific and you may need to use or create a
compatability library to perform this "portably" across all platforms.

Hint - GUI's usually have somw way of doing this.

Jul 22 '05 #2
>Hi everyone,

Let's see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer
speaker beep. I know that whether the computer speaker actually beeps
or not is largely dependent on the OS I'm using. But I'm not so much
concerned about that (at this stage). I just want to know if ANSI C++
provides for this functionality. I'm only interested in ANSI C++, and
not C++ prior to standardization or non-standard C++. I don't want to
know about workarounds in Assembly or another programming language -
this is strictly an ANSI C++ question.

Any help greatly appreciated.

Cheers,

Deets



I don't know which compiler you're using but with my Borland 5.5 Standard
Edition compiler, From the tools drop down menu, I select 'Environment
Options', Preferences tab, and I can select the compiler option to "Beep on
completion".

JB
Jul 22 '05 #3
On 22 Nov 2003 19:44:49 -0800, an********@fast mail.fm (Anon Email)
wrote in comp.lang.c++:
Hi everyone,

Let's see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer
speaker beep. I know that whether the computer speaker actually beeps
or not is largely dependent on the OS I'm using. But I'm not so much
concerned about that (at this stage). I just want to know if ANSI C++
provides for this functionality. I'm only interested in ANSI C++, and
not C++ prior to standardization or non-standard C++. I don't want to
know about workarounds in Assembly or another programming language -
this is strictly an ANSI C++ question.

Any help greatly appreciated.

Cheers,

Deets


The closest you can get in standard C++, or standard C either for that
matter, is to send the '\a' escape sequence to the standard output,
either the stdout stream or the cout object.

The C++ standard inherits this from C, and since it does not supply a
different definition it inherits the one from the C standard:

"\a (alert) Produces an audible or visible alert without changing the
active position."

On most common desktop systems, it produces a beep from the speaker,
assuming the computer has one.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Jul 22 '05 #4
cout << '\a';
Jul 22 '05 #5
Anon Email escribió:
Let's see, now. This question is about the capabilities of ANSI C++. I
want to write and compile code in ANSI C++ that, when compiled, will
make the computer speaker beep; or, at least, SHOULD make the computer


cout << '\a' << flush;

Regards.
Jul 22 '05 #6
Thanks guys,

So it IS possible, by coding for the specific OS in question? I'm not
concerned about portability (yet), I just want to know if it's
possible using ANSI C++ only. Also, I should have added that I didn't
want to do it via escape sequences - that I wanted to produce an
audible beep at a particular frequency and for a given length (sorry
about that). I know it's possible with non-standard C++, but my
question relates to ANSI C++.

Actually, now I have another question: are the beeps that result from
escape sequences a result of code designated in the C++ standard
header files/ library or are they generated by the IDE? Or perhaps
they're a response of the OS to the code? Basically, I want to know if
"/a", for example, calls some sort of beep routine inherent in
standard C++, and where this routine is stored? Help much appreciated.

Cheers,

Deets
Jul 22 '05 #7
Anon Email wrote:

Actually, now I have another question: are the beeps that result from
escape sequences a result of code designated in the C++ standard
header files/ library or are they generated by the IDE? Or perhaps
they're a response of the OS to the code? Basically, I want to know if
"/a", for example, calls some sort of beep routine inherent in
standard C++, and where this routine is stored? Help much appreciated.


Its a system response and whether that response relies in
the device driver, shell, or somewhere else is defined in
your system documents.

Jul 22 '05 #8
Anon Email wrote:
Thanks guys,

So it IS possible, by coding for the specific OS in question? I'm not
concerned about portability (yet), I just want to know if it's
possible using ANSI C++ only.

Well, the proposed way is quite likely to produce a beep if possible.
You don't get more than that.
Also, I should have added that I didn't
want to do it via escape sequences - that I wanted to produce an
audible beep at a particular frequency and for a given length (sorry
about that). I know it's possible with non-standard C++, but my
question relates to ANSI C++.
Then the answer is "no". The C++ standard doesn't even say that it has
to be a beep, and so it doesn't let you set a frequency or length.
The C++ standard actually doens't say anything except that \a mean
alert. I don't know if it inherits the definition from C, and I don't
have the C89 standard, but C99 only says:

\a (alert) Produces an audible or visible alert without changing the
active position.
Actually, now I have another question: are the beeps that result from
escape sequences a result of code designated in the C++ standard
header files/ library or are they generated by the IDE?
The IDE doesn't generate anything at your program's run time. An IDE is
an environment for editing, debugging and compiling your source code.
Or perhaps they're a response of the OS to the code?
It's not defined by the standard where the alert signal comes from or
how it is generated. It's totally up to the implementation. It might
even be a flashing screen (which most Un*x terminals support to
compensate for a possibly missint speaker) instead of a beep.
Basically, I want to know if
"/a", for example, calls some sort of beep routine inherent in
standard C++, and where this routine is stored? Help much appreciated.


No.

Jul 22 '05 #9
> > Basically, I want to know if
"/a", for example, calls some sort of beep routine inherent in
standard C++, and where this routine is stored? Help much appreciated.


No.


Great answers guys. Sorry for all the questions, but I'm rather
inquisitive. I have another one.

Behind this "/a" escape sequence there has to exist some code, right?
Let's forget the results for the moment - whether or not it produces a
speaker beep, a soundcard beep, a flashing screen etc.. Somewhere in
the ANSI C++ libraries (or whatever) there must exist a directive
(code) that replaces "/a" when the code gets compiled. This directive
must include in it code that tells the OS to produce a beep, etc.. The
directive has to exist, or the operating system wouldn't produce the
response!

Is there a way to "view" this directive (code)? Where does this code
lie? Also, Rolf, would you mind telling me where you got this
information?:

C99 only says:

\a (alert) Produces an audible or visible alert without changing the
active position.

Thanks once again for all your help.

Deets
Jul 22 '05 #10

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

Similar topics

9
8434
by: jgcrawford | last post by:
G'day, I'm writing a ringtone manager for nokia ringtones and I'd like to be able to play the ringtone on the PC speaker. I've had some success in DOS with turbo C and its sound(), delay() and nosound(). Is there anything similar for Linux? I know I can make a simple beep with '\a', but that's not what I need. If not, can someone please show me how to do this with the /dev/audio device?
1
1925
by: Hai Ly Hoang | last post by:
Hi, I want to make a beep (like MS-DOS beep, not a beep from sound-card). How to do that ? Thanks
2
1603
by: John S. Ford, MD | last post by:
I'm familiar with the beep function but is there any function that enables you to determine the pitch and duration of a tone produced by the computer's speaker? John
1
3156
by: strancho | last post by:
hi guys: i am rather new to C++. By using beep(hz, duration), I figured out a way to drive computer speaker. However, my project requires me to create sound from the sound card. Do you happen to know how this works? or is there a command like that? I was going to generate it from wave file. However, it is just too cumbershome.. thanks for the help
14
2348
by: v4vijayakumar | last post by:
In computer based, two player, board games, how to make computer play? Are there any formal ways to _teach_ computer, to choose best possible move? I know this is kind of off-topic here. Please redirect me, if there are more appropriate newsgroup. Many thanks.
0
8991
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9376
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6796
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.