Plugin.Maui.Audio icon indicating copy to clipboard operation
Plugin.Maui.Audio copied to clipboard

Equalizer support

Open wasyster opened this issue 2 years ago • 1 comments

It would be nice to have a support for equalizer, or point me to a direction how to add one for Android and iOS. I found that Android has an equalizer in Equalizer, but I can't figure it out how to wire it up in the player.

Whay I tried was:

**internal AudioPlayer(Stream audioStream)
{
    player ??= new MediaPlayer();
    player.Completion += OnPlaybackEnded;

    if (OperatingSystem.IsAndroidVersionAtLeast(23))
    {
        stream = new MemoryStream();
        audioStream.CopyTo(stream);
        var mediaDataSource = new StreamMediaDataSource(stream);

      equalizer ??= new Equalizer(0, player.AudioSessionId);
      equalizer.SetEnabled(true);
      
        //this changes the sound, but what am I exactly setting here?
        //equalizer.SetBandLevel(0, -1000);
        //equalizer.SetBandLevel(1, -500);
        //equalizer.SetBandLevel(2, -250);
        //equalizer.SetBandLevel(3, 500);
        //equalizer.SetBandLevel(4, 1000);

        player.SetDataSource(mediaDataSource);
        player.Prepare();
	}
	else
    {
        PreparePlayerLegacy(audioStream);
    }
}**

wasyster avatar Jun 17 '23 18:06 wasyster

I don't think we will add anything like this anytime soon ourselves. If anyone is up for the challenge, feel free to discuss the proposed API changes and open a PR.

jfversluis avatar Jun 21 '23 08:06 jfversluis