'===========================================================================
' Subject: AUDIO MIXER                        Date: 06-03-97 (23:59)       
'  Author: Charles Godard                     Code: QB, QBasic, PDS        
'  Origin: FidoNet QUIK_BAS Echo            Packet: SOUND.ABC
'===========================================================================
'>> Has anybody some informations and/or sources to access the basic
'>> functions (volume, bass, treble.....) of a soundblaster card ?

'I wrote this to go along with some code posted by John Woodgate that
'played a CD.  This will control the mixer.  You can use it by starting
'something, like a CD, midi or wave player, then run this sub and it
'will control the audio mixer.

'I just checked to make sure that it stlll works under win95.  John's
'CD code doesn't work under 95 since it wants MSCDEX loaded. (Haven't
'tried to see if MSCDEX would load under win95)

'To go much further with this, your program has to be mixer chip specific.
'The treble, base and other functions use different registers on the
'different cards.  I've got the registers up to the sb16, CT1745 chip.
'I don't know if they would work with the Pro.  Maybe Andras has some
'later info on the registers.

DEFINT A-Z

CALL Volume

SUB Volume
      OUT &H224, &H22
      Rt = INP(&H225) \ &H10: Lt = INP(&H225) AND &HF
    CLS
    PRINT TAB(15);
    PRINT "Arrow Left/right and Ctl-Lt/Rt Arrow to control audio"
    PRINT TAB(30);
    PRINT "Arrow up/dn Master Volume"
    DO
  Kp = 0
  Kp$ = INKEY$
  IF Kp$ <> "" THEN
    IF LEN(Kp$) > 1 THEN
          Kp = -ASC(MID$(Kp$, 2, 1))
          ELSE
          Kp = ASC(LEFT$(Kp$, 1))
    END IF
  END IF

SELECT CASE Kp
CASE IS = -75
'Lower Right 'volume  'arrow rt
IF Lt > 0 THEN Lt = Lt - 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Right Channel Volume  &"; HEX$((Rt * &H10) OR Lt)
CASE IS = -77
'Raise Right 'volume  'arrow lt
IF Lt < 15 THEN Lt = Lt + 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Right Channel Volume  &"; HEX$((Rt * &H10) OR Lt)
CASE IS = -115
'Lower Left 'volume 'ctl left
IF Rt > 0 THEN Rt = Rt - 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Left Channel Volume   &"; HEX$((Rt * &H10) OR Lt)
CASE IS = -116
'Raise Left 'volume 'ctl right
IF Rt < 15 THEN Rt = Rt + 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Left Channel Volume   &"; HEX$((Rt * &H10) OR Lt)
CASE IS = -72    'master volume up
IF Rt < 15 THEN Rt = Rt + 1: OUT &H225, (Rt * &H10) OR Lt
IF Lt < 15 THEN Lt = Lt + 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Master Volume         &"; HEX$((Rt * &H10) OR Lt)
CASE IS = -80   'master volume down
IF Lt > 0 THEN Lt = Lt - 1: OUT &H225, (Rt * &H10) OR Lt
IF Rt > 0 THEN Rt = Rt - 1: OUT &H225, (Rt * &H10) OR Lt
LOCATE 4, 30: PRINT USING "Master Volume         &"; HEX$((Rt * &H10) OR Lt)
END SELECT
LOOP WHILE (Kp <> 27) AND (Kp <> 32)
END SUB
