Click to See Complete Forum and Search --> : DirectSound
sandra
Jun 10th, 2001, 05:41 AM
Hi.
I tried using DirectSound in my game but it did not work.
What's happening is that when I run my program, it doesn't run. Instead, VB is just closed.:confused:
Can someone help me please?
Thank you.:)
Arbiter
Jun 10th, 2001, 05:45 AM
Could you provide a little more info please?
What error messages, where's it crash, an example of the code?
Fox
Jun 10th, 2001, 08:19 AM
You can review my DSound8 example (http://fox.acky.net/english/coding/directx.html)
sandra
Jun 10th, 2001, 10:38 AM
Fox, I'm using DirectSound7.
sandra
Jun 10th, 2001, 10:40 AM
Arbiter, there aren't any error messages.
VB is just closing its window.
Sastraxi
Jun 10th, 2001, 04:13 PM
It would help if you posted some code
sandra
Jun 10th, 2001, 04:33 PM
OK, this is somehow the code I'm using:
LoadSounds 'using CreateSoundBufFromFile()
LoadGraphics 'Using CreateSurfFromFile()
Game Loop
If Certain_Condition Then
Play
End If
Loop
StopSounds 'Buffer.Stop
UnloadSounds 'Buffer=Nothing
Sastraxi
Jun 10th, 2001, 05:32 PM
I would need actual VB code, if you could post it.
Don't worry we wont steal :D
Arbiter
Jun 11th, 2001, 02:42 AM
Well, there's not a lot to go on there... ;)
Are there no error messages because you're trapping them?
If you step through the code line by line and then have a look at the line that's causing it to fall over it may give you a clue.
If you could post the code and then point out the line that's the culprit we could have a look.
PS - Fox's tutorials are normally pretty good. Have you had a look at his code and see if it's of any use?
Fox
Jun 11th, 2001, 05:33 AM
Thanks Arbiter :)
Well my DS8 example is really easy, but sandra won't use DX8... erm... why not??? ;)
Recommended! ^_^
sandra
Jun 11th, 2001, 12:07 PM
I won't use DX8 coz I've already started my game with DX7. :)
The problem is, and I don't think you are getting it, is that I can't know where the error is coz VB is CLOSING ITS WINDOW.
I'll include the actual code I'm using maybe it'll help you.
(By the way, Sastraxi, I'm not afraid you'll steal my code, ;) it's just that I think it's too long to be posted, so I prefer to replace it by the algorithm. )
Set dsMain = dxMain.DirectSoundCreate("")
Set Buffer = dsMain.CreateSoundBufferFromFile(Picture.bmp, BufferDesc, wavFormatex) 'BufferDesc is of type DSBUFFERDESC
Game Loop
if condition Then
Call Buffer.Play(DSBPLAY_LOOPING)
end if
Loop
Buffer.Stop
Set Buffer=Nothing
Is this OK?
This is the DirectSound part included in the other code.
Thank you if you help me :p
sandra
Jun 12th, 2001, 10:49 AM
Please,
DSound worked once and only once.:confused:
Can I please post my game for someone to try and help me, because I think the only solution.
Thank you for all those who will help me, you will be saving my life.:)
TType85
Jun 12th, 2001, 12:11 PM
Set Buffer = dsMain.CreateSoundBufferFromFile(Picture.bmp, BufferDesc, wavFormatex)
should be
Set Buffer = dsMain.CreateSoundBufferFromFile(Sound.wav, BufferDesc, wavFormatex)
:)
Chris
sandra
Jun 12th, 2001, 02:19 PM
Oups! :D
I'm sorry I haven't moticed what I wrote.
But this isn't what I wrote in my code, OK?
I still need the urgent help. :)
Thank you.
Arbiter
Jun 12th, 2001, 03:06 PM
If there's somewhere we can download your game we can have a look.
A tip - In order to narrow down where the fault it you could strategically place message boxes through the code starting at the beginning. Crude, but effective.
Bit like me really.... :rolleyes:
TType85
Jun 12th, 2001, 03:14 PM
'I set up a UDT
Type DSSound
Filename As String
Loop As Boolean
DBuffer As DirectSoundBuffer
DSDesc As DSBUFFERDESC
WAVEFORMAT As WAVEFORMATEX
Number As Integer
End Type
'declare it
Public TheSounds(0 to 99) As TBSound
'I pull values in through an xml file, to get filename and number
' THen I load all my sounds
Function LoadSounds() As Boolean
Dim I As Integer
For I = 0 To UBound(TheSound)
Set TheSound(I).DBuffer = DS.CreateSoundBufferFromFile(App.Path & _
"\sound\" & TheSound(I).Filename, TheSound(I).DSDesc, _
TheSound(I).WAVEFORMAT)
Next
End Function
'then to play it
TheSound(uSoundNumber).DBuffer.Play DSBPLAY_DEFAULT
Hope that helps some
Chris Wilson
sandra
Jun 12th, 2001, 03:41 PM
I'm sorry but I did not understand your code. :D
TType85
Jun 12th, 2001, 03:57 PM
Dim DBuffer as DirectSoundBuffer 'Direct Sound Buffer
Dim DSDesc as DSBUFFERDESC 'Direct Sound Buffer Description
Set DBuffer = DS.CreateSoundBufferFromFile(whatever.wav, DSDesc, WAVEFORMATEX)
'Non-Looping
DBuffer.Play DSBPLAY_DEFAULT
'Looping
DBuffer.Play DSBPLAY_LOOPING
Sastraxi
Jun 12th, 2001, 04:10 PM
Use the new vbCode tag:
For I = 1 To 3
If I > 2 Then
Do
Msgbox "HaHa"
Loop
End If
Next I
sandra
Jun 13th, 2001, 04:24 PM
Actually, Sastraxi, I'm so mad at this game that I can't laugh for the moment.
And by the way, TType85, the second code you gave me is the one I'm using (or is this a jake that I did not understand? :o )
sandra
Jun 13th, 2001, 04:48 PM
I don't know if you will believe this, I know I don't, but DS worked just like that.
I don't know how it did, I haven't changed anything in the code, but it just felt like working so it did! :p
Fox
Jun 14th, 2001, 12:02 AM
...and I still recommend you starting out with DX8 :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.