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

Playing Sound Through A Mic

I know a weird request. I was trying to figure out a way and couldn't.

I want to create a program that routes all sound the computer would normal make through the speakers (I guess line out?) And make them all go through the mic.

Would this be possible in VB 6.0? Or .Net? I have both but I know a lot more about 6.0.

I can get sound to play and even kind of record. But playing everything through the mic has been a challenge.

If it helps any, I thinking the program will have a simple button that when pressed will route all sound to the microphone instead of the speakers. With another button to switch it back.

Thanks for any advise!


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Playing Sound Files In A Selected Sound Device
Hello all,

I have a VB6 application which plays a .wav file using the SndPlaySound function. I want my sound file to be played on a different sound device, rather than my default sound device. The device gets listed when i use waveOutGetDevCaps function. But i couldn't find a way to play the file through the new device. How can i make my application to play the sound through a specified sound device say, a USB headset plugged into my pc, rather than my desktop speakers?

Thanks in advance,

How Can I Tell If A Sound Is Playing.
Hey. Im using Direct X 7 to play sound. How can I tell if a sound buffer is playing a sound.

Many thanks chris

Help With Playing Sound FX.
I want to play some sound effects such as a sword swish, or a chest opening in my game. I tries using both the sndPlaySound and PlaySound API's, but they both freeze the game while playing a sound. Can someone tell me an alternative method of doing this? Keeping it simple, plz? TIA!

Playing Sound
Can I play two wave at the same time?

For example, I'm playing a music, then I want to play a "bomb" at the same time, How can I do it?

Please help, Thank

Playing Sound In VB6
I am creating an application which requires sound playing. I have read many threads on using winmm.dll for sound playing. But, my application requires to play it own sound, which it creates for itself. I can't create wave file, bcs I need to play e.g. 500Hz sine wave and need to dynamically regulate the frequency of sine - 500-600Hz with step of 0.1Hz, for example. But that means, that I am not able to create a single wave file and play it.

Anyone can help, pls?

Needs Help With Playing A Sound
Ok guys I am just not getting this...

Here is what I have so far....
General Declaraions

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

'Then we have to declare the constants that go along with the sndPlaySound function
Const SND_ASYNC = &H1 'ASYNC allows us to play waves with the ability to interrupt
Const SND_LOOP = &H8 'LOOP causes to sound to be continuously replayed
Const SND_NODEFAULT = &H2 'NODEFAULT causes no sound to be played if the wav can't be found
Const SND_SYNC = &H0 'SYNC plays a wave file without returning control to the calling program until it's finished
Const SND_NOSTOP = &H10 'NOSTOP ensures that we don't stop another wave from playing
Const SND_MEMORY = &H4 'MEMORY plays a wave file stored in memory

Private Sub CmdAsync_Click()

'This uses the constants ASYNC and NODEFAULT to play the sound
sndPlaySound App.Path & "sound.wav", SND_ASYNC Or SND_NODEFAULT

and this works...
But what if my sound is in c:ding.wav? What should the syntax look like?
sndPlaySound c: "ding.wav", SND_ASYNC Or SND_NODEFAULT???

Can someone help me on this please?



Playing A Sound
How Can I make a program play a sound, without giving the user the ability to stop the sound.

Playing Sound
How can I play a sound in VB?

Playing Sound
what kind of sound can i play? what kind of formats? and how do i play them ?

Playing Sound
how do i use sound in vb?
i just want it to play a short wav file when the mouse goes over the button but ive never used sound.

Playing A Sound
vb Code:
Private Sub Command1_Click()MediaPlayer1.FileName = "C:Englishyoullbeinmyheart.wma"MediaPlayer1.PlayEnd Sub

i'm try to play a sound, i found this code on internet,but cant work.

Playing Sound
I want in my application that I can play sounds from the resource.
So at my form_Load i want it loads the music file[.wav / mp3] and plays it? i dont want any control, only that it will play

I thank you?

Maybe this question came over 100 times, i cant find a real answer

Playing Sound
Hi,The problem now is the program does not play the sound file when the two pictureboxes
hit again(for the second time).it works only in the first hitting...Let's take the picturebox1 as a bullet
and I want to hear the sound every time they collide...

VB Code:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _(ByVal lpszSoundName As String, ByVal uFlags As Long) As LongPrivate flg As BooleanDim mm As IntegerPrivate Sub Timer1_Timer()  Picture1.Left = Picture1.Left + 10  Picture2.Left = Picture2.Left - 10  If Picture1.Left > Me.ScaleWidth Then  Picture1.Left = -100  End If If Picture2.Left < -100 Then    Picture2.Left = Me.ScaleWidthEnd If    If (Picture1.Left > Picture2.Left) And (Not flg) Then    sndPlaySound "C:ses1laser.wav", SND_LOOP    flg = True  End IfEnd Sub

VB Sound Playing
if i were to use VB to play music with a simple program tht had no functions besides a library and the ability to play music would it be faster than using a program like winamp, realplayer or wmp.

by faster i mean take up less of the computer to i could have music playing in the background of games

Playing A Wav Sound In Vb
how to i get a specific wav sound to be played on a condition
like a statement
if .....then
{sound to played on else condition)
end if

does someone have en example of the code

Playing Sound!

I have made a program......And if I push a button there will be several actions.
But everytimi I push that button, you hear a Windows Defaultsound!
I am not going to change something in my Control Panel

How can I fix this so it will be gone??

Thanks for your help!

Playing Wav Sound
what would you use to play a wav sound...also what is the code to activate and disactivate it

Playing A Sound!
Well what i am making is my own Alarm clock so that i can make my own waking sound lol, or something like that since i keep my computer on 24/7 i might do something usufel with it .

Anyway i just want to be able to play some anoying wav file or an mp3 i have never tried this before but any help would be great thx alot peepz ..


Playing A Sound
how do i get the program to play a wav file already on the computer

Playing Sound
how would i play a sound file when my form loaded

Is My Sound Playing?
Hello, is there a way to know if my sound is playing? I'm using the API SndPlaySound to play it.

Playing A Sound
How do I do to playa a sound (.mp3, .wav....) when I click a button?

Playing Sound
Can anyone tell me a simple way to play a wave file. I have started to look at the MMcontrol but though I would first look for a more simpiler way.

Playing A Sound
Is there a way to play a sound when you database is updated by you VB program.

Playing A .wav Or Other Sound.
How do I do this without making my app freeze up while its playing?

Playing Sound In VB?
Is there codes that allow sound to be played ?? Or any command to play it?

Programmers are the laziest people around.

Sound Playing In VB6 (without WMP)
I am looking for a way to play .wav files in VB without using resource files and without using Windows Media Player control (because it is slow if you are running a Pentium 133 with Win 95 and playing it 15 times in a row!)

Problem Playing Sound (.wav)
I am getting an error message when I try to call my function to play sound. The error says:
Run-time error '49':
Bad DLL calling Convention.

I must be doing something wrong, but everything seems fine. Does anyone see what my problem is? Here a section of my code for playing sound:

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Dim SoundName$, wFlags%, x%

Private Sub PlayThudSound()
SoundName$ = App.Path + "Sound hud.wav"
x% = PlaySound(SoundName$, wFlags%)
End Sub

The program gets the error when it calls PlayThudSound, then... when I hit the Debug button (on the error dialog box), it will highlight the row:
x% = PlaySound(SoundName$, wFlags%)
I am not sure what I am doing wrong. Any suggestions?

Playing A Sound When Timeleft=0?
ive got a sound on my computer called Celebtate.WAV

ive go a timer in my program, i want that song to play looped (never ending) when the timer =0. i made an integer called timeleft.

so i want this

timeleft= timeleft -1
if timeleft=0 then (play that sound on loop)

Can someone show me how to do this? people told me to type PlaySound but nothing happens. can someone show me?

Playing Sound With PLAYSOUND API
I want to play a sound on my form with the playsound API. I would like the sound to play once and then stop. The sound file is called ohmagod.wav and it is located on my desktop.
I know how to declare it.

Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

That is all I Have so far though.
Could someone please give me the code to do it.
I have been to this site but it is too confuduling

Thanks in advanced

Playing And Recording Sound
ive made a program but in some places i need to play a .wav file, and i also need to make a form which can record a wave file from the microphone, like windows' soundrecorder (but simpler) it just needs a record button, a play from start button, a stop button and a save button(the save button doesnt open a dialog box, just save to a set folder giving the filename as the value of a string).

basically i have no idea where to even start with this, any help would be highly appreciated.

Playing A Sound Without Everything Else Freezing
I added following code into a module:

Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub PlayWhatever()
Call sndPlaySound32(AppPath & "..soundswhatever.wav", 0)
End Sub
And then used command "PlayWhatever" to play the sound in the project. It plays good, but nothing else can happen at that time, the program freezes while the sound is playing.

Is there a way to do this so the sound would play in the background?

Finish Playing The Sound Before The Next One..
When i use the PlaySound API, sounds dont wait for the last one to play through, so my question is; how do I make the sounds play through before playing the next one?

And how can i get the lenght of a sound file (mp3 or wav)?

Playing Sound From CDs Having Different Formats
Hi friends,
I have a VB program which is using Microsoft Multimedia control to play Audio CD. Its working fine. I want to play MP3 CDs also with the same programs.
But first of all I want to know from my program, that which type of CD is inserted. i.e, whether it is a normal audio CD or and MP3 CD.
anybody having some idea..?

thanks in advance..

Thomas George

Playing A Sound File
Hi all. I can't remember if this was possible or I'm just making things up. There used to be a control that looked like a yellow speaker (sort of like the sound volume icon in the systray bar). It would allow you to "embed" the sound in your program so you wouldn't have to load it from a path. I can't find this control. I only want the sound to play when a certain event in my program happens. I don't need the user to click anything to load a sound file. I'm almost positive it wasn't the windows media player or mmcontrol. Anyone know what I'm talking about?

I did find a control called "wave sound" in the insertable objects section of components but when I put it in my program it automatically brings up "sound recorder". It will let me record something but of course I want a file I have not one I have to record. The sound recorder doesn't give you the option to open a file. When I close the sound recorder, there is no option in its properties to load a file and I can't get that sound recorder to come up again without deleting & adding the control again. Also, if you do record something in it, it will play the file if you double click on it.

Playing Sound In VB6 Application ? ? ?
Ok, I got my litl porgram done now, but at the end i realized that i need to play sound constantly all the time my program runs. I've found one way to do it by adding this script into main form:

Private Sub form_load()
'This script could be changed to the Command1_Click event as well or any event you want to play your sound on though i need it the whole time

Dim i As Long
Const SoundFileName$ = "C:Documents and SettingsOwnerMy DocumentsMy Musicinacard_1.wav"

i = waveOutGetNumDevs()
If i > 0 Then
i& = sndPlaySound(SoundFileName$, Flags&)
End If

End Sub

And also i have to declare funct. in separate module:

Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Declare Function waveOutGetNumDevs Lib "winmm" () As Long

Global Const SND_SYNC = &H0 'just after the sound is ended exit function
Global Const SND_ASYNC = &H1 'just after the beginning of the sound exit function
Global Const SND_NODEFAULT = &H2 'if the sound cannot be found no error message
Global Const SND_LOOP = &H8 'repeat the sound until the function is called again
Global Const SND_NOSTOP = &H10 'if currently a sound is played the function will return without playing the selected sound

Global Const Flags& = SND_ASYNC Or SND_NODEFAULT

So, as the result I get that soundfile, "binacard1.wav" playing in the background whenever my program starts (it only has one main window).
Though My Questions are:

1. How can i include that soundfile in my .exe file? Is it possible at all?
2. If not, Is there any way i can get my program to play it from internet? (file is ~300kb and i already uploaded it on
3. I also need to LOOP playing of this sound, so that it's being played the whole time until u terminate the program. Is it Possible at all, and if yes - what do i change in my script? Do i have to use another one in order to do that?

//So the whole point is to get compact with the sound (so i only have one .exe file and nothing else and so it works the same way on any PC), and LOOP it.

i'm not really experienced in VB6 so don't mind me if something i've asked is really simple

Playing A Sound In Hz (save To Wav)
Is there a simple way to play the sound through the sound card and not the system speaker? I seen a sample but it included exporting it to a wav file and all. I just want to be able to play 643.0 Hz for a certain duration and proceed to the next tone.


Playing A Sound On Click
ok i want as much little code as posibble to make "Command1" play "nudge.wav" ok click

with no components just declerations if posible


A Different Way Of Playing A Sound File (wav)
I noticed that there are two main ways used for playing sound files:

1. msdxm.ocx
2. PlaySound API

I noticed problems with these on older systems (win 9x). For some reason msdxm.ocx refuses to work on it, and API requires newer version of DirectX drivers to be installed.

Is there a different way to do it that will have less dependencies?

Problem Playing Sound
I am using a Windows Media Player control and a Flash control in a form. I am playing a MP3 file through the Media Player control. The Flash file also has an audio in it. The idea is to have both this audio playing while the form is running. This works on some systems and does not work on some systems. Can someone help please? I am desperate.


Playing A Sound In A VB Application
i know thats a simple question but im just a beginner, how can i play a sound, like a .WAV file, in my appilcation? and also, is their a way to create a sort of area where you can click it to do a function? like just selecting a general area, like a circle, and make it clickable? thank you very much

How Ti Know If A Sound Stops Playing
Hi! i have a question.. is't possible to determine whether a sound played using:

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

is capable of determining whether the sound that it has played has stoped playing?
if not, then is there any other way in doing this? thanks!

Playing Sound Files
If t is possible, how can I play a sound file (.wav, .mp3) in a mouse over event. I'm in te middle of a university project and it would be nice to be able to add some sound to the project (all about the history of Canterbury). Any help will be "sound".

-= Help With Playing Sound Clips =-
Hey.. I amm trying to figure out how to make a command button play a sound clip. If someone could help me out, that would be great. Thanks!

Playing A Sound (tone) From VB
Can anyone point me to sample code for playing a set frequency through the
sound card.
Phil Jones
The Logical Interface
Phone 612 95410367
Fax 612 9541 0535

Playing An XM Sound Clip
How do you play a mod/xm file in a visual basic 6 program?

I already have the XM file composed and tracked, and the vb6 program written, now all I want to do is make it play the song when it loads.

Pretty much like a keygen with music (except my file isn't a keygen, it's a text encryptor).

Does anyone know how to do that?

Here is a perfect example:


Playing Sound Asynchronously
I want to be able to play music whilst my splash screen which contains essential reading material is displayed. I also want to use similar sound calls throughout my program but don't want them to lock up the whole program operation whilst the sound plays. Using SoundPlay doesn't seem to work. The whole program locks up whilst the sound is being played, even if I set the asynchronous flag. How do I get sound to play whilst the rest of the program gets on with its stuff? A code snippet would be helpful. Thanks.

BTW this site is awesome I wish I had found this 3 month's ago. I learned more of what I want to know surfing here for an hour than all the books I have read to date on VB.NET.



Playing Sound File
Hello all,

I am using the following function to play sound.

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

retval = PlaySound("c:windowsmediading.wav", 0, 0)

The problem is that this function is a part of a clock application and the the clock stops for a second when the sound is playing.
any idea of different way to play sound files without delay and witout player running of course ??



Playing A Sound File
1) Now there any Win32 API/VB functions for laying sound files? I don't wanna use a MCI control or other control......I just wanna play it. These controls are just overkill, pals.

2) Is there a way to import a sound file into our VB project?(like the way u em-bed a picture file into the VB program so that it doesn't get lost easily)

Thanks a lot! :-)

Copyright 2005-08, All rights reserved