Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Play Multiple Sounds

Here is what i am currectly using to play sounds:

VB Code:
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _(ByVal lpszSoundName As String, ByVal uFlags As Long) As LongPublic Const SND_ASYNC = &H1  '  play asynchronously'Public Const SND_MEMORY = &H4 '  lpszSoundName points to a memory filePublic Const SND_NODEFAULT = &H2  '  silence not default, if sound not found Public Sub Playit(Sound As String)    Dim SoundBuffer As String        SoundBuffer = StrConv(LoadResData(Sound, "WAVE"), vbUnicode)    Call sndPlaySound(SoundBuffer, SND_MEMORY Or SND_ASYNC Or SND_NODEFAULT)End Sub

It plays sounds from a RES file. I am coming across the issue that if i try to play 2 sounds (different of the same) it will only play the last sound. Does anyone know of a better way to play multiple sound without using a control???

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Play Multiple Sounds
Hey guys, I was wondering how to play multiple sounds at the same time, when you play it normaly with sndplaysound api you can only play one at a time or it will cancel the one already playing, I have tried all the flags I think... Any ideas??? Do I have to use some sort of mixing api?

I Need To Play Multiple Sounds At Once
how do i play multiple sounds at once?

Play Sounds
Is there a way to play sounds without putting a Media player in my program?

Play Sounds
Is it able to produce sounds in machine without sound card installed by vb?. This is required for remainder Program.The sound should be Nice !!!!

Play Sounds In Parallel
In Visual Basic 6.0, I need to play 2 or more wavefiles almost in parallel.

I found that I can use a function called PlaySound() from winmm.dll, this function takes 3 inputs: filename path, something else I put to zero for now, and 3rd parameter is flags. After I played iwth the flags, all I can do is play awavefile and wait until it's done to play the next. I am not able to play 2 files in parallel.

PlaySound( "I:apuname.wav", 0, SND_ASYNC );
PlaySound( "I:giggles.wav", 0, SND_ASYNC );

Any ideas are appreciated thanks.

How To Play Generated Sounds?

How do i play sounds generated by the program?
Let's say that the program generates a sine curve. How can i play it.

The Most Easy Way To Play Sounds
hi, i am not very good at either VB or English...(because i am Norwegian... )

i was searching on this site on how to play sounds, the only sound i know is the "Beep" sound...and i found an example here, which was very complex and complicated....isn't there an easier way to play .wav and .midi sounds?

for example, if i have a .wav file called "intro.wav" that is lying on c:windowsintro.wav, that should be played when the form frmMain is opened, exactly what shoud i write, what is the easiest way?

Play Music And Then Sounds.
I am playing background music.

I want little sounds to be played when users press certain keyboard buttons. The background music should still play, until another different key has been pressed.

Anywho, My Problem is:

When I play the little sounds, the background one stops, and when I use the SND_ASYNC flag on the background, I cant interact till the music is finished.

Please Help,

Tom Young, 14 Year Old
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer

Play Sounds OTHER Than Beep ?

When you use the visual basic Find/Replace form, once it is finished it makes a sound (not a beep, more like a brief note from a horn)

Are there intrinsic sounds that I can use other than the beep, or do I need to incude some kind of media file?

Thanks guys, Have a great time

God Bless America

Record/play Sounds At The Same Time
This is my first post, so be gentle. I need to play a sound and record at the same time, hopefully with the records lining up. This is for a signal analyzer, where a stimulus is applies to a circuit or a room, and the result is recorded and analyzed. Is there a way to synchronize the gozinta and comzouta?



Excel/VBA: Play Sounds With Delays...
Hello, I would like to create a macro in Excel (using VBA) that will:

1) play a WAV file
2) wait 5 seconds
3) play the WAV file again
4) wait 10 seconds
5) play the WAV file again
6) wait 5 seconds
7) play the WAV file again


How To Play Drum Sounds From Your Soundcard?
Microsoft keep notes of drum sound in .drm files.
Well i'll start and say that .drm files are basicaly commands and not sort of a file.
Here is an example for what's written in a drm file:
MRDm =
In other .drm files the char (for example above =) will change.
Now i know that to play this, the program has to call the soundcard to play the drumsound using the char or something like that.
I can give you an example for it in Microsoft Plus for Kids 95, the software PlayIt! can play .drm files.
I know that you can do with api midiOutOpen and open the device for playing but i don't know what to do further.
I know that the sounds of the drums will change from one soundcard to another but please help me what do i have to do next?
How can i call the soundcard to play this sounds?
I saw a dll microsoft used for PlayIt! called MNMIDI32.DLL and i think they play the sounds with it, but i don't know how to work with it.
What can i do to play drum sounds (from the soundcard, not waves)?
Thanks for any one who will help me with this.

Checking Registry To Play Sounds?
OK. I'm designing a little chat program for fun and for the heck of it. It has sounds that you can play, as well as an options form. If you click on the "Sounds On!" options and then my "Apply" command then it will set a registry key named "Sounds" with a value of "1", or if you do "Sounds Off!" then it will set that key to "0". Now here's my dillemma:

When you click on one of the Sound commands, for instance the slap one, it has an If Then statement. I want it to check that if the registry key named "Sounds" has a value of "1" then go ahead and play the sound...if it's not "1" then don't do anything. Right now my code looks something like this...

If GetSetting("PChat", _
"Options", "Sounds") = 1 Then
playsound = sndPlaySound("soundsslap.wav", 1)
End If
End Sub

There is more code in there but it's irrelevant. Just one to set focus to the message box after it's done...and that's after the End If. Now I know that the

If GetSetting("PChat", _
"Options", "Sounds") = 1 Then
blah blah blah
End If

works, becuase in my options form it accesses the registry and finds out what the values are so your options are saved and you do not have to reapply them. Like...

Private Sub Form_Load()
If GetSetting("PChat", _
"Options", "Sounds") = 1 Then
Option1 = True
Option2 = True
End If
If GetSetting("PChat", _
"Options", "WebAllow") = 1 Then
Check1.Value = 1
Check1.Value = 0
End If
End Sub

That's in my options form...and it does work. So why won't it work for the sounds and play my sound when I want it to, lol. I made sure by going into regedit and made sure that the Key was set to "1". I just don't get it. Well, can anyone shed some light on this?

Oh yeah and to play my sounds here's the code at the top...

Private Declare Function mciSendString Lib "winmm.dll" Alias _
"mciSendStringA" (ByVal lpstrCommand As String, ByVal _
lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _
hwndCallback As Long) As Long
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

I don't get it! lol


Newbie Need Help Again {play Sounds - Older Version Of WMP}
A while ago I implemented sounds in my program using Windows Media Player. Then I found that users with older version of WMP cannot run it (I am using WMP9). Is there any way to adjust the compatibility? Thanks

Play Midi Sounds From Resource Editor
I know how to play WAV files from here.. But how can I play the MIDI files too?

Thank you in advance for your help.

*** This is what I am using rightnow for the WAVES ***

Public Sub PlayWavResource(pintResourceID As Integer)

Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Private Const SND_ASYNC = &H1 ' Play asynchronously

Private Const SND_NODEFAULT = &H2 ' Don't use default sound

Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file

'Usage: PlayWavResource ResourceID
'Example: Call PlayWavResource(101)

Dim retVal As Long
Dim SoundBuffer As String
SoundBuffer = StrConv(LoadResData(pintResourceID, "CUSTOM"), vbUnicode)
retVal = sndplaysound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)

End Sub

Can MciSendString Be Used To Play Sounds From Memory As Well As From File?
I am upgrading an app that used to play wav files when sounds were needed. These sounds were played either directly from file, or from memory if they had previously been loaded into memory. (the commonly used sounds were loaded into memory in order to speed up latency on playing)

sndPlaySound (The API predecessor to PlaySound) was used to play the wav files from memory or from file as needed (by setting the SND_MEMORY flag). Can I achieve the same thing with mciSendString or mciSendCommand?

Also does anybody know where I could find out what can actually be done with the mci Functions, since all I seem to be able to find is the parameter info?

How Do I Play Wave Sounds Over Modem Line
Hi Guys! Can anyone help me with this probled. How do I play wave files over a modem line, and record as well?
Please help, Have been breaking my head for months!
Please E-mail : URL
South Africa

Help-Need Looping Background Music In And Other Sounds To Play At Same Time.
I'm tring to have a little wav file play when my app starts for background music that loops untill someone clicks on a music on/off button. The problem is that I have other sounds that play when other buttons are clicked (a clicking sound) and this stops the background music. How do I go about having them both play at the same time?

Anyone Know How To Make The Sound API Let Me Play Differnt Sounds At The Same Time?
or maybe another sound API that will let me do this, this is crucial in my virtual drum set program

Multiple Sounds
How can I play 2 .wav sounds at the same time that are triggered by seperate events?

Multiple Sounds

Is it posssible to play 2 or more sounds at the same Time WITHOUT the use of DirectX?

Multiple Sounds
Hey all you clever people!

I'm really struggling with trying to play multiple sound files simultaneously.

Can anyone point me in the right direction. Just a general direction will do, I'll learn more if I have to work it out rather than having the solution given to me on a plate.

Multiple Sounds
im trying to add sounds to my app and there are two types, there are loops that the user can select and then there are sounds that the interface will make (button over, down etc...)
my loops work fine when the user clicks on play, until that is i move my cursor over one of the buttons, which plays a interface sound Fx (eg: Bleep). when the interface sound get used (played) it stops playing the loop, it seems i cant play more than 1 sound at a time... so i added 2 different subs to play sounds, one that plays loops and the other that plays anyother sound FX, this fixed this problem
Then !!!! what happened was that i made my exe and published it along with wav files neede and the loop waves worked fine but the interface wavs didnt!!!!

so i want to store the interface sounds in a resource file and use a rutine that lets me play multiple sounds a the same time(seeing as how i cant with the routines ive got). hopeful i can get this working

Signature -----------------------------------------------------------------------------------------------------Code:Private Sub Form_Load() 'Print to from, code my problems!
     Form1.Print "CanT SleeP!..... MusT PrograM!!!" & vbCrLf & "I need coffee, WhErE iS mY CoFfEe?!"
End Sub 'All things come to and end

Edited by - coma on 10/27/2004 6:22:23 PM

Help Needed On Multiple Sounds
I am using PlaySound API to play sounds in my game.
PlaySound App.Path + "attack.wav", SND_ASYNC
PlaySound App.Path + "footstep.wav", SND_ASYNC
(btw, SND_ASYNC = &H1)
But I notice one problem.
The new sound will always replace the previous sound even when the previous sound have not played finish.

EG> the character make an attack. the attack.wav start to play... and then the character move around while attacking, the attack.wav always suddenly stop and then it gets replace by the footstep.wav.

I hope to play more than 1 sound at the same time, what should I do?

Using Multiple OLE Sounds With Options
Ok this is the first time i have ever tried using multiple sounds with option buttons. If i was being 100% honest id tell you i have no ****ing clue how to make it work.

i know like for a single sound it would go

If Option1.Value = True Then
OLE1 = 7
End If
End Sub

Can someone tell me how i would do that if i wanted multiple sounds

Specifically i am trying to use 6 sounds.

Any help would be appreciated.


Edit: A little more helpful info is i am wanting to play the chosen sound when something is added to a combo box.

Playing Multiple Sounds
This is my problem. I have a program that i am using active movie player to play wav files in my program.
But I want to have background music playing all the time and have the sound effects over top.
Everytime I try to do this the sound effect overrides the background music and cancels it. does anyone know how to prevent this?


Multiple Sounds At Same Time
Hi, Im having problems playing more than one WAV file at once.
Im using the API function sndPlaySound. sometimes during my game, more than one sound will play at the same time, but the API will ignore the 'newer' sound until the older one has finished. is there any way of having, say, multiple channels, so that different sounds can play simulataneously?
Thanks, Dave.

Playing Multiple Sounds With PlaySound
I've seen several posts here about playing multiple WAV sounds using PlaySound, but has anyone actually been able to achieve it?

I've tried several combinations of flags, but I can't get it to work.

Thanks in advance,


Playing Multiple Sounds With Direct Sound
im playing multiple sounds in my game, i dont think this module that i am using is allowing that. Can someone please check what i need to change to make it play multiple sounds?


Public Dx As New DirectX7
Public Ds As DirectSound
Public DsBuffer(0 To 100) As DirectSoundBuffer
Public Sub DSInitialise()
Set Ds = Dx.DirectSoundCreate("")
Ds.SetCooperativeLevel Form1.hWnd, DSSCL_NORMAL
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
End Sub

Multiple Font In Richtextbox (thougher Then It Sounds)
Allright, This is getting complicated.

I have a kind of a text editor. It uses a richtextbox to have different fonts in the text. But now is the problem the following.
When it's all typed in. I want to put some text in front of all text
But is must be in a certain font. But when I say :


it puts the text in the normal font wich is in use. When I say


It works until I have already used 2 differnt fonts. For example.

This is the code right here
and then add the word trying. It makes it:

Trying This is the code right here .
So the italic miraculeusly disapperead.

Is there a way to solve this problem??

How I Can Use Multiple Sound Cards To Direct Sounds Played By Two Instances Of WMP?
How I can use Multiple sound cards to direct sounds played by two instances of WMP?

I have developed a DJ application around WMP 7.

I have two sound card installed in my machine. I use multiple instances of WMP to play different media file but output goes to only one device(default device).

Now I want, different(or at least one)instances of WMP to use another multi media devices to send output.

Is it possible? If so, How? please help!

I need it as I want a facility to be able to hear the media before I feed in, while I'm playing another media,using a sound device.

Will any Expert help me?

Play Multiple Audio File In Vb
hi all....
this is the 10th forum i asked to solve my question but with no respond,so plz help me..........

1st: how to play more than .wav file one after other once i click a button...(RealAudio1...)

2nd: how to concatinate more than 1 .wav file and then play them all one after other in a new file....

Note: im working on text-to-speech project , so my program should return the .wav file that i record for each word on the screen...(any sugestion are welcome)


How To Play Multiple Sound Effects?
I am making a small game in VB6 and I need to know how to play multiple sound effects.

Right now I am using...

Private Declare Function sndPlaySound Lib "winmn.dll" Alias "sndPlaySoundA" _
(ByVal ipszSoundName as String, ByVal uFlags As Long) As Long

and triggering a sound with...

sndPlaySound "soundfile.wav",1

This code only allows me to play one sound at a time.
I need to know how to play multiple sounds at once, at least five.


RE: Override System Event Sounds With Custom Application Sounds
Hi all

Saved an artical to my HD a while back on how to override system even sounds with custom sounds specific to the application.
It's vanished and the registry is not one of my strong points.

So pointers would be great or a link to an article pointing me in the right direction would be great.

The application has been programmed in VB6.0

cheers in advance

Daniel :-(

Saving Sounds To Match Sounds

This is kinda hard to explain for me but is there a way that I can record a sound from a guitar, lets say an E note, and later in the program when I can recording if they play an E then a message will come up "you played an E!"??

Help would be very appreciated

Play, Stop, Pause, Loop Play MP-3
respected codeguru users and viewers,

how i can play mp3 file in my program i used mmcontrol and active movie control but not the solution due to lack of experience, can any one help me how its done, thanx for viewing and responsing,

Title Music Won't Play, Need A Way To Play MP3!
I haven't found a way to play my title music yet! I need a way to play an MP3 file!

Play Pbc (play Back Control) Media Files In Windows Media Player
i can not play pbc (play back control) media files in windows media player in visual basic program and i try to play in normal windows media player on windows , it can not play too . help me pls , thanks a lot

Scrolling Play-by-play
(I consider this "general," as it would apply to status reporting other than for a game. I hope that's okay.)

I've been designing a sports simulation game. It began in QuickBasic, was adapted to VB 3 and is now in VB 5. For the play-by-play window, I'd been using a simple List Box. I add

frmNarrate.lstPlayByPlay.AddItem Text$
Where Text$ will be something synthesized like "Green Bay lines up, first and ten from their 35 ... ," or "Wilson grounds to short . . . he's out!" Text$ also gets written to a file for a permanent record.

After each addition, I scroll the list to show the latest entry:

frmNarrate.lstPlayByPlay.TopIndex = frmNarrate.lstPlayByPlay.ListCount - 1

This has served me quite well over several years. However, I'm limited to one text style, size and color. I can change (or let the user change) the entire display, but can't show one team's results in Blue and the other in Red, use bold or italic, that sort of thing.

In reading through this Forum, I was surprised to find that (1) many programmers seem to use a multi-line Text Box for just this sort of thing, and that (2) I ought to consider using a Rich Text Box to full advantage. I presume that it can be made to scroll properly.

I'm going to try these as an alternative just as soon as I get home. Any opinions as to whether it will work, or how difficult the conversion would be? Would using the Rich Text Box add much overhead to the program?

The MP3 sound doesnt work on this game, can someone plz look at the code and tell me why? thanks

I need to know a low-resource non directX way to play sounds WITHOUT the windows media player control. Also, if you know where to get a free footstep sound file, i need to know that too.

Bg Sounds
how would i place a sound in a form to play on from load? i tried with the media player and real compnents, but they all require you to look for the sound file, how would i be able to make it play on a form load? thanks...

Hey all

My program is nearly complete however i need to know how to play a wav file when a form loads and if i can play a midi file. I am also having trouble with my bottom wall of my game the other 3 are working fine here is the code i already have


If KeyCode = vbKeyDown Then
If xwing.Top + 1025 > episode4.Top Then
xwing.Top = xwing.Top + 500

End If
End If
this does not work however. Any help would be greatly appreciated.



Car Sounds
im making a car game, and im using direct sound (directX7) for the sound, and im having jsut leik an ideling wav file then ispeed up the frequency(pitch).. thats all good and all.. my problem now is

blow off valve or gear changing sounds, how can you have 2 diff sounds at 2 diff frequencies(pitches) playing at the same time
ty in advanced

I have other visual basic programs that play sound when you load them. I was wondering, if i can make a separate program to block/stop the sounds from playing when i open a program that plays sound.

Sounds! Please Help
I used this code to play a sound when a form loads.... can someone tell me why it doesnt play the sound, it just goes "beep"....
I found the code on this site and I just wanna see if it will work. thanks!

Option Explicit
Private Const SND_ASYNC = &H1
Private Const SND_FILENAME = &H20000
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Sub Form_Load()

PlaySound App.Path & "zoomin.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC

End Sub

How do I put sound into my game so that wen text1 = 0 then it will play a sound. Thanks!

Ok I still call myself new at VB but im learning fast, just one question how do you make VB play sounds? Say if i have a WAV or a MP3 or something how would i make it play you clicked a button?

Copyright 2005-08, All rights reserved