473,383 Members | 1,862 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,383 software developers and data experts.

How to play sound in many devices at the same time?

Hello

I want to play sound in three external sound cards at the same time,I mean when I click in a button I can hear sound from three speakers which are related to my three sound cards. I have a function but it plays sound only in one device,the first one it finds,I mean in this code the first device is number 0,so it play sound in it,but if you write device number 1 at first,it will play sound in it,as a conclusion it plays sound only in one device,it dont works for all the devices at the same time. This is its code:
Expand|Select|Wrap|Line Numbers
  1. public void playAllAvailableDevices()
  2. {
  3. //create a new class for each wav file & output etc.
  4. WaveOut waveOut1 = new WaveOut();
  5. WaveFileReader waveReader1 = new WaveFileReader(fileName);
  6. WaveOut waveOut2 = new WaveOut();
  7. WaveFileReader waveReader2 = new WaveFileReader(fileName);
  8. WaveOut waveOut3 = new WaveOut();
  9. WaveFileReader waveReader3 = new WaveFileReader(fileName);
  10.  
  11. switch (waveOutDevices)
  12. {
  13. case 1: 
  14. waveOut1.Init(waveReader1);
  15. waveOut1.DeviceNumber = 0;
  16. waveOut1.Play();
  17. break;
  18. case 2: 
  19. waveOut1.Init(waveReader1);
  20. waveOut1.DeviceNumber = 0;
  21. waveOut1.Play();
  22.  
  23. waveOut2.Init(waveReader2);
  24. waveOut2.DeviceNumber = 1;
  25. waveOut2.Play();
  26. break;
  27. case 3:
  28. waveOut1.Init(waveReader1);
  29. waveOut1.DeviceNumber = 0;
  30. waveOut1.Play();
  31.  
  32. waveOut2.Init(waveReader2);
  33. waveOut2.DeviceNumber = 1;
  34. waveOut2.Play();
  35.  
  36. waveOut3.Init(waveReader3);
  37. waveOut3.DeviceNumber = 2;
  38. waveOut3.Play();
  39. break;
  40. }}
  41.  
fileName is the name of the sound file I want to play,in my code I get this name from a darabase:
Expand|Select|Wrap|Line Numbers
  1. private void btnAlarm1_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         OdbcConnection cn = new OdbcConnection("DSN=cp1");
  5.         cn.Open();
  6.         OdbcCommand cmd1 = new OdbcCommand("select chemin from alarme where code_alarme=41", cn);
  7.         cmd1.Connection = cn;
  8.         fileName = cmd1.ExecuteScalar().ToString();
  9.         wave = new WaveOut();
  10.         playAllAvailableDevices();
  11.     }
  12.  
Can you help me to find the solution please???? Thank you in advance. Good day.
May 15 '11 #1
1 2556
Brosert
57
Where and how is waveOutDevices (passed to your switch statement) set?

Currently, it appears that within playAllAvailableDevices
you switch based on a variable that is never set.
Further, there is only 1 pass through the function, so only 1 device will ever play.
May 18 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bill Dandreta | last post by:
I posted a message ("Help with my 1st Tkinter program") a few days ago complaining that Python did not have any built in basic cross platform sound capability. I was wrong (at least partly). Python...
2
by: | last post by:
Hi everybody. Need your help. How can I play sound (.wav-file / camera click) on mouseclick? TIA willy wuff ...
1
by: svpsiva | last post by:
How to play sound in j2sdk1.4.2_07??
0
by: yuen | last post by:
How to play sound by C# without using WMP?
0
by: seo gang ho | last post by:
this is my source :$ (tone generator) how to play sound in outputbuffer? please help me...teach me detail...:$ using System;
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
10
by: CM | last post by:
Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As...
1
by: tinmaung | last post by:
hi please help me i want to know how to play sound in java application i don't mean java applet if you can, please send me how to write coding to play sound in application.
1
by: anuvanand1 | last post by:
I am in need of user defined function for Play sound .........
3
by: jamessarvs | last post by:
Windows Media Player cannot play the file because there is a problem with your sound device. There might not be a sound device installed on your computer, it might be in use by another program, or it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.