Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a 10 band equalizer (already made for linux) #1868

Open
1 task done
motobep opened this issue Jan 13, 2025 · 0 comments
Open
1 task done

Add support for a 10 band equalizer (already made for linux) #1868

motobep opened this issue Jan 13, 2025 · 0 comments

Comments

@motobep
Copy link

motobep commented Jan 13, 2025

Checklist

  • I made sure that the issue I am raising doesn't already exist

Use case / Problem

I'd like to implement a 10 band equalizer.
It fits in this package because it's easier to implement this way (compared to a standalone package).

Proposal / Solution

There will be changes to AudioPlayer class API (see "Example Code") . No breaking changes.

I forked this repo and made an implementaion for Linux (my repo).
AudioPlayer's API was extended. Controls were added for the example app. Everything's working. You can change the EQ controls in the example app to verify.

In github actions 2 tests didn't pass.
Android test

1736777119

Web test

1736777145

Maybe something's wrong with my github actions. Does anyone know the solution?

Example Code

Additional API would be like this:

  /// Gets the EQ gain by band index.
  double getGain(int bandIndex) {
    return _gains[bandIndex];
  }

  /// Gets the EQ bandwidth by band index.
  double getBandwidth(int bandIndex) {
    return _bandwidths[bandIndex];
  }

  /// Gets the EQ frequency by band index.
  double getFrequency(int bandIndex) {
    return _frequencies[bandIndex];
  }

  /// Sets the EQ gain.
  /// Value range: [-24.0, 12.0]
  Future<void> setGain(int bandIndex, double value) async {
    assert(
      -24.0 <= value && value <= 12.0,
      'Gain is not in range [-24.0, 12.0]: $value',
    );
    _gains[bandIndex] = value;
    await creatingCompleter.future;
    return _platform.setGain(playerId, bandIndex, value);
  }

  /// Sets the EQ bandwidth.
  /// Value range: [0.0, 20_000.0]
  Future<void> setBandwidth(int bandIndex, double value) async {
    assert(
      0.0 <= value && value <= 20000.0,
      'Bandwidth is not in range [0.0, 20_000.0]: $value',
    );
    _bandwidths[bandIndex] = value;
    await creatingCompleter.future;
    return _platform.setBandwidth(playerId, bandIndex, value);
  }

  /// Sets the EQ frequency.
  /// Value range: [20.0, 20_000.0]
  Future<void> setFrequency(int bandIndex, double value) async {
    assert(
      20.0 <= value && value <= 20000.0,
      'Frequency is not in range [20.0, 20_000.0]: $value',
    );
    _frequencies[bandIndex] = value;
    await creatingCompleter.future;
    return _platform.setFrequency(playerId, bandIndex, value);
  }

API usage:

AudioPlayer player = AudioPlayer();

int i = 5; // band index
double gain = 10.0; // db
double bw = 200;
double freq = 300; // Hz

player.setGain(i, gain);
player.setBandwidth(i, bw);
player.setFrequency(i, freq);

Affected platforms

Android, Windows, Linux

Platform details

For starters I want to support Android, Linux, Windows.

Audio Files/URLs/Sources

No response

Mockups

Additions to the UI of example app:

1736774960

Related issues / more information

Related issue: #303

So, I'd like to make a PR. Please answer something after you read this issue.

Working on PR

yeah

@motobep motobep changed the title Add support for a 10 band equalizer Add support for a 10 band equalizer (already made for linux) Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant