Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually driving the PC internal speaker

Tags:

audio

speaker

Is there any way, in any language (C preferred) to interface the PC internal speaker directly under Windows/Linux? (no DOS) I don't want to drive it at a specficic frequency for a given duration (no beep(frq, msecs)), but I'd rather send signals directly.

I suppose it's one bit resolution, so I plan using PWM driving to play wave sounds.

like image 685
kaoD Avatar asked Sep 15 '25 16:09

kaoD


1 Answers

On Linux, you will probably want to make a kernel driver to drive the speaker, and provide eg. a /dev entry for accessing it.

Note that there is already a driver that supports PCM in the Linux kernel, that interfaces as an ALSA driver. Check it out: http://lxr.linux.no/linux+v2.6.39/sound/drivers/pcsp/

The actual hardware interfacing appears to be done in pscp_input.c: pcspkr_do_sound(...)

like image 50
mrb Avatar answered Sep 17 '25 20:09

mrb