Results 1 to 15 of 15

Thread: Using Sound Effects in VB?

  1. #1

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Using Sound Effects in VB?

    Hi All,

    Just wondering whether it's a difficult thing or not to incorporate sound effects into VB? Short version, experimental VB + Cairo RPG crawler game being tested, I think it would be nice to add sound effects to weapon slashes and general combat.
    Humble has released an enormous sound kit (2 days left), but I haven't looked at sound incorporation into VB at this stage of development.
    I am wondering if there are sound gurus on here that know about sound and music on VB? Is there a lot involved, can one setup a decent combat system sound-wise? Can I play recorded MP3's at the same time as fighting? Would it sound good or trashy? Can multiple sounds play at once?

    Any knowledge greatly appreciated.

    Name:  the-strongest-sage-iris.gif
Views: 332
Size:  65.0 KB
    Last edited by -Corso->; Sep 12th, 2022 at 04:58 PM.

  2. #2
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Using Sound Effects in VB?

    Can't help anyone with silly, meaningless and childish images inserted, it just deflates my will to assist.
    Make it grown up and my will to help might be restored.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  3. #3

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Not going to happen, my RPG game is about monstergirls, and Iris above, is an Anime dragon girl from the target audience I'm aiming the RPG at. So you are going to see more and more monstergirls from my posts as time passes. Some artwork made by me, some from the web. If you don't want to help, I'll understand your bitterness and prejudice against monstergirls. :P

  4. #4
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Using Sound Effects in VB?

    Damn. I'm sure someone else will help.

    WAV files can be played by default. MP3 and other formats can be played with assistance of Win APIs
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  5. #5

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Ah, I bought the mega sound pack.. Seems to be quite excellent for a starting pack. Crafting noises, monsters, combat, yereverluvinuncleber donkey noises.

    Name:  the-strongest-sage-with-the-weakest-crest-eris.gif
Views: 293
Size:  10.5 KB

    Ah, yes, now I DO remember programing in some sounds when I had VB4... But it was pretty lame... API's, Ok.

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: Using Sound Effects in VB?

    For games the best bet is probably using DirectSound, The trick made a VB6-compatible typelib for it.

  7. #7
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Using Sound Effects in VB?

    I can't stand Japanese style kiddie cartoons, so 70s, so trivial, so passée.
    Glad you managed to get help on your cartoon sounds.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  8. #8

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Quote Originally Posted by fafalone View Post
    For games the best bet is probably using DirectSound, The trick made a VB6-compatible typelib for it.
    Thanks Fafalone. Oh boy, that does look complicated. I've got some ActiveX/Classes training to do for a while and will scan over the Tricks' stuff following that. Good to know that something can be done. I found this old stuff, which is good enough for a tiny test at least.

    Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Public Sub PlaySound(strFileName As String)
    sndPlaySound strFileName, 1
    End Sub
    Private Sub Command1_Click()
    PlaySound App.Path & "\Windows Logoff Sound.wav"
    End Sub

  9. #9

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Quote Originally Posted by yereverluvinuncleber View Post
    I can't stand Japanese style kiddie cartoons, so 70s, so trivial, so passée.
    Glad you managed to get help on your cartoon sounds.
    Ok Cruella de Vil, you'll still be VB Forum's favorite wine aunt.

    Name:  anime-star.gif
Views: 208
Size:  34.1 KB

  10. #10
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Using Sound Effects in VB?

    Quote Originally Posted by -Corso-> View Post
    Ok Cruella de Vil, you'll still be VB Forum's favorite wine aunt.
    You'd be surprised how good I look in stockings and suspenders.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Using Sound Effects in VB?

    Quote Originally Posted by yereverluvinuncleber View Post
    I can't stand Japanese style kiddie cartoons, so 70s, so trivial, so passée.
    All media categories have winners, losers, and subjectively ambiguous material. Some can be good enough to appeal to broader audiences and the trick is finding those.

  12. #12
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: Using Sound Effects in VB?

    Quote Originally Posted by -Corso-> View Post
    Thanks Fafalone. Oh boy, that does look complicated. I've got some ActiveX/Classes training to do for a while and will scan over the Tricks' stuff following that. Good to know that something can be done. I found this old stuff, which is good enough for a tiny test at least.

    Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Public Sub PlaySound(strFileName As String)
    sndPlaySound strFileName, 1
    End Sub
    Private Sub Command1_Click()
    PlaySound App.Path & "\Windows Logoff Sound.wav"
    End Sub
    Loading a file every time is probably going to be too slow for properly synced sound effects; it would be better to first load the sound effects into memory (read the file into a byte array) and use the SND_MEMORY flag to have PlaySound play it from the preloaded byte array (and of course SND_ASYNC so it doesn't halt your code while it plays).

    If you search the forum you'll find examples for doing it from both files on disk and files embedded in your exe as resources.

  13. #13

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Quote Originally Posted by dilettante View Post
    All media categories have winners, losers, and subjectively ambiguous material. Some can be good enough to appeal to broader audiences and the trick is finding those.
    Very true.

    Quote Originally Posted by fafalone View Post
    Loading a file every time is probably going to be too slow for properly synced sound effects; it would be better to first load the sound effects into memory (read the file into a byte array) and use the SND_MEMORY flag to have PlaySound play it from the preloaded byte array (and of course SND_ASYNC so it doesn't halt your code while it plays).
    Oh, I had no idea that sounds could be treated that way. Thanks for the tidbit.

  14. #14

  15. #15

    Thread Starter
    Hyperactive Member -Corso->'s Avatar
    Join Date
    Oct 2021
    Posts
    379

    Re: Using Sound Effects in VB?

    Thanks Trick, that looks waaay complex for me to understand just this minute, does the PlayFile allow concurrent Wav's to be played?

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