I'm using NAudio and the AudioSwitcher libary in my software. I want to change the volume for one audio device like in this picture:
Unfortunately I can't find a description how to get access to the volume controle in this mixer with one of the 2 libaries.
Is there anywhere a documentation for the libary or someone has an example for me?
So far I only managed to get access to this volume control but this is not the same like above
For the settings that I managed to work I use:
IEnumerable<CoreAudioDevice> DeviceList = m_Controller.GetPlaybackDevices();
foreach (CoreAudioDevice PlaybackDevice in DeviceList)
{
if (PlaybackDevice != null)
{
if (PlaybackDevice.State == AudioSwitcher.AudioApi.DeviceState.Disabled)
continue;
string strTmp = PlaybackDevice.FullName.ToUpper();
if (PlaybackDevice.FullName.Contains("xxxxx"))
{
m_PlaybackDevice = PlaybackDevice;
m_PlaybackDevice.SetAsDefault();
m_PlaybackDevice.SetAsDefaultCommunications();
PlaybackDevice.SetVolumeAsync(100);
}
}
}
But it is not the volume setting from the first picture
Update 1:
I tried the link with the nAudio example
try
{
NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
NAudio.CoreAudioApi.MMDeviceCollection DevCol = MMDE.EnumerateAudioEndPoints(NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All);
foreach (NAudio.CoreAudioApi.MMDevice dev in DevCol)
{
try
{
System.Diagnostics.Debug.Print(dev.FriendlyName);
//dev.AudioEndpointVolume.Mute = true;
}
catch (Exception ex)
{
//Do something with exception when an audio endpoint could not be muted
}
}
}
catch (Exception ex)
{
//When something happend that prevent us to iterate through the devices
}
But this gives me only a list of the hardware devices and not a list of the applications from my first picture. I need the application list. e.g. when firefox runs I could change the volume of the firefox app in that audio mixer panel.
Update 2
NAudio.CoreAudioApi.MMDeviceEnumerator MMDE = new NAudio.CoreAudioApi.MMDeviceEnumerator();
throws sometimes, but not always an exception:
Blockquote System.InvalidCastException: Das Objekt des Typs "System.__ComObject" kann nicht in Typ NAudio.CoreAudioApi.Interfaces.MMDeviceEnumeratorComObject" umgewandelt werden.
bei NAudio.CoreAudioApi.MMDeviceEnumerator..ctor()
Sometimes it works but most times I get that cast exception