[comp.sys.ibm.pc] Speaker Control/Music

tomr@ashtate (Tom Rombouts) (05/26/90)

In article <1990May23.162547.26538@agate.berkeley.edu> wainscot@math.berkeley.edu (Brian Wainscott) writes:
>Is is possible, and if so how, to control the VOLUME of the speaker
>on my PC.  I'm working on some music composition programs, and don't
>want to disturb my whole family while tinkering at 1 am.
>
I was involved in this question about three months ago and recieved
a definitive "no" answer, although there are TSR's that attempt to
shut off the speaker entirely.  (In my experience, I found that 
certain apps seemed to turn it back on.  In some other apps it was
muted, but still slightly audible.)  Please correct me if I am
wrong - I ended up opening the box and physically cutting the
wires!

Tom Rombouts, Ashton-Tate, Voice: (213) 538-7108

mpe@shamash.cdc.com (2375) (05/28/90)

You can seemingly control the speaker volume by alternating the interval
between tones.  An example of a routine is:

      for i:=1 to count do
      begin
        sound(1000);
        nosound;
        delay(volume);
      end;

In this routine, the tone of the sound is the value 1000 and the volume
is somewhat controlled by the delay interval between sounds.  Please note,
the method outlined here only approximates the function you want and the
REAL output tone will be a rather complex combination of the actual sound 
tone and the delay time.  Find someone who knows something about FFT's 
to explain what I mean...

As for a TSR routine to implement this, I leave that to the reader as
an exercise.

The fastest method that I know to implement a solution to control the 
volume of a PC for the purpose of not waking everyone up during midnight
programming sessions is to splice-in a variable resistor is series with
the speaker.

cat *flame*  > /dev/null
.

KRW1@Lehigh (05/28/90)

Yes, it is possible to control the volume of the PC speaker, but
probably not in a way that is suitable for most applications.  The
techniques used for playing digitized sound allow the reproduction of
any audio signal within about a 35 db volume range.  Unfortunately, this
requires increasing the system timer interrupt rate to 8-16KHz, not
giving you time to do much else except service the interrupt on slower
machines.  On the other hand, if you're not interested much in sound
quality, that interrupt rate could probably be lowered.  Haven't tried
it for simple tones.  It might be feasible.  -- Kevin