[comp.lang.c] DIGITALIZED SOUND ON PC?

zhou@brazil.psych.purdue.edu (Albert Zhou) (11/20/90)

   I want to output some digitalized sound signal to the speaker. The key-
point I figured out is to control the volume of the speaker. While you
can use "sound" to control frequency, Turbo does not provide direct access
to the speaker. I searched throughout my DOS manual and could not find
a interrupt for speaker. Does anybody have any clue on how to access speaker?

dave@tygra.ddmi.com (David Conrad) (11/20/90)

In article <11516@j.cc.purdue.edu> zhou@brazil.psych.purdue.edu (Albert Zhou) writes:
)
)   I want to output some digitalized sound signal to the speaker. The key-
)point I figured out is to control the volume of the speaker. While you
)can use "sound" to control frequency, Turbo does not provide direct access
)to the speaker. I searched throughout my DOS manual and could not find
)a interrupt for speaker. Does anybody have any clue on how to access speaker?

The IBM PC/PS/2's speaker does not have a volume control.  The speaker
is driven by channel 2 of the system timer.  Once channel 2 has been
programmed for the desired frequency two bits in a control I/O port are
used to indicate whether the speaker is on or off.  There is no need to
program the speaker directly as Turbo C's sound() and nosound() functions
provide complete access to it, however if more specific info is desired
follow this up in comp.sys.ibm.pc.hardware as this issue is not related
to C.
--
David R. Conrad
dave@tygra.ddmi.com
-- 
=  CAT-TALK Conferencing Network, Computer Conferencing and File Archive  =
-  1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new'    - 
=  as a login id.  AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET")        =
   E-MAIL Address: dave@DDMI.COM

dzoey@terminus.umd.edu (Joe Herman) (11/20/90)

In article <11516@j.cc.purdue.edu> zhou@brazil.psych.purdue.edu (Albert Zhou) writes:
>
>   I want to output some digitalized sound signal to the speaker. The key-
>point I figured out is to control the volume of the speaker. While you
>can use "sound" to control frequency, Turbo does not provide direct access
>to the speaker. I searched throughout my DOS manual and could not find
>a interrupt for speaker. Does anybody have any clue on how to access speaker?

There is an excellent paper by David Chappell of NCSU on how to do
this for PCs.  There was a posting about it in
comp.sys.ibm.pc.hardware or comp.sys.ibm.ps2.hardware a couple of days
ago.  It's worth reading.  He uses pulse width modulation instead of
pulse amplitude modulation.  I've played the demo and it's pretty
impressive considering the hardware.

			Joe Herman
			U. of Md.

dzoey@terminus.umd.edu


-- 
"Everything is wonderful until you know something about it."

gordon@osiris.cso.uiuc.edu (John Gordon) (11/21/90)

zhou@brazil.psych.purdue.edu (Albert Zhou) writes:


>   I want to output some digitalized sound signal to the speaker. The key-
>point I figured out is to control the volume of the speaker. While you
>can use "sound" to control frequency, Turbo does not provide direct access
>to the speaker. I searched throughout my DOS manual and could not find
>a interrupt for speaker. Does anybody have any clue on how to access speaker?

	If you are trying to output digitized sound from the internal speaker
on a PC, good luck.  The speaker is a very minimal sort of device.  Its only
feature is that it can beep at different frequencies.  It has no "voices" or
anything of the sort.

hls@rwthbs.uucp (H.L. Stahl) (11/26/90)

In article <11516@j.cc.purdue.edu> zhou@brazil.psych.purdue.edu (Albert Zhou) writes:
>
>   I want to output some digitalized sound signal to the speaker. The key-
>point I figured out is to control the volume of the speaker. While you
>can use "sound" to control frequency, Turbo does not provide direct access
>to the speaker. I searched throughout my DOS manual and could not find
>a interrupt for speaker. Does anybody have any clue on how to access speaker?

It's quite as simple:

   #define PB    0x61  /* adress of port B 	       */
   #define CREG  0x43  /* adress of 8253 command register */
   #define LATCH 0x42  /* adress of 8253 latch register   */

   outp(PB, inp(PB) | 3);  /* start sound */

   outp(CREG,0xB6);          /* send 8253 command */
   outp(LATCH, durn & 0xFF); /* LowByte of duration */
   outp(LATCH, durn >> 8  ); /* HighByte of duration */

   outp(PB, inp(PB) & 0xFC);  /* end sound */

Hope this helps!

 |  _      : Hans-Ludwig Stahl, Lehrstuhl fuer Betriebssysteme, RWTH Aachen
 |_|_`__   : Kopernikusstr. 16, D-5100 Aachen, ..49-(0)241-804374
   | |__)  : Domain:  hls@informatik.rwth-aachen.de
     |__)  : uucp:    ...!{seismo,mcvax,uunet}!unido!rwthinf!hls

skrbec@motcid.UUCP (Brad Skrbec) (11/27/90)

gordon@osiris.cso.uiuc.edu (John Gordon) writes:

>zhou@brazil.psych.purdue.edu (Albert Zhou) writes:


>>   I want to output some digitalized sound signal to the speaker. The key-
>>point I figured out is to control the volume of the speaker. While you
>>can use "sound" to control frequency, Turbo does not provide direct access
>>to the speaker. I searched throughout my DOS manual and could not find
>>a interrupt for speaker. Does anybody have any clue on how to access speaker?

>	If you are trying to output digitized sound from the internal speaker
>on a PC, good luck.  The speaker is a very minimal sort of device.  Its only
>feature is that it can beep at different frequencies.  It has no "voices" or
>anything of the sort.

I'm not an expert at digitized sound on the PC using Turbo (pascal, c,
c++ ?), but I beg to differ that it cannot be done at all.  If you
contact komatsu@uhunix.uhcc.hawaii.edu, you will find that he has done
exactly that (played back digitized sounds on the PC) in a program
called REMAC, which will play digitized sounds, created for the
Macintosh, on the PC.  Dave is the moderator of a sound list for REMAC,
which has over 15 meg of various sound files such as the Simpsons,
Star Trek characters, etc.  To be added to the sound list, just put
the phrase: ADD-ME: <your e-mail address> in your message to him.

If you can create sounds from the speaker at the right frequencies,
you can create "voices".  The output isn't "super stereophonic high
quality blah blah blah", but you'll be amazed at how good Robin
Williams saying "Good Morning, Vietnam!" sounds!

------------------------------------------------------------------------------
| Brad Skrbec                | "For it is the doom of men that they forget." |
| Motorola Cellular          |                             -- Merlin         |
| Arlington Heights, IL      | UUCP: uunet!motcid!skrbec                     |
|                            | Internet: motcid!skrbec@uunet.uu.net          |
------------------------------------------------------------------------------

avery@netcom.UUCP (Avery Colter) (12/02/90)

John Gordon writes:

zhou@brazil.psych.purdue.edu (Albert Zhou) writes:


>>   I want to output some digitalized sound signal to the speaker. The key-
>> point I figured out is to control the volume of the speaker. While you
>> can use "sound" to control frequency, Turbo does not provide direct access
>> to the speaker. I searched throughout my DOS manual and could not find
>> a interrupt for speaker. Does anybody have any clue on how to access speaker?

> 	If you are trying to output digitized sound from the internal speaker
> on a PC, good luck.  The speaker is a very minimal sort of device.  Its only
> feature is that it can beep at different frequencies.  It has no "voices" or
> anything of the sort.

Well, my trusty IIGS may lag behind in some areas, but when it comes to music,
come taste the rhythm of a 14-voice synthesizer chip, supported by three
integrated toolboxes, one of which is a processor for a type of musical
scripting language.

I like listening to songs on the shareware program SoundSmith whenever I
start believing all the people who tell me I made a mistake. Makes the
heart warm again it does.


-- 
Avery Ray Colter    {apple|claris}!netcom!avery  {decwrl|mips|sgi}!btr!elfcat
(415) 839-4567   "I feel love has got to come on and I want it:
                  Something big and lovely!"         - The B-52s, "Channel Z"