Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a audio wave while recording in Flutter?

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,    
      ),
    );
  }
}
like image 809
basit Avatar asked Sep 07 '20 07:09

basit


1 Answers

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

like image 98
BananaNeil Avatar answered Oct 21 '22 07:10

BananaNeil