How to make a beep [SOLVED]

New to Gambas? Post your questions here. No question is too silly or too simple.
Post Reply
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

How to make a beep [SOLVED]

Post by JumpyVB »

Is there an easy way to make a beep sound in Gambas? The gb.ncurses component seems to have Screen.Beep() but I couldn't make it work. Besides I am working on a Graphical application.
Last edited by JumpyVB on Friday 21st April 2023 6:29pm, edited 1 time in total.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How to make a beep

Post by cogier »

This is the way I do it. You need gb.sdl2.audio. You then load a music file and play it. This can be a 'beep' or a 2-hour concert. I have attached a 'beep.ogg' file for you to put in your program's main folder.

''Needs gb.sdl2.audio

Public Sub Form_Open()

  Music.Load(Application.Path &/ "beep.ogg")
  Music.Play

End

beep.ogg.tar.gz
(4.28 KiB) Downloaded 65 times
vuott
Posts: 262
Joined: Wednesday 5th April 2017 6:07pm
Location: European Union

Re: How to make a beep

Post by vuott »

Sometimes this question about the beep comes up. Out of curiosity, I'm reporting the discussions, opened in some Gambas forums, related to that topic:

viewtopic.php?f=4&t=1110
https://www.gambas-club.de/viewtopic.php?f=3&t=5226
https://foro.gambas-es.org/viewtopic.php?f=5&t=6884
https://www.gambas-it.org/smf/index.php?topic=324.0
https://www.gambas-it.org/wiki/index.ph ... are_un_bip
Europaeus sum !

Amare memorentes atque deflentes ad mortem silenter labimur.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: How to make a beep

Post by JumpyVB »

vuott wrote: Saturday 8th April 2023 9:13am Sometimes this question about the beep comes up. Out of curiosity, I'm reporting the discussions, opened in some Gambas forums, related to that topic:

viewtopic.php?f=4&t=1110
https://www.gambas-club.de/viewtopic.php?f=3&t=5226
https://foro.gambas-es.org/viewtopic.php?f=5&t=6884
https://www.gambas-it.org/smf/index.php?topic=324.0
https://www.gambas-it.org/wiki/index.ph ... are_un_bip
Very interesting.
JumpyVB
Posts: 75
Joined: Friday 11th September 2020 9:09am

Re: How to make a beep

Post by JumpyVB »

cogier wrote: Saturday 8th April 2023 8:45amThis is the way I do it. You need gb.sdl2.audio.
Public Sub Form_Open()
  Music.Load(Application.Path &/ "beep.ogg")
  Music.Play
End
This works for me. Thank you.

Also found some alternative sound files to use from /usr/share/mint-artwork/sounds/
User avatar
thatbruce
Posts: 161
Joined: Saturday 4th September 2021 11:29pm

Re: How to make a beep

Post by thatbruce »

Thanks from me too Cogier. I have some daily jobs that run for some time, enough time for a couple of games of solitaire or so. So I made your code into a little component with a static function to play a "nice" beep when the job completes. Very simple and works like a charm.
Have you ever noticed that software is never advertised using the adjective "spreadable".
Post Reply