VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to play a wav file using DirectX

by Muhammad Asif (3 Submissions)
Category: Games
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 7th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to play a wav file using DirectX

API Declarations



Dim DX As New DirectX7
Dim Ds As DirectSound 'The root object
Dim dsBuffer As DirectSoundBuffer 'Note, there is not a fixed number of
Dim bufferDesc As DSBUFFERDESC
Dim waveFormat As WAVEFORMATEX

Rate How to play a wav file using DirectX



Set Ds = DX.DirectSoundCreate("")
Ds.SetCooperativeLevel Me.hWnd, DSSCL_NORMAL

'bufferDesc.lFlags = DSBCAPS_CTRLFREQUENCY Or DSBCAPS_CTRLPAN Or DSBCAPS_CTRLVOLUME Or DSBCAPS_STATIC

waveFormat.nFormatTag = WAVE_FORMAT_PCM
waveFormat.nChannels = 2 'or 2 for stereo.
waveFormat.lSamplesPerSec = 22050
waveFormat.nBitsPerSample = 8 'or 16 for 16bit sounds

'waveFormat.nBlockAlign = waveFormat.nBitsPerSample / 8 * waveFormat.nChannels
'waveFormat.lAvgBytesPerSec = waveFormat.lSamplesPerSec * waveFormat.nBlockAlign

Set dsBuffer = Nothing
Set Laugh = Nothing

Set dsBuffer = Ds.CreateSoundBufferFromFile("type here wave file", bufferDesc, waveFormat)

dsBuffer.Play DSBPLAY_LOOPING



End Sub


Download this snippet    Add to My Saved Code

How to play a wav file using DirectX Comments

No comments have been posted about How to play a wav file using DirectX. Why not be the first to post a comment about How to play a wav file using DirectX.

Post your comment

Subject:
Message:
0/1000 characters