Skip to content

[PowerPlay] Integrate Audio Effect Into PowerPlay#2380

Merged
madebymozart merged 8 commits into
mainfrom
madebymozart/powerplay-effects
Jun 10, 2026
Merged

[PowerPlay] Integrate Audio Effect Into PowerPlay#2380
madebymozart merged 8 commits into
mainfrom
madebymozart/powerplay-effects

Conversation

@madebymozart

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a comprehensive audio effects system to the PowerPlay sample app. It leverages Android's native audio effects (Equalizer, Bass Boost, Reverb, and Loudness Enhancer) by attaching them to the Oboe audio stream via session ID allocation. It also adds a polished UI with a bottom sheet containing tabs for each effect, allowing users to customize their audio experience in real-time.

Changes

C++ Engine (PowerPlayMultiPlayer.cpp)

  • Session ID Allocation: Enabled session ID allocation in the Oboe stream builder (SessionId::Allocate) to allow attaching Android audio effects.
  • Exposed Session ID: Added getSessionId() to retrieve the allocated session ID from the stream.

JNI (PowerPlayJNI.cpp)

  • JNI Bridging: Added getSessionIdNative to expose the stream's session ID to the Kotlin layer.

Kotlin Audio Player (PowerPlayAudioPlayer.kt)

  • Effects Lifecycle Management: Integrated EffectsController to initialize and release audio effects when the stream is created or when the performance mode changes (which recreates the stream).

Audio Effects Managers (EffectsController.kt)

  • New Component: Created EffectsController to query supported effects and manage instances of EqualizerManager, BassBoostManager, ReverbManager, and LoudnessManager.
  • Modular Effect Wrappers: Added dedicated manager classes for each effect to encapsulate Android's AudioEffect APIs.

Jetpack Compose UI (MainActivity.kt)

  • Effects Bottom Sheet Integration: Added a button to open the Effects Bottom Sheet and integrated the EffectsBottomSheet composable.
  • Renamed UI Elements: Refactored variables and content descriptions from "Equalizer" to "Effects" to better reflect that the sheet now contains multiple audio effects beyond just the equalizer.
  • New UI Tabs: Added custom UI tabs for each effect (EqualizerTab, BassBoostTab, ReverbTab, LoudnessTab) inside the bottom sheet.

Effects Support Matrix

The availability of effects depends on hardware support and is queried dynamically at runtime:

Effect Supported Notes
Equalizer Dynamically Checked Standard multi-band equalizer
Bass Boost Dynamically Checked Enhances low frequencies
Environmental Reverb Dynamically Checked Simulates different room acoustics
Loudness Enhancer Dynamically Checked Safe volume boosting

Note

If an effect is not supported by the device's hardware/HAL, it will not be initialized and its tab will not appear or will be disabled.

How to Test

  1. Open the PowerPlay sample app.
  2. Play any track.
  3. Click the menu icon (Effects) at the bottom center.
  4. Verify that the bottom sheet opens with tabs for Equalizer, Bass Boost, Reverb, and Loudness.
  5. Adjust the sliders and toggles in each tab and verify that the audio effect is applied in real-time.
  6. Change performance modes (e.g., switch to Low Latency or PCM Offload) and verify that the effects are re-applied correctly to the new stream.

Visuals

Equalizer Tab Bass Boost Tab Reverb Tab

-   Introduced `EffectsController` to manage audio effects.
-   Refactored `Equalizer` into `EqualizerManager`.
-   Added `BassBoostManager`, `VirtualizerManager`, `ReverbManager`, and `LoudnessManager`.
-   Updated `PowerPlayAudioPlayer` to use `EffectsController`.
-   Replaced `EqualizerBottomSheetContent` with a new `EffectsBottomSheet` featuring tabs for Equalizer, Bass Boost, Virtualizer, Reverb, and Loudness.
This commit removes all code related to the Virtualizer audio effect from the PowerPlay sample, including:
*   Deletion of `VirtualizerManager.kt`
*   Deletion of `VirtualizerTab.kt`
*   Removal of Virtualizer from `EffectsBottomSheet` tabs and UI
*   Removal of Virtualizer initialization and management from `EffectsController`
-   Remove `setEnabled` and `isEnabled` from `BassBoostManager` and `EqualizerManager`.
-   Rename equalizer UI elements to general effects UI in `MainActivity`.
-   Remove `private val` from `sessionId` in effect manager constructors.
@madebymozart madebymozart requested review from flamme and robertwu1 May 14, 2026 14:38
@madebymozart madebymozart self-assigned this May 14, 2026
@madebymozart madebymozart changed the title Madebymozart/powerplay effects [PowerPlay] Integrate Audio Effect Into PowerPlay May 14, 2026
Comment thread samples/powerplay/src/main/cpp/PowerPlayMultiPlayer.cpp Outdated
@madebymozart

Copy link
Copy Markdown
Collaborator Author

Are we good to merge this?

@madebymozart madebymozart requested review from flamme and robertwu1 June 9, 2026 22:19
->setSessionId(oboe::SessionId::Allocate);

if (performanceMode == oboe::PerformanceMode::PowerSavingOffloaded) {
builder.setSharingMode(oboe::SharingMode::Shared);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why setting sharing mode to shared for offload? MMAP PCM offload only supports exclusive.

@flamme

flamme commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

I have a quick talk with Robert offline. We are okay with setting the session id by default for flexibility of testing audio effects. But also note that when the app asks for allocating session id, the audio framework right now is not allowed to use mmap low latency path. In that case, it will be better to give a hint from the UI that the stream is not mmap low latency or just remove the mmap low latency option given PowerPlay more focus on testing music playback via Oboe API.

@madebymozart madebymozart merged commit 830587b into main Jun 10, 2026
7 checks passed
@madebymozart

Copy link
Copy Markdown
Collaborator Author

I will take that feedback and open another PR

@madebymozart madebymozart deleted the madebymozart/powerplay-effects branch June 10, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants