Comments (3)
Hi,
you can only get FFT and wave data while the audio is playing. See getFft(), getWave(), getAudioTexture() in the doc.
They return a convenient Pointer<Float>
for performance instead of copying it ie in a Float32List every time.
Getting a whole audio frequency domain at once is not yet planned
from flutter_soloud.
Hi, you can only get FFT and wave data while the audio is playing. See getFft(), getWave(), getAudioTexture() in the doc. They return a convenient
Pointer<Float>
for performance instead of copying it ie in a Float32List every time.Getting a whole audio frequency domain at once is not yet planned
Thanks for your answer.
-
But I didn't understand how can I get value of frequencies to Hz from FFT data. Do you mean
ffi.Pointer<ffi.Float> audioData
represents amplitude of each sine wave or frequency of sine wave? I want to have both of them (a Map with key=frequency and value=amplitude of that sine waves that create our signal). How can I find it?
could you give me source code of this example where x-axis shows frequencies and y-axis shows amplitude of them to decibel? -
In fact, I have a reference wav file and want to compare other wav files with it to check if they are similar or not.
can you suggest me a solution please?
from flutter_soloud.
I notice now that I didn't exposed getAudioTexture(), it's not available on Flutter side. So you will need to use getAudioTexture2D().
Using getAudioTexture2D() you will get back a matrix with 256 rows of 512 floats. You could consider only the 1st row as it represents the latest data. So this first row is composed by:
- The first 256 floats represent the FFT frequencies data in the 0.0~1.0 range.
- The other 256 floats represent the wave data in -1.0~1.0 range (amplitude).
So, the first 256 floats in this array, I think are the values you are looking for:
final ffi.Pointer<ffi.Float> audioData = SoLoud().getAudioTexture2D(playerData);
You can access these floats with double n = audioData[i]
. The i
index is the frequency in Hz and its value is the amplitude (volume) of that frequency.
Since the engine is set to 44100 samples/s and the amount of data given to compute FFT is 1024, below a function to know which frequency is represented in the array index i
.
double Index2Freq(int i, double samples, int nFFT) {
return (samples / nFFT / 2.0) * i;
}
and you can use it with something like this:
void getFreqs() {
for (final int i=0; i<256; i++) print('index: $i is ${Index2Freq(i, 44100, 1024)} Hz');
}
Here you can see the widget used in the Visualizer
example to show the FFT data, but the correct image is this. The one you linked is made using Audacity app and it's a bit different with the one generated by this plugin and I don't know yet why 😄
I didn't tested and I don't know much about audio processing, but hope this helps!
- I think this could be more complicated than it might seems. To compare audio you should use fingerprints, basically you should generate these fingerprint of samples and then compare each other. There are some libraries around by I never tried.
I move this issue to Discussion, it maybe be useful to others!
from flutter_soloud.
Related Issues (20)
- feat: Add custom source data for capturing HOT 3
- fix: Crash when opening a malformed mp3 file HOT 2
- feat: Make it possible to "instance" SoLoud? HOT 3
- feat: Find a better mechanism than the `audioEvent` stream for listening to changes in the engine HOT 3
- feat: Fail-fast more often HOT 2
- feat: WASM support HOT 27
- chore: Address C++ compilation warnings HOT 2
- proposal: Another set of renames HOT 4
- feat: Implement setProtectVoice() HOT 1
- docs: What does disposeSound actually do? HOT 2
- fix: Wrong error reported when trying to add a filter twice
- bug: crash on deinit() HOT 1
- fix: App asks for microphone permission even though it's not using it HOT 4
- feat: Simplified Recording Mechanism HOT 12
- feat: WaveForm for complete Audiofile HOT 1
- perf: Ability to play precise sound sequences HOT 3
- fix: Missing audio on playing a loaded url HOT 1
- fix: Init error on hot restart HOT 3
- fix: handles become invalid at unknown points HOT 9
- MA_NODE_FLAG_SILENT_OUTPUT duplicates API recursive triggers (bangs) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_soloud.