'===========================================================================
' Subject: SB INPUT L/R MASTER VOLUME         Date: 09-07-96 (19:51)       
'  Author: Beau Schwabe                       Code: QB, QBasic, PDS        
'  Origin: comp.lang.basic.misc             Packet: SOUND.ABC
'===========================================================================
'>Has anybody knows how to read or rather calculate the volume from the 
'>input-port in the SB ? I've been trying to figure it out for some time
'>now but have sofar been unsuccesful.

DECLARE SUB MasterVolume (Right%, Left%, Getvol%)
CLS
BasePort% = &H220 'You might have to change this

'this puts the mixer volumes in Right% and Left%
MasterVolume Right%, Left%, -1 

PRINT "Master volume is set at: Right-"; Right%; " Left-"; Left%

'this cranks the master volume all the way up.
MasterVolume 15, 15, 0 


SUB MasterVolume (Right%, Left%, Getvol%)
    SHARED BasePort%
    OUT BasePort% + 4, &H22
    IF Getvol% THEN
       Left% = INP(BasePort% + 5) \ 16
       Right% = INP(BasePort% + 5) AND &HF
       EXIT SUB
    ELSE
       OUT BasePort% + 5, (Right% + Left% * 16) AND &HFF
    END IF
END SUB
