multiple sound cards

Started by
9 comments, last by The__Void 15 years, 10 months ago
hi everyone I'm developing an aplication that needs to use multiple sound devices at the same time, I search several websites and googled for a few hours trying to find a solution and I didn't find anyting being able to change the device would also work, but using both would be great any ideas? thanks in advance edit: oh ya and it's for win xp
Advertisement
What language, API and OS?
that was a fast reply :)

well it's a simple voip phone, using sip messages

I'm using C# and the OS is win XP

not using any API, just the .net framework soundPlayer
DirectSound should allow opening multiple devices without a hitch. OpenAL should also handle multiple devices.
Quote:Original post by SnotBob
DirectSound should allow opening multiple devices without a hitch. OpenAL should also handle multiple devices.


I'll be killing a bug with a bazzuka using those :D

I'll check out the DirectSound

know any websites with examples? I never used those
http://www.codeproject.com/KB/audio-video/DirectSound9p1.aspx

this should do it :)

thanks alot guys, you saved me a few hours of pain
Are you already using multiple sound cards?
Last time I put two sound blasters on the same PC the driver went crazy and took quite a while to go back to a predictable state.

Please, give me good news!

Previously "Krohm"

not yet, I'll do it tomorow
and actualy it's not 2 sound cards, it's a onboard sound card and an usb phones

I'll post the code here once I'm done
as promised here is the code

it's only used to play a sinlge audio file, but it's easy to change to play more them one

have fun and good coding ;)

using System;using System.Collections.Generic;using System.Text;using System.Media;using System.Runtime.InteropServices;using System.Management;using Microsoft.DirectX;using Microsoft.DirectX.DirectSound;namespace audio_device_changer{    static class player    {        //primary device (headphones)        private static Device dSound = null;        private static SecondaryBuffer sound = null;        //secondary device (speakers)        private static Device dSound2 = null;        private static SecondaryBuffer sound2 = null;        private static BufferDescription d = null;        private static DevicesCollection devList = null;        internal static DevicesCollection DevList        {            get { return devList; }        }        /// <summary>        /// true if ringing is playing        /// </summary>        internal static bool Playing        {            get { return playing; }        }        private static bool playing = false;        /// <summary>        /// if true the secoundary device will also play        /// </summary>        internal static bool PlaySecondary        {            get { return playSecondary; }            set            {                if (!value && Playing)                    if (sound2 != null)                        sound2.Stop();                if (value && Playing)                    if (sound2 != null)                        sound2.Play(0, BufferPlayFlags.Looping);                playSecondary = value;            }        }        private static bool playSecondary = false;        /// <summary>        /// setups the player        /// </summary>        /// <param name="FilePath">path to the rining wave file</param>        /// <param name="owner">onwer form</param>        /// <returns></returns>        internal static bool SetStuff(string FilePath, System.Windows.Forms.Form owner)        {            try            {                devList = new DevicesCollection();                d = new BufferDescription();                d.Flags = BufferDescriptionFlags.ControlVolume | BufferDescriptionFlags.ControlFrequency | BufferDescriptionFlags.ControlPan | BufferDescriptionFlags.ControlEffects;                if (DevList.Count >= 2)                {                    dSound = new Device(DevList[1].DriverGuid);                    dSound.SetCooperativeLevel(owner, CooperativeLevel.Priority);                    sound = new SecondaryBuffer(FilePath, d, dSound);                }                if (DevList.Count >= 3)                {                    dSound2 = new Device(DevList[2].DriverGuid);                    dSound2.SetCooperativeLevel(owner, CooperativeLevel.Priority);                    sound2 = new SecondaryBuffer(FilePath, d, dSound2);                }                return true;            }            catch (Exception ex)            {                return false;            }        }        /// <summary>        /// starts ringing        /// </summary>        internal static void PlayRing()        {            try            {                if (sound != null)                {                    sound.Play(0, BufferPlayFlags.Looping);                }                if (sound2 != null && PlaySecondary)                {                    sound2.Play(0, BufferPlayFlags.Looping);                }                playing = true;            }            catch (Exception ex)            {                if (true)                {                }            }        }        /// <summary>        /// stopts ringing        /// </summary>        internal static void StopRing()        {            try            {                if (sound != null)                {                    sound.Stop();                }                if (sound2 != null)                {                    sound2.Stop();                }                playing = false;            }            catch (Exception ex)            {                if (true)                {                }            }        }        /// <summary>        /// stops sound and disposes objects        /// </summary>        internal static void Destroy()        {            try            {                if (playing)                    StopRing();                if (devList != null)                    devList = null;                if (d != null)                    d.Dispose();                d = null;                if (dSound != null)                    dSound.Dispose();                dSound = null;                if (dSound2 != null)                    dSound2.Dispose();                dSound2 = null;            }            catch (Exception ex)            {            }        }    }}


ok I have a small problem

the sound works fine but when I minimize my Form the sound stops

I know this is suposed to happen, but is there anyway around it?

also find something about using Microsoft.DirectX.AudioVideoPlayback, but I can't find it

any ideas?
thanks in advance

This topic is closed to new replies.

Advertisement