Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: WavFileWriter

  1. #1
    Junior Member
    Join Date
    Jun 2018


    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Wow, this looks awesome. Can't look at 'til next week... wrapping up 1.42 now.

  3. #3
    Junior Member
    Join Date
    Jun 2018
    Thank you so much
    There is a couple of things I would like to tweak.
    - Using the proper size typedefs (ie int16_t, int32_t etc.) so that the integer width is guaranteed
    - Adding multi channel support
    - The files are displayed as containing 32-bit float, eventhough I write 16-bit integers into them...
    And again it would be fantastic if someone could double check if the size is written properly, as I was unable to construct a proper test case on the teensy.
    Maybe I can get those things ticked of until next week...
    Good luck with the 1.42 and thanks for all your amazing work!
    Last edited by Foaly; 06-05-2018 at 12:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts