Featured Image

Moving from ‘audioplayers’ to ‘SoLoud’ in Flutter: Enhancing Audio Effects Made Easy

This article was originally published on Medium on Oct 1, 2024.

Today, I’m gonna share with you guys something that I experienced in doing an interesting project Singistic, in our company ELO. Our mobile team was working on publishing an updated version of this app, but we were facing difficulties in updating the SDK version to 34 just because our app used a package called audioplayers, which was customized and not maintained for a long time. We needed that package to apply effects on recorded voice, but at the same time, we couldn’t upgrade that package because it was so time-consuming. Then we searched for an alternative package and found a new one flutter_soloud, that works on low latency and can add effect on recorded voice.

When developing Flutter apps, we aim to keep our code efficient and maintainable. We achieve this by choosing the right tools that offer flexibility and performance. In our karaoke app, Singistic, users can record songs, add echo and reverb effects, and enjoy a rich audio experience. Initially, we used the audioplayers package with custom methods and native plugins to achieve these effects. However, as time went on, we encountered some challenges that led us to switch to the SoLoud audio engine.

In this article, you’ll learn:

  • Why we transitioned from audioplayers to SoLoud
  • How to implement echo and reverb effects using SoLoud
  • The differences in implementation between audioplayers and SoLoud
  • How to dynamically update audio effects in real-time

Let’s dive in!

Why Transition from audioplayers to SoLoud :

While the audioplayers package is great for basic audio playback, it doesn’t natively support advanced audio effects like echo and reverb. To work around this, we extended its functionality using custom methods and integrated native plugins. However, over time, some of these plugins became deprecated, leading to:

  • Maintenance Headaches: Constantly updating or replacing deprecated plugins was time-consuming.
  • Inconsistent Performance: Relying on external plugins sometimes led to unstable audio effects.
  • Development Delays: We spent extra time troubleshooting issues related to these plugins.

We needed a more reliable solution that offered advanced audio features out of the box, without the hassle of extra plugins. That’s when we discovered SoLoud.

Implementing Echo and Reverb with audioplayers

Here’s how we initially added echo and reverb effects to our recorded voice files using audioplayers.

Breaking It Down:

  • Playback Management: We used voicePlayer.play() to play the recorded voice file locally.
  • Volume Control: Managed vocal volume using voicePlayer.setVolume().
  • Enabling/Disabling Effects: Enabled effects based on the vocal volume.
  • Applying Effects: Applied echo and reverb using voicePlayer.setEffects(), a method extended via native plugins.
  • State Management: Updated the UI with the new echo and reverb values.

Challenges:

  • Dependencey on Native Plugins: The setEffects method relied on external plugins that could become outdated.
  • Inconsistent Results: Effects didn’t always work the same way on all devices.
  • Extra Maintenance: Keeping plugins up to date added more work for us.

Implementing Echo and Reverb with SoLoud

Switching to SoLoud simplified our implementation significantly. Here’s how we did it.

Initialization of SoLoud Audio Engine

Note: It’s important to initialize SoLoud only once in your application to avoid conflicts.

Loading Audio Files

Loading Voice and Music: Loaded the recorded voice and background music files into SoLoud.

Applying Echo and Reverb Effects at the initial state

Global Filters: Applied echo and reverb filters globally, affecting all audio streams.

Adjusting Parameters: Set the intensity of the effects based on user input.

Playing Audio

Dynamically Updating Effects

Key Takeaways:

  • Simplified Code: With SoLoud, we eliminated the need for custom methods and external plugins, simplifying our codebase.
  • Improved Performance: SoLoud is optimized for real-time audio, providing a smoother user experience.

Easier Maintenance: Fewer dependencies mean less time spent on upkeep and troubleshooting.

Conclusion

Transitioning from audioplayers to SoLoud significantly enhanced our app Singistic. We achieved better performance, simplified our code, and provided a more consistent and enjoyable experience for our users.

If you’re developing a Flutter app that requires advanced audio functionalities, consider integrating SoLoud. It offers powerful features out of the box and can save you a lot of time and headaches down the line.

If you want to learn more step by step about the implementation of SoLoud then you can read this article How I implemented SoLoud in Flutter apps.

If you’re building a SaaS product and need help with audio, we’d love to talk. Click here to book a free SaaS plan & quote.

Scroll to Top