Android Flutter分析音频波形 [英] Android Flutter Analyze Audio Waveform

查看:983
本文介绍了Android Flutter分析音频波形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个音乐应用,其视图类似于SoundCloud的视图,这一点要明确:

I want to create a music app that has a view that resembles the one of SoundCloud, this one to be clear: This

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

I thought of creating a class like this for each bar:

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

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

已经播放的是一个布尔值,指示条形应该是彩色还是灰色,索引是条形的编号和高度,好是条形的高度.前两个变量应该不难获取,我的问题是获取小节的高度,因此需要了解音乐的强度.这已经足够了,但是如果有人知道如何计算特定频率(例如225 Hz)的强度,那就更好了.

where alreadyPlayed is a bool that tells if the bar should be colored or Greyed out, index is the number of the bar and height, well is the height of the bar. The first two Variables shouldn't be difficult to obtain, my problem is to obtain the height of the bar, so the intensity of the music at that time. This is already enough, but even better if someone knows how to calculate the intensity of a specific frequency, for example, 225 Hz, that could be useful.

但是无论如何,如果有帮助,我会添加我想通过伪代码实现的目标:

But anyway, if it helps, I am adding what I'm trying to achieve in pseudocode:

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

我要问的可能吗?

推荐答案

看起来您正在寻找从音频生成波形图的方法.到目前为止,您有尝试过什么吗?

Looks like you're looking into generating waveform graphs from audio. Have you tried anything so far?

虽然这里没有简短的答案.您可以开始使用 flutter_ffmpeg 从音频生成波形数据.由您决定波形数据将使用哪种格式.获取数据后,可以使用 CustomPaint .您可以在此博客文章中查看示例.样本中使用的波形数据为JSON.

There's no short answer here though. You can start exploring with flutter_ffmpeg to generate waveform data from audio. It's up to you on what format you'll use for your waveform data. Once you got your data, you can generate waveform graphs in Flutter using CustomPaint. You can check the sample on this blog post. The waveform data used in the sample is in JSON.

这篇关于Android Flutter分析音频波形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆