flac
flac copied to clipboard
flac in espressif idf?
Please be a little more descriptive. I have no clue what you want.
Please be a little more descriptive. I have no clue what you want.
Hello, and thank you for responding.
I am developing an audio recorder for bird identification through their sounds, and I am using the Espressif ESP32-S3 with the C language through IDF.
I need to convert the audio I capture in .wav format to FLAC to reduce the file size and be able to record for more hours with the same SD card capacity.
I thought you could help me achieve this.
Thank you.
https://www.espressif.com/en/products/sdks/esp-idf
How far have you gotten yet? I might be able to help with some FLAC specifics, but I cannot do the work for you. I don't have an ESP32, and I only know of it because of this project: https://github.com/earlephilhower/ESP8266Audio
At the moment, I have the file in WAV format and I wanted to convert it to FLAC/OGG/OPUS due to space constraints on the SD card.
I am looking at https://docs.espressif.com/projects/esp-adf/en/latest/index.html, which seems to have an encoder for Opus but not for FLAC. Although it would be acceptable for me. I found it after making the inquiry.
The issue is that I am unable to make it work, and I wanted something simple that allows me to convert to FLAC without complications. Since the project I mentioned is very large and involves many things that ultimately are not necessary for me.
I capture the audio from a MEMS-type I2S microphone in PDM and pass it to a buffer. From that buffer, it goes to the SD card as a .WAV file. I simply wanted to insert the conversion to FLAC between the capture and the recording.
I apologize if I am not explaining myself well.
I meant, have you started porting/rewriting anything yet? What do you expect me to do? I cannot hand you a completely functional ESP32 port of the whole FLAC project of course, I don't have that hardware.
I meant, have you started porting/rewriting anything yet? What do you expect me to do? I cannot hand you a completely functional ESP32 port of the whole FLAC project of course, I don't have that hardware.
Claro, it's logical. I think with some understanding of the compression process or something like that, it would be sufficient for me.
Keep in mind that in a low-resource system, large systems are not required either. It would be more than enough if it is capable of compressing in FLAC/Ogg in 16 bits and 44100Hz without tags or anything similar.
I found this: https://github.com/astoeckel/libfoxenflac/tree/master, but I don't know how to start since I'm unfamiliar with the compression process.
I have two buffers where I store the audio captured by the I2S port in WAV format, and the idea would be to pass that buffer through the encoder.
Thanks for your time, you're very kind.
libfoxenflac is decompression only, so that isn't really useful. If you want to know more about the way FLAC compresses data, you can look here: https://datatracker.ietf.org/doc/draft-ietf-cellar-flac/
If you want to build a very simple FLAC encoder from scratch, the process would be as follows
- Take a chunk of sound data (lets say, 1000 samples)
- Calculate the 1st order predictor, which is essentially a difference signal
- Find a suitable rice parameter
- Check whether the result is smaller than the input
- If the result is smaller than the input, write the data compressed
- If the result is larger than the input, write the data uncompressed
Such a simple encoder would ignore the following potential improvements
- Other order fixed predictors
- Stereo decorrelation
- Non-fixed (LPC) predictors
- Partitioned entropy
- Variable blocksize
For your use case (bird song recording) I estimate that such a simple encoder would compress files to 60% of their original filesize whereas a more complex encoder would get it to 50% or 40%.
Have you gotten anywhere with this yet? Do you need any help?