this post was submitted on 13 Oct 2023
10 points (100.0% liked)

Programming

17251 readers
331 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

for a while, I have been using hardware through Linux that uses the beep from the PC speaker. I'm actually really used to it, so when I switched to using hardware with an unusably loud (volume can't be changed) volume (and also different frequency), I started looking into "exporting" the original beep to an audio file that could be played at different volumes and for other purposes.

looking through the internet, however, I haven't found any attempts to represent any actual PC speaker beep in an audio file, so I'm asking you guys if you know how to do so. presumably, the beep is just a short, simple waveform at a certain frequency, but I am not sure what that waveform is, or what the easiest way to do so is.

top 9 comments
sorted by: hot top controversial new old
[–] atheken 3 points 1 year ago (1 children)

You can probably use Audacity to generate a tone. The more you can find out about the specs of the original speaker, the easier it’ll be to generate a new tone.

[–] zolax 1 points 1 year ago

yeah, I'll look into that; the waveform that the PC speaker produces seems to be the standard sound for most PC speakers (something like this).

[–] fettuccinecode 2 points 1 year ago (1 children)

Actually, resulting volume amplitude from pc speaker can be tweaked by using pulse-width modulation (PWM) techniques. It does not work that well with cheap moving-iron pc speaker but still possible to play PCM waveforms with this trick. Some DOS software like games such Pinball Fantasies or MOD players like Inertia Player supported this.

Most classic 1-bit pc speaker info just has codified frequency and time on and off programmatically, so it is suggested to find non-pcm and unlikely varying, non-standardized ways to store this information. 1-bit does not have some specific shape, unless you imagine a square waveform but actually on an analog signal it is far for being real square due to vibration, so you get the Gibbs phenomenon represented by Fourier series primitives (all sounds are just a combination of sine wave harmonics). But you don't throw those primitives to the digital controller, it is just the natural analog resulting effect of sound from digital information.

[–] zolax 1 points 1 year ago (1 children)

thanks. do you know any software that could do play the PC speaker while reducing amplitude, or possibly existing code examples to create this myself? I know of libraries that can beep at different frequencies and lengths, but not with different volumes.

[–] fettuccinecode 2 points 1 year ago

After a quick search engine visit looking for "pwm pc speaker linux", the couple first results seem promising (I didn't test them, however):

https://github.com/xdsopl/pcspkr

https://unix.stackexchange.com/questions/353558/playing-arbitrary-pcm-sound-throught-the-pc-speaker

[–] AdmiralShat 2 points 1 year ago (1 children)

Can anyone see this comment?

[–] zolax 1 points 1 year ago
[–] [email protected] 1 points 1 year ago (1 children)

If you have the hardware, you could record the beep by removing the PC speaker and wiring those terminals directly into an audio recorder or the mic jack on another computer. That way you'd have the exact sound you want.

Understandably not everyone can do this, so an alternative could be to record the sound with a normal microphone and then use software to determine the frequency of the beep so you can recreate it in Audacity or something. I don't know the names of any off by heart, but I'm sure there will be some free ones online.

[–] zolax 2 points 1 year ago

not really able to remove the PC speaker, but in line with @atheken's and your comment, I'll probably generate the tone in Audacity and figure out the frequency with a recording