Android Flutter 分析音频波形

标签 android audio flutter

我想创建一个具有类似于 SoundCloud View 的音乐应用程序,这个要清楚:This

我想为每个栏创建一个这样的类:

class Bar {
  const Bar(this.alreadyPlayed, this.index, this.height);

  final bool alreadyPlayed;
  final int index;
  final double height;
}

其中 alreadyPlayed 是一个 bool 值,它指示条是应该着色还是变灰,index 是条的编号和高度,well 是条的高度。前两个Variables应该不难获取,我的问题是获取bar的高度,也就是当时音乐的强度。这已经足够了,但如果有人知道如何计算特定频率(例如 225 Hz)的强度,那就更好了。

但不管怎样,如果有帮助,我将添加我想要在伪代码中实现的目标:

// 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.

我问的可能吗?

最佳答案

看起来您正在研究从音频生成波形图。到目前为止,您尝试过什么吗?

虽然这里没有简短的答案。您可以使用 flutter_ffmpeg 开始探索至 generate waveform data from audio .波形数据的格式由您决定。获得数据后,您可以使用 CustomPaint 在 Flutter 中生成波形图.您可以查看此 blog post 上的示例.示例中使用的波形数据为 JSON 格式。

关于Android Flutter 分析音频波形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51894140/

相关文章:

Android 如何从 Activity 中获取出席者姓名和电子邮件

android - 在android中自定义youtube播放器 View

javascript - 为什么 .click() 在 Android 上不起作用?

javascript - 克隆音频源而无需再次下载

python - Python中的视频和语音聊天可操作性

Flutter:构建期间调用 setState() 或 markNeedsBuild()

flutter - 无法使用特定 block 的vs代码以 Dart (flutter)的方式折叠代码

flutter - 为什么移动 slider 会将体重和年龄更改为初始值

android - Asynctask 不会更新数组

javascript - 单击按钮将代码添加到JS