DirectX SDK |
This section pertains only to DirectX for Visual Basic. See DirectSound C/C++ Tutorials.
In the Tutorial 1 sample, the sound is loaded onto a sound buffer when the user clicks the Play button. There are actually several steps before the sound is actually played.
First we set the volume and pan level to the value of the associated scroll bars. This is shown in the following two procedures:
Private Sub scrlVol_Scroll(i As Integer) If m_dsBuffer(i) Is Nothing Then Exit Sub m_dsBuffer(i).SetVolume scrlVol(i).Value End Sub Private Sub scrlPan_Scroll(i As Integer) If m_dsBuffer(i) Is Nothing Then Exit Sub m_dsBuffer(i).SetPan scrlPan(i).Value End Sub
Next we determine whether the loop check box is checked:
Dim flag As Long flag = 0 If chLoop(i).Value <> 0 Then flag = 1
If the loop box is checked, the flag variable is set to DSBPLAY_LOOPING which is equal to 1.
Finally we play the sound with the call:
m_dsBuffer(i).Play flag