What FLAC compression level does audiowrite use?

10 views (last 30 days)
FLAC audio compression has 9 levels (0-8). Higher levels lead to higher compression levels but take longer to encode. What level does the audiowrite function use? I cannot find this anywhere in the the audiowrite documentation.

Accepted Answer

Anushka
Anushka on 7 May 2025
MATLAB’s ‘audiowrite’ function supports writing FLAC files, but unfortunately, it does not provide any parameter to control the FLAC compression level (which ranges from 0 to 8). Additionally, the documentation does not specify what default level is used internally.
Here is a workaround you can use if you need to control the compression level:
1.Write a WAV file using ‘audiowrite’:
audiowrite(audio.temp_wav,y,Fs);
2. Then, convert it to FLAC using the FLAC command-line tool:
system(flac -f -8 audio_temp.wav);
% You can use -0 to -8 compression level
This approach gives you full control over the compression level. It relies on MATLAB’s system command and the external FLAC encoder, which must be installed separately. Make sure the ‘flac’ command is accessible from your system’s PATH.
Hope this helps!

More Answers (0)

Categories

Find more on Measurements and Spatial Audio in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!