Skip to content

[PowerPlay] Integrate Audio Effect Into PowerPlay#2380

Open
madebymozart wants to merge 7 commits into
mainfrom
madebymozart/powerplay-effects
Open

[PowerPlay] Integrate Audio Effect Into PowerPlay#2380
madebymozart wants to merge 7 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
@@ -0,0 +1,35 @@
package com.google.oboe.samples.powerplay.effects
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.

nit, please add copyright declaration for all new added files.

->setContentType(ContentType::Music)
->setFramesPerDataCallback(128)
->setSharingMode(SharingMode::Exclusive);
->setSessionId(oboe::SessionId::Allocate);
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.

By allocating session id, all the paths will not be on a low latency path...

Please try playing with the settings in OboeTester to see what happens when you do this.

That's why we have been telling folks to add their own effects in the app if possible and not rely on platform effects.

BassBoost, Equalizer, and Loudness effects can easily be written without using the AudioEffect from Android. The app can easily implement this as it renders audio

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