[LAD] (libsndfile) FLAC format question

hermann meyer brummer- at web.de
Tue Nov 5 19:04:13 UTC 2013


Hi

I would save a internal audio buffer to file on exit, to reuse it after 
e new start.
Currently I use stdio fopen/fwrite/fread and save the binary data from 
the array.
That works well.

Now I've started to play with libsndfile, first I use  SF_FORMAT_WAV | 
SF_FORMAT_FLOAT which work as nice as stdio. The file size is the same 
then with plain binary data.

To save some bytes on the disk I tried SF_FORMAT_FLAC | SF_FORMAT_PCM_24 
which reduce the size nearly to the half. The drawback is that the 
floats in the internal buffer could go out of the range from -1.0 <-> 
1.0 which leads to crackles when the buffer get refiled.   As long the 
values are in range, flac works very well.

I tried it with the sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE)
for write and read, but that didn't help.
Yes, I use sf_write_float to write/read the flac file, even if flac 
didn't support floats. When I understand the libsndfile api right, 
libsndfile will handle that.

So my quetion will be, which is the common format to write flac file 
with libsndfile, and is there a way to write values out of range into a 
flac file?

regards
hermann


More information about the Linux-audio-dev mailing list