Closed ekuleshov closed 4 months ago
v0.0.4 of coast_audio_miniaudio
includes MabAudioConverterNode
+MabAudioConverter
, which take input and output formats as arguments and perform the conversion.
v0.0.4 of
coast_audio_miniaudio
includesMabAudioConverterNode
+MabAudioConverter
, which take input and output formats as arguments and perform the conversion.
I know thatMabAudioConverter
does work. However, for my needs to simply decode and process wav files, it is excessive and also brings in additional native code.
But if you use the WavAudioDecoder
as the audio data source, it produces data that is not compatible with the FftNode and few other processing nodes.
@SKKbySSK still wasn't been able to resolve this. Do you have any idea if the output of WavAudioDecoder
could be transformed to work with the FftNode
and other components that expect the float values as an input?
Thank you in advance.
@ekuleshov
WavAudioDecoder
produces original samples of the wave data. It is usually int16 format.
You can verify the format by printing WavAudioDecoder.outputFormat.sampleFormat
.
To convert int16 samples to float32 samples. apply this calculation to each sample
final convertedSample = sample / SampleFormat.int16.max
By the way, int16 consists of 16 bits(2 bytes) and float32 consists of 32 bits(4 bytes). So you need to calculate audio buffer size carefully.
As @aveia stated above, MabAudioConverter
should be simpler and the performance should be better.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
I'm truing to add an
FftNode
to theaudio_graph_demo.dart
demo app.So, created the
FftNode
like below and then linked it in thegraphNode
betweenmixerNode
andmasterVolumeNode
.With that it is giving me all
NaN
values for FFT magnitudes.If I change the
sampleFormat: SampleFormat.float32
to be used to allFunctionNode
s - then FFT works, but it fail with an "unsupported sample format" error in theWavAudioEncoder
.The
WavAudioDecoder
also usually produces theSampleFormat.int16
output and I can't figure out how to convert that data into theSampleFormat.float32
thatFftNode
can work with.Could you please advise how to make the such conversion and to integrate
FftNode
with int16 audio buffers andWavAudioDecoder
. Thank you in advance.PS: the
MabAudioDecoder
producesSampleFormat.float32
and it seem to work with theFftNode
out of the box, but it seems an overkill for a simple audio processing.