Playing wavs and buffering wavs

11-07-2001, 03:43 AM
Ok in my game i dont want to use direct x as i have no idea on how to use it
but to use API commands instead

I need to buffer 2 wav files

and then be able to play them

and is it possible to play both sounds at the same time?

wild wolf
11-07-2001, 03:57 AM
check this post out, in this post attached is my game which uses Direct Sound, and there is also some ref fpart=
if the link does not work, just go to this post DS-Help me Debug by Wild Wolf (thats me)
any prob, ask

wild wolf
11-07-2001, 04:01 AM
or u can go to this link, there is a very good tutorial by Squirm there fpart=, if this link does not work, go to tutors corner in the main menu and look for DS tutorial

11-07-2001, 06:09 AM
Try searching the forum for sndPlaySound.
For a lower level solution you'll need to do some research into the waveOut API functions. I'll warning you now, it ain't nice.

wild wolf
11-08-2001, 12:25 AM
i think DirectSound will be easier rather than take him into API which is more complicated

11-08-2001, 01:50 AM
Can someone just write me an example , not from another tutorial

on how to use the directx sound

What I need is :

To back buffer two sounds
And then Play the two sounds

I dont want any excess code!

Basically i want it this way

Buffer(SoundFile1) as #1
Buffer(SoundFile2) as #2

PlaySound #1
PlaySound #2

wild wolf
11-08-2001, 04:11 AM
ill help u there,
first u need to initialise ur variables,

#Const COMPILING = False
Dim DirectX7Obj As New DirectX7
Dim DirectSoundObj As DirectSound
Dim startmusic As DirectSoundBuffer 'startmusic is a variable
Dim crashmusic As DirectSoundBuffer '

Sub InitDirectSound()
On Local Error Resume Next
Set DirectSoundObj = DirectX7Obj.DirectSoundCreate("")
If Err.number <> 0 Then
MsgBox "DirectSound initialization failed."
End If
DirectSoundObj.SetCooperativeLevel Me.hWnd, DSSCL_PRIORITY
End Sub
Function CreateSound(FileName As String) As DirectSoundBuffer

Dim DSBuffer As DirectSoundBuffer

DSWave.nChannels = 2
DSWave.lSamplesPerSec = 22050
DSWave.nBitsPerSample = 16
DSWave.nBlockAlign = DSWave.nBitsPerSample / 8 * DSWave.nChannels
DSWave.lAvgBytesPerSec = DSWave.lSamplesPerSec * DSWave.nBlockAlign

Set DSBuffer = DirectSoundObj.CreateSoundBufferFromFile(FileName, DSDesc, DSWave)

Set CreateSound = DSBuffer

End Function

Sub PlaySound(Sound As DirectSoundBuffer, _
CloseFirst As Boolean, LoopSound As Boolean)
If CloseFirst Then
Sound.SetCurrentPosition 0
End If
If LoopSound Then
Sound.Play 1
Sound.Play 0
End If
End Sub

Sub StopSound(Sound As DirectSoundBuffer, _
CloseFirst As Boolean)
If CloseFirst Then
Sound.SetCurrentPosition 0
End If
End Sub

Sub CreateSounds()
Set startmusic = CreateSound("hem6.wav") 'pathname of ur file 1
Set crashmusic = CreateSound("Car Crash.wav") 'pathname of ur file 2
Set startmusic = CreateSound("hem6.wav") 'same as above
Set crashmusic = CreateSound("Car Crash.wav") 'same as above
#End If
End Sub

and where wan play the sound type

playsound startmusic, true, true

if u wan stop it and play file 2 type
stopsound startmusic, true
playsound crashmusic, true, true

remember to select Directx7 from preferences

if u still dun understand, tell me ill try to write a small prog and attach it

11-08-2001, 04:34 AM
For a start, DirectX is an API. Second sndPlaySound is not compilcated.
True, the waveOut stuff is hard but I did note that.

wild wolf
11-08-2001, 04:44 AM
oooopsie, i confused it with VBSound (or am i still confused?)

11-08-2001, 05:24 AM
I've never heard of VBSound. What is it?

wild wolf
11-08-2001, 05:58 AM
its the normal sinsertion of sound by calling the functions from the pakages (or did i confuse the name?)

11-08-2001, 06:05 AM
Sorry, what functions from which packages?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum