How to create a audio wave while recording in Flutter?

7.1k views Asked by At

I want to create an audio wave while recording in flutter. To record voice I am using Flutter Audio Recorder. To create wave I tried this plugin as well Wave Generator, but could not find any positive results.

Code Sample:

 class AudioWave extends StatelessWidget {
  const AudioWave({
    Key key,
    @required this.translateX,
    @required List<double> audioPowerData,
    })  : _audioPowerData = audioPowerData,
           super(key: key);

  final double translateX;
  final List<double> _audioPowerData;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: screenUtil.screenWidth,
      margin: const EdgeInsets.only(top: 0, right: 0),
      alignment: Alignment.topRight,
      child: CustomPaint(
        child: Container(height: 180.0, width: screenUtil.screenWidth),
        painter: CurvePainter(translateX: translateX, data: _audioPowerData),
        isComplex: true,   
        willChange: false,    
      ),
    );
  }
}
1

There are 1 answers

3
BananaNeil On

I recently did some work on a package called mic_stream

If you clone the repo from here, and run the app that is held within the example directory, you'll see a (relatively crude) waveform thats pulled in from the microphone. Hopefully it can give you a good starting point for what you want to build!

UPDATE: I believe there is something wrong with the mic_stream code in the ios side.

I might instead recommend using some of the IOS code from the following repository, which has an ios visualizer: https://pub.dev/packages/audio_visualizer