Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a DisplayServer.beep() method to produce an OS beep sound #11179

Open
markeel opened this issue Nov 17, 2024 · 2 comments
Open

Add a DisplayServer.beep() method to produce an OS beep sound #11179

markeel opened this issue Nov 17, 2024 · 2 comments

Comments

@markeel
Copy link

markeel commented Nov 17, 2024

Describe the project you are working on

Writing an editor plugin as an extension that allows access to a command line terminal from within the Godot Editor. This should look and behave as much like a native terminal application as possible. This includes providing a sound when the terminal would normally issue a "bell" sound.

Describe the problem or limitation you are having in your project

Ideally the bell sound would be the same sound heard as part of any other OS function when a bell alert is presented. But currently there is no access to the underlying X11/Mac/Windows API that would allow the OS native bell or beep.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The enhancement would be to expose on the DisplayServer a beep() method that would provide the OS specific beep sound. This would only apply to Linux/Mac/Windows (not Web/Android etc.). It could be a no-op for other platforms like Android/iOS/Web

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Here is an example implementation of different bell or beep sounds.

void DisplayServerX11::beep() const {
	XBell(x11_display, 0);
}


void DisplayServerMacOS::beep() const {
	NSBeep();
}


void DisplayServerWindows::beep() const {
	MessageBeep(MB_OK);
}

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can sort of be worked around, by creating a AudioStreamPlayer and including a sound file that provides a beep, but it would not really match what the user normally experiences outside the Godot editor.

Is there a reason why this should be core and not an add-on in the asset library?

Since it is exposing a feature behind a core function (the DisplayServer) it would need to be part of the core, but it should also be exposed on the GDExtension interface of DisplayServer so that extensions can use it.

@Calinou Calinou changed the title Include cross platform beep sound that matches OS beep Add a DisplayServer.beep() method to produce an OS beep sound Nov 17, 2024
@Calinou
Copy link
Member

Calinou commented Nov 17, 2024

This would go well with Window.request_attention() since you can call it and DisplayServer.beep() at the same time.

@syntaxerror247
Copy link

syntaxerror247 commented Nov 18, 2024

Why not implement it for mobile platforms too? Beeps can be annoying but also a good accessibility feature if used judiciously.
I don't know about iOS but I can implement it for atleast Android.

Additionally, I would want an option to set its intensity. I think it's not possible on desktop platforms to set intensity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants