Results 1 to 22 of 22

Thread: DirectSound

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90

    DirectSound

    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.

    Can someone help me please?
    Thank you.

  2. #2
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Could you provide a little more info please?

    What error messages, where's it crash, an example of the code?
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  3. #3
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    You can review my DSound8 example

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    Fox, I'm using DirectSound7.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    Arbiter, there aren't any error messages.
    VB is just closing its window.

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It would help if you posted some code
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    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 

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I would need actual VB code, if you could post it.
    Don't worry we wont steal
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    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?
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  10. #10
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Thanks Arbiter

    Well my DS8 example is really easy, but sandra won't use DX8... erm... why not???

    Recommended! ^_^
    Last edited by Fox; Jun 11th, 2001 at 05:46 AM.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    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. )

    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
    Is this OK?
    This is the DirectSound part included in the other code.

    Thank you if you help me

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90

    Very Urgent

    Please,
    DSound worked once and only once.

    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.

  13. #13
    Lively Member
    Join Date
    May 2001
    Location
    Garden Grove, CA
    Posts
    72

    here is the problem

    Set Buffer = dsMain.CreateSoundBufferFromFile(Picture.bmp, BufferDesc, wavFormatex)

    should be

    Set Buffer = dsMain.CreateSoundBufferFromFile(Sound.wav, BufferDesc, wavFormatex)



    Chris
    Chris Wilson

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    Oups!

    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.

  15. #15
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    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....
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  16. #16
    Lively Member
    Join Date
    May 2001
    Location
    Garden Grove, CA
    Posts
    72

    The Way I do it

    VB Code:
    1. 'I set up a UDT
    2.  
    3. Type DSSound
    4.     Filename As String
    5.     Loop As Boolean
    6.     DBuffer As DirectSoundBuffer
    7.     DSDesc As DSBUFFERDESC
    8.     WAVEFORMAT As WAVEFORMATEX
    9.     Number As Integer
    10. End Type
    11.  
    12. 'declare it
    13. Public TheSounds(0 to 99) As TBSound
    14.  
    15. 'I pull values in through an xml file, to get filename and number
    16. ' THen I load all my sounds
    17.  
    18. Function LoadSounds() As Boolean
    19. Dim I As Integer
    20.     For I = 0 To UBound(TheSound)
    21.         Set TheSound(I).DBuffer = DS.CreateSoundBufferFromFile(App.Path & _
    22.         "\sound\" & TheSound(I).Filename, TheSound(I).DSDesc, _
    23.         TheSound(I).WAVEFORMAT)
    24.     Next
    25. End Function
    26.  
    27. 'then to play it
    28.  
    29. TheSound(uSoundNumber).DBuffer.Play DSBPLAY_DEFAULT

    Hope that helps some

    Chris Wilson
    Last edited by TType85; Jun 12th, 2001 at 04:22 PM.
    Chris Wilson

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    I'm sorry but I did not understand your code.

  18. #18
    Lively Member
    Join Date
    May 2001
    Location
    Garden Grove, CA
    Posts
    72

    Smile ok here it is a bit simpler :)

    VB Code:
    1. Dim DBuffer as DirectSoundBuffer 'Direct Sound Buffer
    2. Dim DSDesc as DSBUFFERDESC 'Direct Sound Buffer Description
    3.  
    4. Set DBuffer = DS.CreateSoundBufferFromFile(whatever.wav, DSDesc, WAVEFORMATEX)
    5.  
    6. 'Non-Looping
    7. DBuffer.Play DSBPLAY_DEFAULT
    8.  
    9. 'Looping
    10. DBuffer.Play DSBPLAY_LOOPING
    Last edited by TType85; Jun 12th, 2001 at 04:21 PM.
    Chris Wilson

  19. #19
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Use the new vbCode tag:

    VB Code:
    1. For I = 1 To 3
    2.    If I > 2 Then
    3.       Do
    4.          Msgbox "HaHa"
    5.       Loop
    6.    End If
    7. Next I
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    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? )

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    Lebanon
    Posts
    90
    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!

  22. #22
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    ...and I still recommend you starting out with DX8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width