andrewo
11-07-2001, 02: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, 02:57 AM
check this post out, in this post attached is my game which uses Direct Sound, and there is also some ref
http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=gp&Number=59510&page=0&view=collapsed&sb=5&o=& 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, 03:01 AM
or u can go to this link, there is a very good tutorial by Squirm there http://www.visualbasicforum.com/bbs/showflat.php?Cat=&Board=tu&Number=59124&page=0&view=collapsed&sb=5&o=& fpart=, if this link does not work, go to tutors corner in the main menu and look for DS tutorial
Banjo
11-07-2001, 05: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-07-2001, 11:25 PM
i think DirectSound will be easier rather than take him into API which is more complicated
andrewo
11-08-2001, 12: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, 03: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
End If
DirectSoundObj.SetCooperativeLevel Me.hWnd, DSSCL_PRIORITY
End Sub
Function CreateSound(FileName As String) As DirectSoundBuffer
Dim DSBuffer As DirectSoundBuffer
Dim DSDesc As DSBUFFERDESC
Dim DSWave As WAVEFORMATEX
DSDesc.lFlags = DSBCAPS_STATIC
DSWave.nFormatTag = WAVE_FORMAT_PCM
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.Stop
Sound.SetCurrentPosition 0
End If
If LoopSound Then
Sound.Play 1
Else
Sound.Play 0
End If
End Sub
Sub StopSound(Sound As DirectSoundBuffer, _
CloseFirst As Boolean)
If CloseFirst Then
Sound.Stop
Sound.SetCurrentPosition 0
End If
End Sub
Sub CreateSounds()
#If COMPILING Then
Set startmusic = CreateSound("hem6.wav") 'pathname of ur file 1
Set crashmusic = CreateSound("Car Crash.wav") 'pathname of ur file 2
#Else
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
Banjo
11-08-2001, 03: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, 03:44 AM
oooopsie, i confused it with VBSound (or am i still confused?)
Banjo
11-08-2001, 04:24 AM
I've never heard of VBSound. What is it?
wild wolf
11-08-2001, 04:58 AM
its the normal sinsertion of sound by calling the functions from the pakages (or did i confuse the name?)
Banjo
11-08-2001, 05:05 AM
Sorry, what functions from which packages?