Hello everybody!
I am working on a little project and needed a way to store audio on a SD card. All I could find was code that either writes raw samples or some god awful spaghetti code attempting to write WAV files (sorry...). So I decided to write a simple class that nicely abstracts all the nitty-gritty details away. I took inspiration from the Recorder example of Paul Stoffregens Audio library and the SFML SoundFileWriterWav class.
So here it is: WavFileWriter on GitHub. I welcome you all to check it out, test it and use it! Feedback is more than welcome!
For my purposes it is important to record at different sample rates. So I used Frank Boesings sample rate adaption code (see Util.hpp). This works nicely when recording audio from the mic inputs. Using a sine wave from AudioSynthWaveform with different sample rates results in a up or down pitched tone, but this seems to a problem of AudioSynthWaveform.
I did a lot of testing, but it turned out to be non-trivial to generate a signal of a precisly timed length to check if the size is written 100% correctly. According to my test the numbers are correct. But a code review/second pair of eyes is more than welcome
Also stereo recodring does not work (yet)...
As I said I am very open for comments, critique or suggestions for improvment
I am working on a little project and needed a way to store audio on a SD card. All I could find was code that either writes raw samples or some god awful spaghetti code attempting to write WAV files (sorry...). So I decided to write a simple class that nicely abstracts all the nitty-gritty details away. I took inspiration from the Recorder example of Paul Stoffregens Audio library and the SFML SoundFileWriterWav class.
So here it is: WavFileWriter on GitHub. I welcome you all to check it out, test it and use it! Feedback is more than welcome!
For my purposes it is important to record at different sample rates. So I used Frank Boesings sample rate adaption code (see Util.hpp). This works nicely when recording audio from the mic inputs. Using a sine wave from AudioSynthWaveform with different sample rates results in a up or down pitched tone, but this seems to a problem of AudioSynthWaveform.
I did a lot of testing, but it turned out to be non-trivial to generate a signal of a precisly timed length to check if the size is written 100% correctly. According to my test the numbers are correct. But a code review/second pair of eyes is more than welcome
Also stereo recodring does not work (yet)...
As I said I am very open for comments, critique or suggestions for improvment