waveform_fft
一個用於使用 FFT(快速傅立葉變換)進行即時音訊視覺化以及使用麥克風資料進行音訊擷取的 Flutter 套件
一個用於使用 FFT(快速傅立葉變換)進行即時音訊視覺化以及使用麥克風資料進行音訊擷取的 Flutter 套件
^1.5.0+1^0.70.2{"sdk":"flutter"}^1.1.8{"sdk":"flutter"}^5.0.0以下為英文專案原文快照,最新內容請造訪 GitHub。
A Flutter package for real-time audio visualization using FFT (Fast Fourier Transform). This package captures audio input and displays it as an animated waveform using fl_chart.
Add this to your package's pubspec.yaml file:
dependencies:
waveform_fft: ^0.0.1
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Add the following keys to your ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to microphone to visualize audio.</string>
The WaveFormWidgetEq widget accepts several parameters for customization:
WaveFormWidgetEq(
data: data, // Frequency data
animationDuration: Duration(milliseconds: 200), // Animation speed
updateInterval: Duration(milliseconds: 48), // Update frequency
barWidth: 5.0, // Width of each bar
maxY: 80.0, // Maximum Y value
minY: -80.0, // Minimum Y value
barColor: Colors.white, // Color of bars
barAlpha: 0.5, // Opacity of bars
);
The AudioCaptureService can be customized with different sample rates and buffer sizes:
final service = AudioCaptureService(
sampleRate: 44100, // Default: 44100 Hz
bufferSize: 256, // Default: 256 samples
);
Note: The
AudioCaptureServiceis a singleton and should be initialized once in your application.
Here's a demo of the audio visualization in action:
The example above demonstrates:
Check out the complete example code in the /example directory to see how to implement this in your app.
The package includes predefined frequency spectrum ranges from 0Hz to 22kHz, following standard audio frequency bands. You can customize these ranges by modifying the AudioWaveFormConstants.defaultFrequencySpectrum.
record or flutter_sound etc for audio recording purpose.Contributions are welcome! Please feel free to submit a Pull Request.