Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Issue with sound play with selected device

KRP
Guest
Quote
2014-03-25 13:59:25

Hello,

Firstly, thanks a lot for your work. Appreciate it.
I have been able to successfully integrate your DLL in my C.net app. I'm using irrKlang.DLL with .Net FW 3.5.

My issue - I use a form in my application to populate, show and save (to system registry) the audio device to be used. And in another form, I fetch the audio device from the registry and pass it as a parameter to the sound engine as below -

IrrKlang.ISoundEngine irrKlangEngine = new IrrKlang.ISoundEngine(IrrKlang.SoundOutputDriver.AutoDetect,
IrrKlang.SoundEngineOptionFlag.DefaultOptions, strRingingDevice);

Here I have tested the "strRingingDevice" with the string name of the audio device and also from the index value of the combo box but the sound plays from the default device and not from the one I have selected. May I know what wrong am I doing here?

Thank you in advance.


niko
Moderator
Quote
2014-03-26 07:22:46

It seems that your string might be wrong. Are you sure you are getting it from the enumeration, without you changing it?


KRP
Guest
Quote
2014-03-26 07:33:27

Yes, I'm getting the devices using -
//Get the list of installed sound devices.
IrrKlang.ISoundDeviceList sdl = new IrrKlang.ISoundDeviceList(IrrKlang.SoundDeviceListType.PlaybackDevice);

//Add each device to a combo box.
for (int i = 0; i < sdl.DeviceCount; i++)
{
//MessageBox.Show(" " + sdl.getDeviceDescription(i));
cmbRingingDevice.Items.Add(sdl.getDeviceDescription(i) + "\n");
}

And yes I'm sure I'm not changing the fetched value before giving to the engine. I have confirmed this putting in break points.


niko
Moderator
Quote
2014-03-26 10:01:58

You are putting the device description + a new line in to that combobox. Are you getting that one maybe? What you need to use is the string gotten from getDeviceID().
What is the content of the string your are setting exactly in your case? Could you post it in here? Who knows, maybe it contains some invalid characters (but it shouldn't)


KRP
Guest
Quote
2014-03-26 10:41:57

I checked it by removing the + "\n" but still the same. I have also cross verified the value from the code and the one from the registry, both are the same. I don't find any invalid characters in the string.

Value from the string - Speakers (VIA High Definition Audio)


niko
Moderator
Quote
2014-03-26 12:23:54

Yes, that's the description of the device. As I wrote above, use the device id instead, then it will work. Use getDeviceID() instead of getDeviceDescription().


KRP
Guest
Quote
2014-03-27 10:28:49

Eureka!!! Thanks a lot Niko :). Finally got it working. Looks like the culprit was the device description. I used it since the device name had to be shown in the combo box. It was more easy to fetch and show that way.
Anyway, all fine now.

Thank you very much for your patience and help.


ipbh
Registered User
Quote
2014-03-27 14:25:08

I am trying to achieve something similar,could you share sample code please. Thanks !


KRP
Guest
Quote
2014-03-28 09:55:15

Hey, here is the code -
Fetch devices from system and show them :
//To store the Key-Value pair of audio devices
var DeviceList = new List<System.Collections.DictionaryEntry>();

//Get the list of installed sound devices.
IrrKlang.ISoundDeviceList SoundDeviceList = new IrrKlang.ISoundDeviceList(IrrKlang.SoundDeviceListType.PlaybackDevice);

//Add each device to a combo box.
for (int i = 0; i < SoundDeviceList.DeviceCount; i++)
{
DeviceList.Add(new System.Collections.DictionaryEntry(SoundDeviceList.getDeviceDescription(i), SoundDeviceList.getDeviceID(i)));
}
cmbRingingDevice.DataSource = DeviceList;
cmbRingingDevice.DisplayMember = "Key";
cmbRingingDevice.ValueMember = "Value";
//Show device name saved in the registry
if (Application.UserAppDataRegistry.GetValue("Ringing Device Name") != null)
{
string strRingingDevice = Application.UserAppDataRegistry.GetValue("Ringing Device Name").ToString();
if (strRingingDevice != null)
cmbRingingDevice.Text = strRingingDevice;
}

/////////////////////////////////////////////
//Fetch device from registry :
if (Application.UserAppDataRegistry.GetValue("Ringing Device ID") != null)
{
string strRingingDevice = Application.UserAppDataRegistry.GetValue("Ringing Device ID").ToString();
if (strRingingDevice != "")
{
IrrKlang.ISoundEngine irrKlangEngine = new IrrKlang.ISoundEngine(IrrKlang.SoundOutputDriver.AutoDetect,
IrrKlang.SoundEngineOptionFlag.DefaultOptions, strRingingDevice);

irrKlangEngine.AddSoundSourceFromFile(System.IO.Path.Combine(Application.StartupPath, @"irish.wav"));
irrKlangEngine.Play2D(System.IO.Path.Combine(Application.StartupPath, @"irish.wav"), true);
popUpFrom.ShowBox("Answer the incoming call?\nCaller: " + CAPName + " \nService Name: " + strIP[1], strIP[0]);
irrKlangEngine.StopAllSounds();
}
}


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internatio?al" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact