• C

PC Speakers and Wav files

Is there a program out there that will read windows .wav files and play them on the PC Speaker (The one connected to the motherboard)
If not how would I go about doing it?
cpa802Asked:
Who is Participating?
 
_Canidae_Commented:
Aah well, I've sent the program to you now.  Too bad scrapdog was right about the sound quality though.  It sounds worse than crap!
0
 
laeuchliCommented:
I don't think there is a program. What you would have to do is find out about the wav file format. Then using some langauge that can talk to the speaker, like powerbasic(www.powerbasic.com) or assembler.
0
 
cpa802Author Commented:
I already know the .wav/RIFF format. I however dont know how to interpert the data for a pc speaker, that is what I want to know if I can't find a program that already does it. If i MUST write it I'd like to do it in C but I dont know how to embed assembler code in to my C code. (I do know a little assembler)
0
Become an IT Security Management Expert

In today’s fast-paced, digitally transformed world of business, the need to protect network data and ensure cloud privacy has never been greater. With a B.S. in Network Operations and Security, you can get the credentials it takes to become an IT security management expert.

 
rbrCommented:
I don't think that it is possible to play a wav-file on the internal speaker.
0
 
newexpertCommented:
Microsoft used to supply speaker.drv for Windows 3.xx, which can play WAV of up to 8 bit 11.025kHz mono over PC speakers.
0
 
cpa802Author Commented:
In pascal you could supply a range of sounds for different lengths of time. Is there a way to do that in C. If anyone knows where I can find any info on general sound programming that would be helpfull too. This myst seem realy strange but im sure it can be done. As newexpert said there used to be a MS driver for it.
0
 
_Canidae_Commented:
A long, long time ago, I found a Pascal program in SWAG that does just what you've asked for.  I just checked now, and I've still got it.  Not entirely sure how good it does the job though.  I could mail it to you if you wanted.
0
 
cpa802Author Commented:
_Canidae_:
I would LOVE a copy :) send your email addy to hades_mop@hotmail.com
and Ill send you an E-mail addy you can send an attachment to (Sorry about the run about but I just dont want to give my school addy out over the net)

If it plays wav files half decient Ill give you the pts for the question.
0
 
laeuchliCommented:
If that does not work, try using the __asm keyword to put asm code in your program.


0
 
scrapdogCommented:
It *is* possible.  However it will sound like crap since the resolution is 1 bit.

When interpreting the samples, normally you just send the whole byte (or word) to the sound device to convert to an analog signal.

However, with the PC speaker, you have to convert the 8 or 16 bit sample to 1 bit!!

Example:  if your file is 8-bit unsigned, you would *click* if the amplitude is between 128 and 255 (by tickling the appropriate port for the PC speaker).  If the sample's amplitude is less than 128, then you would do nothing (i.e. no sound).

If it were 16-bit signed, you would *click* on 49152-65535 or 0-16383, and NOT click on 16384-49151, etc.

In other words, the most significant bit of your sample determines whether or not to emit a click.
0
 
scrapdogCommented:
btw, the amount of assembly code you will need is minimal, if any.  You probably only need code to manipulate the speaker, which should take no more than a few lines.
0
 
cpa802Author Commented:
Tks for the info scrapdog, Im not woried about the sound quality I just want it recognisable.
0
 
cpa802Author Commented:
Youre right It soundl like krap but maybe I can play with the source code. Tks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.