How to create a audio wave while recording in Flutter?
Asked Answered
H

1

15

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,    
      ),
    );
  }
}
Hobbism answered 7/9, 2020 at 7:51 Comment(1)
Research about "audio visualization" keyword. It's just a basic math.Chlordane
G
4

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

Goalkeeper answered 18/4, 2021 at 19:28 Comment(3)
the link seems to be brokenHooknose
@GyuriMajercsik I updated it, and added an additional note about the ios lib potentially being imperfect.Goalkeeper
Thanks @BananaNeil.Hooknose

© 2022 - 2024 — McMap. All rights reserved.