Android Flutter Analyze Audio Waveform

5,494

Looks like you're looking into generating waveform graphs from audio. Have you tried anything so far?

There's no short answer here though. You can start exploring with flutter_ffmpeg to generate waveform data from audio. It's up to you on what format you'll use for your waveform data. Once you got your data, you can generate waveform graphs in Flutter using CustomPaint. You can check the sample on this blog post. The waveform data used in the sample is in JSON.

Share:
5,494
Fabrizio
Author by

Fabrizio

Updated on December 06, 2022

Comments

  • Fabrizio
    Fabrizio over 1 year

    I want to create a music app that has a view that resembles the one of SoundCloud, this one to be clear: This

    I thought of creating a class like this for each bar:

    class Bar {
      const Bar(this.alreadyPlayed, this.index, this.height);
    
      final bool alreadyPlayed;
      final int index;
      final double height;
    }
    

    where alreadyPlayed is a bool that tells if the bar should be colored or Greyed out, index is the number of the bar and height, well is the height of the bar. The first two Variables shouldn't be difficult to obtain, my problem is to obtain the height of the bar, so the intensity of the music at that time. This is already enough, but even better if someone knows how to calculate the intensity of a specific frequency, for example, 225 Hz, that could be useful.

    But anyway, if it helps, I am adding what I'm trying to achieve in pseudocode:

    // Obtain the mp3 file.
    //
    // Define a number of bars decided from the song length 
    // or from a default, for example, 80.
    //
    // In a loop that goes from 0 to the number of bars create 
    // a Bar Object with the default alreadyPlayed as 0, index 
    // as the index and the height as a 0.
    // 
    // Obtain the intensity of the sound in a way like this: 
    // sound[time_in_milliseconds = song_lenght_in_milliseconds / num_of_bars ],
    // and then set the height of the bar as the just found intensity.
    

    Is what I'm asking possible?

  • Naeem
    Naeem over 2 years
    did implement listen microphone and draw waves functionality ?