Volume control, please direct a newbie

Volume control, please direct a newbie

Post by Geir Lauv » Tue, 31 Mar 1998 04:00:00



Hi Folks!

I'm a student trying to reach the volume control. I'm working on a
wav-player that I want to include a volume control in.

I'm greatful for any help, thank you!

Rgds Geir L

 
 
 

Volume control, please direct a newbie

Post by Mike Morrow says remove the x- & -x for a valid email addre » Tue, 31 Mar 1998 04:00:00


I found an 'example' on the web but it was terribly incomplete and did
not work at all, even after a LOT of playing.  I have the MS
Multimedia Guide and it is useless, too.  No examples anywhere!

If anyone has a working volume control, or you get one sent to you,
please post the code or a pointer to it.  I would like to have one,
too.

Thanks,
Mike Morrow

On Mon, 30 Mar 1998 01:10:17 +0200, "Geir Lauve"


>Hi Folks!

>I'm a student trying to reach the volume control. I'm working on a
>wav-player that I want to include a volume control in.

>I'm greatful for any help, thank you!

>Rgds Geir L


 
 
 

Volume control, please direct a newbie

Post by Mike Morrow says remove the x- & -x for a valid email addre » Fri, 03 Apr 1998 04:00:00


Hey, THANKS!!

We got really close here.  This sets the overall volume and the mic
level.  I am still wanting to set the MIDI level.  Maybe I can work on
this in the next few days and find out how to affect the MIDI level.

This is great!  THANKS!!

Mike Morrow

On Wed, 1 Apr 1998 22:20:35 +0200, "Geir Lauve"


>Hi Mike.

>Thanks for answering Mike!

>It seems I found it at last, and the example works. I include a copy (I hope
>this works...)

>Rgds Geir L.

>>I found an 'example' on the web but it was terribly incomplete and did
>>not work at all, even after a LOT of playing.  I have the MS
>>Multimedia Guide and it is useless, too.  No examples anywhere!

>>If anyone has a working volume control, or you get one sent to you,
>>please post the code or a pointer to it.  I would like to have one,
>>too.

>>Thanks,
>>Mike Morrow

 
 
 

Volume control, please direct a newbie

Post by Wayde Wyat » Fri, 03 Apr 1998 04:00:00


Try this:

'-- Used to Get/Set Volume
Declare Function waveoutSetVolume Lib "mmsystem.dll" (ByVal wDeviceID As
Integer, ByVal dwVolumeRight As Integer, ByVal dwVolumeLeft As Integer) As
Integer
Declare Function waveOutGetVolume Lib "MMSYSTEM.DLL" (ByVal wDeviceID As
Integer, lpdwvolume As Long) As Integer
Declare Function midioutSetVolume Lib "mmsystem.dll" (ByVal wDeviceID As
Integer, ByVal dwVolumeRight As Integer, ByVal dwVolumeLeft As Integer) As
Integer
Declare Function midiOutGetVolume Lib "MMSYSTEM.DLL" (ByVal wDeviceID As
Integer, lpdwvolume As Long) As Integer

'============================================
'-- WAVE Device capabilities
'============================================
'  general constants
Global Const MAXPNAMELEN = 32           '  max product name length
(including NULL)
Global Const MAXERRORLENGTH = 128       '  max error text length (including
NULL)

Type WAVEOUTCAPS
    wMid As Integer                  '  manufacturer ID
    wPid As Integer                  '  product ID
    vDriverVersion As Integer        '  version of the driver
    szPname As String * MAXPNAMELEN  '  product name (NULL terminated
string)
    dwFormats As Long                '  formats supported
    wChannels As Integer             '  number of sources supported
    dwSupport As Long                '  functionality supported by driver
End Type

'  flags for dwSupport field of WAVEOUTCAPS
Global Const WAVECAPS_PITCH = &H1                '  supports pitch control
Global Const WAVECAPS_PLAYBACKRATE = &H2         '  supports playback rate
control
Global Const WAVECAPS_VOLUME = &H4               '  supports volume control
Global Const WAVECAPS_LRVOLUME = &H8             '  separate left-right
volume control
Global Const WAVECAPS_SYNC = &H10

Declare Function waveOutGetNumDevs Lib "MMSYSTEM" () As Integer
Declare Function waveOutGetDevCaps Lib "MMSYSTEM" (ByVal udeviceid As
Integer, lpCaps As WAVEOUTCAPS, ByVal uSize As Integer) As Integer

'============================================
'  MIDI output device capabilities structure
'============================================
Type MIDIOUTCAPS
    wMid As Integer                  '  manufacturer ID
    wPid As Integer                  '  product ID
    vDriverVersion As Integer        '  version of the driver
    szPname As String * MAXPNAMELEN  '  product name (NULL terminated
string)
    wTechnology As Integer           '  type of device
    wVoices As Integer               '  # of voices (internal synth only)
    wNotes As Integer                '  max # of notes (internal synth only)
    wChannelMask As Integer          '  channels used (internal synth only)
    dwSupport As Long                '  functionality supported by driver
End Type

'  flags for wTechnology field of MIDIOUTCAPS structure
Global Const MOD_MIDIPORT = 1      '  output port
Global Const MOD_SYNTH = 2         '  generic internal synth
Global Const MOD_SQSYNTH = 3       '  square wave internal synth
Global Const MOD_FMSYNTH = 4       '  FM internal synth
Global Const MOD_MAPPER = 5        '  MIDI mapper

'  flags for dwSupport field of MIDIOUTCAPS structure
Global Const MIDICAPS_VOLUME = &H1               '  supports volume control
Global Const MIDICAPS_LRVOLUME = &H2             '  separate left-right
volume control
Global Const MIDICAPS_CACHE = &H4

Declare Function midiOutGetNumDevs Lib "MMSYSTEM" () As Integer
Declare Function midiOutGetDevCaps Lib "MMSYSTEM" (ByVal udeviceid As
Integer, lpCaps As MIDIOUTCAPS, ByVal uSize As Integer) As Integer

Sub um_WaveSetVolume (DeviceID%, VolumeRight&, VolumeLeft&)
    Dim Rtn%

    Rtn% = waveoutSetVolume%(DeviceID%, CInt("&H" & Hex$(VolumeRight&)),
CInt("&H" & Hex$(VolumeLeft&)))

End Sub

Sub um_WaveGetVolume (DeviceID%, VolumeRight&, VolumeLeft&)
    Dim Rtn%
    Dim BothVolumes&

    ' Note that the waveid is 0 indicating the first wavefile.
    ' If you were to play multiple wavefiles you would use
    ' 1 for the second, 2 for the third and so on.
    ' This code will retrieve the current volume setting
    Rtn% = waveOutGetVolume(DeviceID%, BothVolumes&)

    ' This code isolates the low-order word.
    ' Note that the value &HFFFF& is a Long Integer, which is the same
    ' as 0000FFFF, but because Visual Basic would automatically
    ' truncate this to FFFF, you must force the logical operation to use
    ' a four-byte Long Integer (0000FFFF) rather than a two-byte Integer
    ' (FFFF). This is accomplished by using the type casting
    ' character (&).
    VolumeLeft& = BothVolumes& And &HFFFF&

    ' This code isolates the high-order word.
    ' Enter the following two lines as one, single line:
    VolumeRight& = ((BothVolumes& And &HFFFF0000) / &H10000) And &HFFFF&

End Sub

Sub um_MidiSetVolume (DeviceID%, VolumeRight&, VolumeLeft&)
    Dim Rtn%

    Rtn% = midioutSetVolume%(DeviceID%, CInt("&H" & Hex$(VolumeRight&)),
CInt("&H" & Hex$(VolumeLeft&)))

End Sub

Sub um_MidiGetVolume (DeviceID%, VolumeRight&, VolumeLeft&)
    Dim Rtn%
    Dim BothVolumes&

    ' Note that the waveid is 0 indicating the first wavefile.
    ' If you were to play multiple wavefiles you would use
    ' 1 for the second, 2 for the third and so on.
    ' This code will retrieve the current volume setting
    Rtn% = midiOutGetVolume(DeviceID%, BothVolumes&)

    ' This code isolates the low-order word.
    ' Note that the value &HFFFF& is a Long Integer, which is the same
    ' as 0000FFFF, but because Visual Basic would automatically
    ' truncate this to FFFF, you must force the logical operation to use
    ' a four-byte Long Integer (0000FFFF) rather than a two-byte Integer
    ' (FFFF). This is accomplished by using the type casting
    ' character (&).
    VolumeLeft& = BothVolumes& And &HFFFF&

    ' This code isolates the high-order word.
    ' Enter the following two lines as one, single line:
    VolumeRight& = ((BothVolumes& And &HFFFF0000) / &H10000) And &HFFFF&

End Sub

Sub um_WaveGetDevices (arrDeviceID%(), arrDeviceName$())
'======================================================================
' DESCRIPTION
'   Returns a 1-based array of wave devices installed on
'   the system.  If there are no wave devices, the array
'   is redimmed (0).
'
' PARAMS
'
' NOTES
'
'======================================================================
    Dim DevCount%, Rtn%, Index%
    Dim tWaveOutCaps As WAVEOUTCAPS

    ReDim arrDeviceID%(0)
    ReDim arrDeviceName$(0)

    DevCount% = waveOutGetNumDevs%()

    If DevCount% > 0 Then

        ReDim arrDeviceID%(1 To DevCount% + 1)
        ReDim arrDeviceName$(1 To DevCount% + 1)

        For Index% = 0 To DevCount% - 1

            Rtn% = waveOutGetDevCaps(Index%, tWaveOutCaps,
Len(tWaveOutCaps))
            If Rtn% = 0 Then
                arrDeviceID%(Index% + 1) = Index%
                arrDeviceName$(Index% + 1) = tWaveOutCaps.szPname
            Else
                MsgBox "Error & " & Rtn%
            End If

        Next Index%
    End If
End Sub

Sub um_MidiGetDevices (arrDeviceID%(), arrDeviceName$())
'======================================================================
' DESCRIPTION
'   Returns a 1-based array of midi devices installed on
'   the system.  If there are no midi devices, the array
'   is redimmed (0).
'
' PARAMS
'
' NOTES
'
'======================================================================
    Dim DevCount%, Rtn%, Index%
    Dim tMidiOutCaps As MIDIOUTCAPS

    ReDim arrDeviceID%(0)
    ReDim arrDeviceName$(0)

    DevCount% = midiOutGetNumDevs%()

    If DevCount% > 0 Then

        ReDim arrDeviceID%(1 To DevCount% + 1)
        ReDim arrDeviceName$(1 To DevCount% + 1)

        '-- Midi Mapper is always -1 and is not
        '   returned by midiOutGetNumDevs
        arrDeviceID%(1) = -1
        arrDeviceName$(1) = "Midi Mapper"

        For Index% = 0 To DevCount% - 1

            Rtn% = midiOutGetDevCaps(Index%, tMidiOutCaps,
Len(tMidiOutCaps))
            If Rtn% = 0 Then
                arrDeviceID%(Index% + 2) = Index%
                arrDeviceName$(Index% + 2) = tMidiOutCaps.szPname
            Else
                MsgBox "Error & " & Rtn%
            End If

        Next Index%
    End If
End Sub

Hope this helps...

Geir Lauve wrote in message <6fmkc7$gc...@bone.globalone.no>...
>Hi Folks!

>I'm a student trying to reach the volume control. I'm working on a
>wav-player that I want to include a volume control in.

>I'm greatful for any help, thank you!

>Rgds Geir L