473,748 Members | 4,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simultaneous Sounds

I'm using the .Net 2.0 SoundPlayer class for the sound effects in my app. But it doesn't seem to allow simultaneous sounds... I'm even executing the instantiation and play on a separate thread. But sound two never gets played. Anyone have much experience with this?

Thanks.

J
Apr 26 '07 #1
2 12913
Hi,

The .NET 2.0 SoundPlayer class internally uses winmm API PlaySound
(http://msdn2.microsoft.com/en-us/library/ms712879.aspx) to play the wave
file and this API cannot play multiple wave files simultaneously in a
process.

To workaround this, you will either use DirectX or use Windows Media Player
to play the wave files:

1) Reference c:\windows\syst em32\wmp.dll
2) Use following code:

WMPLib.WindowsM ediaPlayer wp = new WMPLib.WindowsM ediaPlayer();
wp.URL = @"c:\1.wav";

WMPLib.WindowsM ediaPlayer wp2 = new WMPLib.WindowsM ediaPlayer();
wp2.URL = @"c:\2.wav";

This will play the two wave files simultaneously.

Here's some tutorials on using Managed DirectX to play sound:

#Managed DirectX Tutorial Part 2 - Samus Running - The Code Project -
Multimedia
http://www.codeproject.com/cs/media/mdxtutorial2.asp

#DirectX:Direct Sound:Tutorials :VBNET:DX9:Play ing Sounds - GPWiki
http://gpwiki.org/index.php/VBNET:DirectSound

Hope this helps.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 27 '07 #2
Great info. Thanks.
"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:QO******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi,

The .NET 2.0 SoundPlayer class internally uses winmm API PlaySound
(http://msdn2.microsoft.com/en-us/library/ms712879.aspx) to play the wave
file and this API cannot play multiple wave files simultaneously in a
process.

To workaround this, you will either use DirectX or use Windows Media
Player
to play the wave files:

1) Reference c:\windows\syst em32\wmp.dll
2) Use following code:

WMPLib.WindowsM ediaPlayer wp = new WMPLib.WindowsM ediaPlayer();
wp.URL = @"c:\1.wav";

WMPLib.WindowsM ediaPlayer wp2 = new WMPLib.WindowsM ediaPlayer();
wp2.URL = @"c:\2.wav";

This will play the two wave files simultaneously.

Here's some tutorials on using Managed DirectX to play sound:

#Managed DirectX Tutorial Part 2 - Samus Running - The Code Project -
Multimedia
http://www.codeproject.com/cs/media/mdxtutorial2.asp

#DirectX:Direct Sound:Tutorials :VBNET:DX9:Play ing Sounds - GPWiki
http://gpwiki.org/index.php/VBNET:DirectSound

Hope this helps.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Apr 27 '07 #3

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

Similar topics

16
4436
by: Florence HENRY | last post by:
Hello again, I still do not master everything about cookies and session. :o/ After some tests, I understood that when a visitor has several browser windows open on my website, the same session id is used for all. The consequence is that if the data are changing in one window, they will also change in another one.
10
2429
by: Eric S. Johansson | last post by:
I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be able to lock records within the very large dictionary when records are written to. Estimated number of records will be in the ballpark of 50,000 to 100,000 in his early phase and 10 times that in the future. Each record will run about 100 to 150...
1
2448
by: slugger | last post by:
Hope this is not OT: I am running into some strange things whenever my ASP pages send out simultaneous requests to another ASP page which in turn gains access to a MySQL database using a DSNless connection string. Whenever I run a page that just puts out a single request things seem to go fine, but if I activate some Flash components that reside on my ASP pages that put out requests to ASP pages which in turn try to retrieve data from...
6
2332
by: Jimnbigd | last post by:
I want to write a game, and sounds will really add to it. Note that I would always make the sounds optional. I hate it when I go to a URL and unexpectedly get sounds or music. I have played with bgsound in IE, and found I can have simultaneous sounds using multiple bgsound tags. I have done a google search, and the only results I found were for "multiple sounds", and all of these really meant "consecutive sounds" -- one sound...
1
3386
by: Semaj | last post by:
Environment: DB2 8.1.4; Windows 2000 We are evaluating the feasibility of upgrading our production DB from 7.2 to 8.1. During this process we've encountered an error when starting our application program, which establishes several JDBC connections to the database. However, this problem can be reproduced in a variety of ways, including using the CLP. Here are the steps required to reproduce the problem using the command-line...
12
2314
by: Dan V. | last post by:
Since an ASP.NET/ADO.NET website is run on the server by a single "asp_net worker process", therefore doesn't that mean that even 50 simultaneous human users of the website would appear to the database backend as a single user. Therefore, wouldn't switching our Access (actually Jet 4.0 OLEDB) database backend on our ASP.NET/ADO.NET website to an MSDE backend be an advantageous change to make while NOT limiting the number of simultaneous web...
1
1134
by: USCG | last post by:
I have an application that connects to remote machines with valid IP addresses. However, if I try to connect to a machine that does not exist, at least 45 seconds goes by before my application times out and moves to the next machine. I am interested in reducing this timeout to about 20 seconds, consistently. Is there a way to reduce the timeout value, or do I need to do this with simultanous processing? I don't really know what is...
1
2099
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous queries to a SQL Server 2000 Standard Edition SP4 running on Windows 2000 Server with 2.5 GB of memory. About 11 of these queries are over views (all over the same table) and these queries are all done from JDBC but I am not sure that matters. ...
4
6474
by: raylopez99 | last post by:
Compound question: first, and this is not easy, if there's a way to detect multiple simultaneous key presses in C# let me know (in the below code, keys c and d being pressed simultaneously or nearly so). I researched this and for C# (as opposed to MFC) there is no library function, and no easy way, though some code on the net suggested that you set up a thread that 'lives' for a certain time, then, if keys are pressed in that certain...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.