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.:)
Printable View
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.:)
Could you provide a little more info please?
What error messages, where's it crash, an example of the code?
You can review my DSound8 example
Fox, I'm using DirectSound7.
Arbiter, there aren't any error messages.
VB is just closing its window.
It would help if you posted some code
OK, this is somehow the code I'm using:
Code:LoadSounds 'using CreateSoundBufFromFile()
LoadGraphics 'Using CreateSurfFromFile()
Game Loop
If Certain_Condition Then
Play
End If
Loop
StopSounds 'Buffer.Stop
UnloadSounds 'Buffer=Nothing
I would need actual VB code, if you could post it.
Don't worry we wont steal :D
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?
Thanks Arbiter :)
Well my DS8 example is really easy, but sandra won't use DX8... erm... why not??? ;)
Recommended! ^_^
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. )
Is this OK?Code: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
This is the DirectSound part included in the other code.
Thank you if you help me :p
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.:)
Set Buffer = dsMain.CreateSoundBufferFromFile(Picture.bmp, BufferDesc, wavFormatex)
should be
Set Buffer = dsMain.CreateSoundBufferFromFile(Sound.wav, BufferDesc, wavFormatex)
:)
Chris
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.
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:
VB Code:
'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
I'm sorry but I did not understand your code. :D
VB Code:
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
Use the new vbCode tag:
VB Code:
For I = 1 To 3 If I > 2 Then Do Msgbox "HaHa" Loop End If Next I
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 )
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
...and I still recommend you starting out with DX8 :)