Ringing the bell

Often I have wished for a simple beep function in SDL. For example,
when someone tries to scroll past the last item in a list, or
backspace past the beginning of an input field, you want to ring the
bell (as they used to say) without having to spin up the whole audio
subsystem.

Presumably this wouldn’t be hard to write; I’m just not sure what the
details are on the less popular platforms. I think that if I were to
write this for myself, it would look something like this:

#include “SDL_syswm.h”

void sdlBeep(void)
{
#if defined(WIN32)
MessageBeep(0);
#elif defined(APPLE)
SysBeep(1);
#elif defined(SDL_VIDEO_DRIVER_X11)
SDL_SysWMInfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);
XBell(info.info.x11.display, 100);
#elif defined(OTHER_CASES)
/* ??? /
#else
/
fallback method (won’t work if stderr is piped to a file) */
fputc(’\a’, stderr);
fflush(stderr);
#endif
}

(And I expect some platform-dependent logic in the Makefile as well.)

But of course it would be SO much nicer if SDL supplied this directly.
It seems like the sort of thing that would be appropriate to SDL – is
there any interest in adding it?

Also, do folks know how to ring the bell on other SDL-supported
platforms?

b

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL? I’d say a BIG step closer to what
you want in life would be to write a library for making a beep noise
yourself.On Mon, Aug 17, 2009 at 6:08 PM, Brian Raiter wrote:

Often I have wished for a simple beep function in SDL. For example,
when someone tries to scroll past the last item in a list, or
backspace past the beginning of an input field, you want to ring the
bell (as they used to say) without having to spin up the whole audio
subsystem.

Presumably this wouldn’t be hard to write; I’m just not sure what the
details are on the less popular platforms. I think that if I were to
write this for myself, it would look something like this:

?#include “SDL_syswm.h”

?void sdlBeep(void)
?{
?#if defined(WIN32)
? ? ?MessageBeep(0);
?#elif defined(APPLE)
? ? ?SysBeep(1);
?#elif defined(SDL_VIDEO_DRIVER_X11)
? ? ?SDL_SysWMInfo info;
? ? ?SDL_VERSION(&info.version);
? ? ?SDL_GetWMInfo(&info);
? ? ?XBell(info.info.x11.display, 100);
?#elif defined(OTHER_CASES)
? ? ?/* ??? /
?#else
? ? ?/
fallback method (won’t work if stderr is piped to a file) */
? ? ?fputc(’\a’, stderr);
? ? ?fflush(stderr);
?#endif
?}

(And I expect some platform-dependent logic in the Makefile as well.)

But of course it would be SO much nicer if SDL supplied this directly.
It seems like the sort of thing that would be appropriate to SDL – is
there any interest in adding it?

Also, do folks know how to ring the bell on other SDL-supported
platforms?

b


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL?

The advantage is that I wouldn’t have to have a bunch of
platform-dependent #ifdefs in my code (and possibly my Makefile). In
other words, pretty much the same reason for using any other feature
of SDL. Consider the fact that most every major platform has a
documented way to sound a simple alert. It’s such a basic feature that
it’s embedded in the ASCII charset. Ringing the alert bell is
traditionally considered a feature of the terminal, not the soundcard.

Obviously, it’s not something that most games need, but for plenty of
other apps, it would certainly be useful. Clearly you don’t agree.

I’d say a BIG step closer to what you want in life would be to write
a library for making a beep noise yourself.

Well, that’s what I’m trying to do. Did you even notice the code I
posted? But of course I don’t know much about platforms that I don’t
have easy access to, so I’m asking for assistance.

In any case, I don’t think such a tiny function merits an entire
library. I mean, so far it’s what? ten lines long.

b

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL?

The advantage is that I wouldn’t have to have a bunch of
platform-dependent #ifdefs in my code (and possibly my Makefile). In
other words, pretty much the same reason for using any other feature
of SDL. Consider the fact that most every major platform has a
documented way to sound a simple alert. It’s such a basic feature that
it’s embedded in the ASCII charset. Ringing the alert bell is
traditionally considered a feature of the terminal, not the soundcard.

You misunderstand.

No matter where the portable beep code lives, it’s going to require
conditional compilation, and it will probably be provided by the
C-preprocessor.

Don’t put that in your application code.

Separate it out into a separate package, and maintain it separately.
Design a portable API that you think suits the features you want to
expose to the API consumer, and that will work with the implementation
details specific to each platform. This is where your #ifdefs and such
will live. Putting it in SDL does not erase the challenge of having
"platform dependent #ifdefs" conditionally expose code to the
compiler.

Obviously, it’s not something that most games need, but for plenty of
other apps, it would certainly be useful. Clearly you don’t agree.

Nothing clear about that. I do agree. I just don’t think you’ll find a
lot of momentum here. The best way to get the SDL community and
maintainers motivated to add beep support, IMHO, is to write the code
yourself, and ask if SDL could include it. Usually, this would mean I
would suggest writing a patch for SDL, but since you don’t want to use
SDL’s audio subsystem, you’re asking for a completely orthogonal
feature set. You could still write it as an SDL patch, but then if
the community doesn’t dig your code, you’d be stuck with a patched SDL
that nobody else had, and your programs would be using SDL APIs that
no one else had, either. If you just write your own library, it might
get incorporated into SDL some day, and in the meantime you’ll have
created a library that I’m sure plenty of projects can use, regardless
of whether or not they use SDL.

I’d say a BIG step closer to what you want in life would be to write
a library for making a beep noise yourself.

Well, that’s what I’m trying to do. Did you even notice the code I
posted? But of course I don’t know much about platforms that I don’t
have easy access to, so I’m asking for assistance.

Ok, here is what I know:

http://linux.die.net/man/3/xkbbell

In any case, I don’t think such a tiny function merits an entire
library. I mean, so far it’s what? ten lines long.

Eh, simpler libraries exist.On Mon, Aug 17, 2009 at 7:17 PM, Brian Raiter wrote:


http://codebad.com/

If you wanted to do things easy, isn’t ascii #7 the bell character?
printf( “\7” );
This should produce a small beep noise, although you will need a
console to output it on…

-AlexOn 8/17/09, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Mon, Aug 17, 2009 at 7:17 PM, Brian Raiter wrote:

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL?

The advantage is that I wouldn’t have to have a bunch of
platform-dependent #ifdefs in my code (and possibly my Makefile). In
other words, pretty much the same reason for using any other feature
of SDL. Consider the fact that most every major platform has a
documented way to sound a simple alert. It’s such a basic feature that
it’s embedded in the ASCII charset. Ringing the alert bell is
traditionally considered a feature of the terminal, not the soundcard.

You misunderstand.

No matter where the portable beep code lives, it’s going to require
conditional compilation, and it will probably be provided by the
C-preprocessor.

Don’t put that in your application code.

Separate it out into a separate package, and maintain it separately.
Design a portable API that you think suits the features you want to
expose to the API consumer, and that will work with the implementation
details specific to each platform. This is where your #ifdefs and such
will live. Putting it in SDL does not erase the challenge of having
"platform dependent #ifdefs" conditionally expose code to the
compiler.

Obviously, it’s not something that most games need, but for plenty of
other apps, it would certainly be useful. Clearly you don’t agree.

Nothing clear about that. I do agree. I just don’t think you’ll find a
lot of momentum here. The best way to get the SDL community and
maintainers motivated to add beep support, IMHO, is to write the code
yourself, and ask if SDL could include it. Usually, this would mean I
would suggest writing a patch for SDL, but since you don’t want to use
SDL’s audio subsystem, you’re asking for a completely orthogonal
feature set. You could still write it as an SDL patch, but then if
the community doesn’t dig your code, you’d be stuck with a patched SDL
that nobody else had, and your programs would be using SDL APIs that
no one else had, either. If you just write your own library, it might
get incorporated into SDL some day, and in the meantime you’ll have
created a library that I’m sure plenty of projects can use, regardless
of whether or not they use SDL.

I’d say a BIG step closer to what you want in life would be to write
a library for making a beep noise yourself.

Well, that’s what I’m trying to do. Did you even notice the code I
posted? But of course I don’t know much about platforms that I don’t
have easy access to, so I’m asking for assistance.

Ok, here is what I know:

http://linux.die.net/man/3/xkbbell

In any case, I don’t think such a tiny function merits an entire
library. I mean, so far it’s what? ten lines long.

Eh, simpler libraries exist.


http://codebad.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ah, Alex beat me to it… I think the common way is printf("\a")?

Jonny DOn Tue, Aug 18, 2009 at 7:18 AM, Alex Barry<alex.barry at gmail.com> wrote:

If you wanted to do things easy, isn’t ascii #7 the bell character?
printf( “\7” );
This should produce a small beep noise, although you will need a
console to output it on…

-Alex

On 8/17/09, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Mon, Aug 17, 2009 at 7:17 PM, Brian Raiter wrote:

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL?

The advantage is that I wouldn’t have to have a bunch of
platform-dependent #ifdefs in my code (and possibly my Makefile). In
other words, pretty much the same reason for using any other feature
of SDL. Consider the fact that most every major platform has a
documented way to sound a simple alert. It’s such a basic feature that
it’s embedded in the ASCII charset. Ringing the alert bell is
traditionally considered a feature of the terminal, not the soundcard.

You misunderstand.

No matter where the portable beep code lives, it’s going to require
conditional compilation, and it will probably be provided by the
C-preprocessor.

Don’t put that in your application code.

Separate it out into a separate package, and maintain it separately.
Design a portable API that you think suits the features you want to
expose to the API consumer, and that will work with the implementation
details specific to each platform. This is where your #ifdefs and such
will live. Putting it in SDL does not erase the challenge of having
"platform dependent #ifdefs" conditionally expose code to the
compiler.

Obviously, it’s not something that most games need, but for plenty of
other apps, it would certainly be useful. Clearly you don’t agree.

Nothing clear about that. I do agree. I just don’t think you’ll find a
lot of momentum here. The best way to get the SDL community and
maintainers motivated to add beep support, IMHO, is to write the code
yourself, and ask if SDL could include it. Usually, this would mean I
would suggest writing a patch for SDL, but since you don’t want to use
SDL’s audio subsystem, you’re asking for a completely orthogonal
feature set. You could still write it as an SDL patch, but then if
the community doesn’t dig your code, you’d be stuck with a patched SDL
that nobody else had, and your programs would be using SDL APIs that
no one else had, either. If you just write your own library, it might
get incorporated into SDL some day, and in the meantime you’ll have
created a library that I’m sure plenty of projects can use, regardless
of whether or not they use SDL.

I’d say a BIG step closer to what you want in life would be to write
a library for making a beep noise yourself.

Well, that’s what I’m trying to do. Did you even notice the code I
posted? But of course I don’t know much about platforms that I don’t
have easy access to, so I’m asking for assistance.

Ok, here is what I know:

http://linux.die.net/man/3/xkbbell

In any case, I don’t think such a tiny function merits an entire
library. I mean, so far it’s what? ten lines long.

Eh, simpler libraries exist.


http://codebad.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I think there are ways to control the beep’s frequency and duration
(in my experience, producing ear-splitting “music”). These are
probably system-dependent and could use a cross-platform wrapper.

Jonny DOn Tue, Aug 18, 2009 at 9:32 AM, Jonathan Dearborn<@Jonathan_Dearborn> wrote:

Ah, Alex beat me to it… ?I think the common way is printf("\a")?

Jonny D

On Tue, Aug 18, 2009 at 7:18 AM, Alex Barry<alex.barry at gmail.com> wrote:

If you wanted to do things easy, isn’t ascii #7 the bell character?
printf( “\7” );
This should produce a small beep noise, although you will need a
console to output it on…

-Alex

On 8/17/09, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Mon, Aug 17, 2009 at 7:17 PM, Brian Raiter wrote:

If it isn’t going to use the SDL audio subsystem, what would be the
advantage of making it part of SDL?

The advantage is that I wouldn’t have to have a bunch of
platform-dependent #ifdefs in my code (and possibly my Makefile). In
other words, pretty much the same reason for using any other feature
of SDL. Consider the fact that most every major platform has a
documented way to sound a simple alert. It’s such a basic feature that
it’s embedded in the ASCII charset. Ringing the alert bell is
traditionally considered a feature of the terminal, not the soundcard.

You misunderstand.

No matter where the portable beep code lives, it’s going to require
conditional compilation, and it will probably be provided by the
C-preprocessor.

Don’t put that in your application code.

Separate it out into a separate package, and maintain it separately.
Design a portable API that you think suits the features you want to
expose to the API consumer, and that will work with the implementation
details specific to each platform. This is where your #ifdefs and such
will live. Putting it in SDL does not erase the challenge of having
"platform dependent #ifdefs" conditionally expose code to the
compiler.

Obviously, it’s not something that most games need, but for plenty of
other apps, it would certainly be useful. Clearly you don’t agree.

Nothing clear about that. I do agree. I just don’t think you’ll find a
lot of momentum here. The best way to get the SDL community and
maintainers motivated to add beep support, IMHO, is to write the code
yourself, and ask if SDL could include it. Usually, this would mean I
would suggest writing a patch for SDL, but since you don’t want to use
SDL’s audio subsystem, you’re asking for a completely orthogonal
feature set. You could still write it as an SDL patch, but then if
the community doesn’t dig your code, you’d be stuck with a patched SDL
that nobody else had, and your programs would be using SDL APIs that
no one else had, either. If you just write your own library, it might
get incorporated into SDL some day, and in the meantime you’ll have
created a library that I’m sure plenty of projects can use, regardless
of whether or not they use SDL.

I’d say a BIG step closer to what you want in life would be to write
a library for making a beep noise yourself.

Well, that’s what I’m trying to do. Did you even notice the code I
posted? But of course I don’t know much about platforms that I don’t
have easy access to, so I’m asking for assistance.

Ok, here is what I know:

http://linux.die.net/man/3/xkbbell

In any case, I don’t think such a tiny function merits an entire
library. I mean, so far it’s what? ten lines long.

Eh, simpler libraries exist.


http://codebad.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This was with straight X Window API (Xlib), but I made a few games on
the Agenda VR3 (the first commerically-available Linux-based PDA) and
used the X bell to play sound effects. :slight_smile:

(The system had a headphone jack for playing real sound, but the system
was a bit underpowered, and most people play games on PDAs w/o plugging in
headphones. The Zaurus was similar… it could beep and click using a
built-in speaker, but for ‘real’ sound you needed headphones or an set
of external speakers.)

-bill!On Tue, Aug 18, 2009 at 09:38:52AM -0400, Jonathan Dearborn wrote:

I think there are ways to control the beep’s frequency and duration
(in my experience, producing ear-splitting “music”). These are
probably system-dependent and could use a cross-platform wrapper.

The Chocolate Doom project (www.chocolate-doom.org) has a PC speaker
emulation library which can attach to the SDL audio core or to
SDL_mixer and provides a fully functional square wave generator.
Chocolate DOOM and my own port, Eternity, use this code to support
the PC speaker format sound effects that were used in DOOM, but
with a little extra work it could be made to play arbitrary sounds.

The best thing about it is that it’s portable; no conditionals are
needed. The worst thing about it is that it has no filtering, and
that I believe listening to it for an extended period of time can
cause damage to your hearing. I certainly know it made my ears
hurt for several hours…----------------------------------------

Date: Mon, 17 Aug 2009 15:08:30 -0700
From: breadbox at muppetlabs.com
To: sdl at lists.libsdl.org
Subject: [SDL] Ringing the bell

Often I have wished for a simple beep function in SDL. For example,
when someone tries to scroll past the last item in a list, or
backspace past the beginning of an input field, you want to ring the
bell (as they used to say) without having to spin up the whole audio
subsystem.

Presumably this wouldn’t be hard to write; I’m just not sure what the
details are on the less popular platforms. I think that if I were to
write this for myself, it would look something like this:

#include “SDL_syswm.h”

void sdlBeep(void)
{
#if defined(WIN32)
MessageBeep(0);
#elif defined(APPLE)
SysBeep(1);
#elif defined(SDL_VIDEO_DRIVER_X11)
SDL_SysWMInfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);
XBell(info.info.x11.display, 100);
#elif defined(OTHER_CASES)
/* ??? /
#else
/
fallback method (won’t work if stderr is piped to a file) */
fputc(’\a’, stderr);
fflush(stderr);
#endif
}

(And I expect some platform-dependent logic in the Makefile as well.)

But of course it would be SO much nicer if SDL supplied this directly.
It seems like the sort of thing that would be appropriate to SDL – is
there any interest in adding it?

Also, do folks know how to ring the bell on other SDL-supported
platforms?

b


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009