问题描述
我想在颤动录音时创建音频波。要录制语音,我正在使用Flutter Audio Recorder。为了产生波澜,我也尝试了Wave Generator这个插件,但是找不到任何积极的结果。
代码示例:
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,),);
}
}
解决方法
我最近在一个名为 mic_stream
的包上做了一些工作如果您 clone the repo from here 并运行保存在 example
目录中的应用程序,您将看到从麦克风拉入的(相对粗糙的)波形。希望它可以为您想要构建的内容提供一个良好的起点!