I'd know how can I mute or select only one audio channel in C#. I have to play an audio file only in the left/right channel. Is it possible? What do I have to do?
Asked
Active
Viewed 947 times
1
-
Please provide some more details and code. How do you play your audio file so far? – abc Jan 18 '17 at 22:38
-
i'm using System.Media SoundPlayer – Marco Zanaboni Jan 18 '17 at 23:09
2 Answers
1
You will likely need to use the Balance property of System.Windows.Media.MediaPlayer.
MSDN MediaPlayer Balance Property
Set it to -1 for the left and 1 for the right channel.
MediaPlayer mediaPlayer = new MediaPlayer();
private void Button_Click(object sender, RoutedEventArgs e)
{
mediaPlayer.Open(new Uri(@"C:\temp\Kalimba.mp3"));
if (DateTime.Now.Second % 2 == 0)
{
mediaPlayer.Balance = 1;
mediaPlayer.Play();
}
else
{
mediaPlayer.Balance = -1;
mediaPlayer.Play();
}
}

Bernard Vander Beken
- 4,848
- 5
- 54
- 76

Kip Morgan
- 728
- 3
- 12
-
Can you provide me a sample code? I need to create an audio player and select the channel (it depends on the time), then play the audio. Thank you – Marco Zanaboni Jan 19 '17 at 08:21
1
System.Media.SoundPlayer lacks the possability of adjusting the balance. You should try something different. System.Media.SoundPlayer simply controls playback of a sound from a .wav file

abc
- 2,285
- 5
- 29
- 64