jfversluis / Plugin.Maui.Audio

Plugin.Maui.Audio provides the ability to play audio inside a .NET MAUI application
MIT License
245 stars 39 forks source link

Equalizer support #59

Open wasyster opened 1 year ago

wasyster commented 1 year ago

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);
    }
}**
jfversluis commented 1 year ago

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.