Home Artists Posts Import Register

Content

When a Blockhead project is saved it currently encodes all the samples as 24-bit FLAC files to save space. This means 32-bit samples are converted to 24-bit when the project is saved which is not ideal. The FLAC format does technically support 32-bit float but most FLAC encoders don't.

Thankfully there is a nice alternative - a lesser known lossless compression format called WavPack. The compression ratio seems to be similar to that of FLAC but the official codec also supports 32-bit float.

WavPack files are not as widely supported as FLAC but since we now have the ability to export samples from the Blockhead UI, the old trick of extracting samples from the blkhd file is not as relevant. So I can use WavPack internally for the project files and you shouldn't ever have to deal with them. You'll still be able to extract the WavPack files if you want but you might have to convert them to something more usable.

I have been using a library named libsndfile to handle all file reading and writing. It's a good library which supports a lot of different formats but I've been wanting to get rid of it and use something else because the license is LGPL. I could probably write a whole blog post about why I dislike LGPL but nobody wants to read that.

libsndfile also doesn't support MP3 files which is a shame because that's a useful format for a DAW to be able to decode, and it doesn't support WavPack.

As part of the internal move from FLAC to WavPack I am taking the opportunity to get rid of libsndfile and replace it with a mix of other libraries, mainly the dr_libs libraries which Marek recently pointed me towards: https://github.com/mackron/dr_libs

I actually came across these libraries earlier but skipped over them in favour of libsndfile because at the time I needed a way to encode FLAC files as well as decode.

Ditching libsndfile means I will have to remove the ability to export to FLAC and will lose support for OGG Vorbis and AIFF samples for the time being. This change will probably be complete in the next build so the situation will be:

Formats that Blockhead will be able to open:

  • FLAC
  • MP3 (new)
  • WAV
  • WavPack (new)

Formats that Blockhead will no longer be able to open:

Formats that Blockhead will be able to export:

  • WAV
  • WavPack (new)

Formats that Blockhead will no longer be able to export:

  • FLAC

WavPack is probably a weird format to add to the export options but I figure I might as well add it since I'll be writing the code to encode WavPack data anyway.

So far I have written the audio file reader which I have added to my audio library here: https://github.com/colugomusic/snd/blob/master/include/snd/storage/audio_file_reader.h

Still left to do is a file writer which will be used for exporting WAV or WavPack, and finally to modify the project saver/loader to use WavPack instead of FLAC.

Comments

No comments found for this post.