473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Playing sounds from resources in VB2005

Using the following routine to play embedded wav files:

Private Sub PlaySound(ByVal Sound As Int32)
Select Case Sound
Case 1 : My.Computer.Audio.Play(My.Resources.Sounds.GoOnlin e,
AudioPlayMode.Background)
Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpe n,
AudioPlayMode.Background)
Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSla m,
AudioPlayMode.Background)
Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.Private Msg,
AudioPlayMode.Background)
End Select
End Sub

Occasionally, instead of hearing the sound, i just hear white noise. This
doesn't happen if I play the sounds from files. Is there a better way to
play sound resources to eliminate the white noise anamoly?
Jan 28 '06 #1
1 3724
Max
Hi

I had this problem too. Finally I solved this by performing this playing the
sound synchronosly in a backgroundworkerprocess.
Private WithEvents bkw As New System.ComponentModel.BackgroundWorker
Public Sub PlaySound(ByVal Sound As System.IO.UnmanagedMemoryStream)
If bkw.IsBusy Then Exit Sub
bkw.RunWorkerAsync(Sound)
End Sub

Private Sub bkw_DoWork(ByVal sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles bkw.DoWork
My.Computer.Audio.Play(e.Argument, AudioPlayMode.WaitToComplete)
End Sub

"Terry Olsen" wrote:
Using the following routine to play embedded wav files:

Private Sub PlaySound(ByVal Sound As Int32)
Select Case Sound
Case 1 : My.Computer.Audio.Play(My.Resources.Sounds.GoOnlin e,
AudioPlayMode.Background)
Case 2 : My.Computer.Audio.Play(My.Resources.Sounds.DoorOpe n,
AudioPlayMode.Background)
Case 3 : My.Computer.Audio.Play(My.Resources.Sounds.DoorSla m,
AudioPlayMode.Background)
Case 4 : My.Computer.Audio.Play(My.Resources.Sounds.Private Msg,
AudioPlayMode.Background)
End Select
End Sub

Occasionally, instead of hearing the sound, i just hear white noise. This
doesn't happen if I play the sounds from files. Is there a better way to
play sound resources to eliminate the white noise anamoly?

Mar 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kiteman \(Canada\) | last post by:
Instead of a beep sound playing as an alarm or reminder I would like to be able to play a more interesting sound. On the web, I found and tried a sound routine that uses the SOUND.DRV but it does...
1
by: Peter Schmitz | last post by:
Hi, I'm just trying to play a *.wav file, making use of the unmanaged function "sndPlaySoundA" in winmm.dll, but I still got one question: How can I avoid, that the sound file itself has to be...
0
by: Adrian | last post by:
Is there a way in C# to play various sounds (WAV files) simultaneously? I also need to jump to the middle of the WAV files and start playing from there, not just from the beginning. Thanks.
8
by: shlomi | last post by:
Hello, It's been long time that I'm investigating on how to play Avi file from memory, with no success. What I'm trying to do is to get a scrambled Avi file to memory, fix same data and...
5
by: Tom W | last post by:
Ok, hi evryon now I swear I put this post up yesterday but I cant find it anywhere so ill put it up again So I'm making a program to play music but the code ive got for the open dialog thing isn't...
1
by: Tom W | last post by:
hi I've found some code for playing sounds and it kinda works. This is what I have \\\\\Public Class SoundClas Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name As String, ByVal hmod As...
1
by: Heinz K | last post by:
Hi all, I have a text list with 20 entries which I want to store in the resources-tab in VB2005. Therefore an arraylist is of course preferred as i want to access it like...
1
by: poo22 | last post by:
Please help, i've looked everywhere on the internet for the answer, but nothing works! here is my problem: I have a Pong game, and would like to have a background .wav file playing. I also have...
0
by: S.Tedeschi | last post by:
Hi all, as already posted, I'm converting an app and I'm facing tons of cons. One of them is my .aspx files can be used by ComponentDesigner to load, e.g., SelectCommands' CommandText, but when...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.