it should be possible but wether you'd agree to the quality produced is another story.
first of all a wav is pulse code modulated (pcm), the pc speaker is pretty much an on-or-off story so there are 2 options... analyze the frequency the wav aims to archieve (gonna be hard if there are multiple frequencies at once) then make the speaker reproduce that frequency, or live with the fact that it can only be 'on' or 'off' and just 'turn it on or off' if the data in the wav reaches a certain pre-set volume/pcm threshold.
also the wav would have a much higher samplerate than the speaker hardware probably can handle (not sure on that, but not being able to set other amplitudes than just 'as much voltage as the thing can handle' or 'zero' with nothing in between is the bigger problem here.
now... the things you want to look into for method 1 is ioctl(x,KIOCSOUND,1193180/desired-freq-in-hz); with 0 obviously being off. KDMKTONE ioctl on an fd on /dev/console seems to be supposed to produce specified tones for a period specified in jiffies.
but if you want to do it properly i'd pick up the datasheet of the chip the speaker is connected to and just address the thing directly without even bothering with /dev/console or any of the linux stuff... so you can indeed, just turn on the voltage, or turn it off. which would give a pcm modulated sound... just without any amplitude variation between 'loud' and 'nothing'.
probably all methods sound like crap anyway...but analyzing the frequency first and then playing back a frequency won't work for music which usually contains multiple frequencies at the same time.
the whole ioctl KIOCSOUND/KDMKTONE seem to rely on the clocktick settings in the kernel, as well as the being present of a /dev/console and a file descriptor to that being open as well. they don't seem to 'just address the i/o pin of the chip the pc beeper is connected to'.
programmable interrupt timer (PIT) intel 8259
i/o port $0042 r/w PIT counter 2, cassette & speaker (XT, AT, PS/2)
basically the usual approach would be to program it with a desired frequency and then it would produce beeps but what you'd want is just 'on' or 'off' so basically 0hz or very low hz, then reprogram the PIT when the data from the wav goes from '1' to 0 to turn it off again... and so on. handling the sample rate of the wav file is up to software like anything else. (take the average or just skip samples if it's too high - it's analog anyway, and you can only produce digital output ;)
It's sounding like you might want to play a sound file located on one system remotely on another system, is this the case? – LawrenceC – 2012-03-28T01:19:04.693