I am looking at creating a WAV file
in C and have seen an example here.
This looks good, but I\'m interested in adding two buffers to make the audio stereo
I think the problem is with the function "write_little_endian". You shouldn't need to use it on your laptop.
Endianness is architecture specific. The original example was likely for an Arduino microcontroller board. Arduino boards use Atmel microcontrollers which are big-endian. Thats why the code you cited explicitly needs to convert the 16-bit integers to little-endian format.
Your laptop on the other hand, uses x86 processors which are already little endian so no conversion is necessary. If you want robust portable code to convert endianness, you can use the function htole16
in Linux. Lookup the man pages to learn more about this function.
For a quick but non-portable fix, I would say just write out the entire 16bit value.
Also, I don't think you need to halve the amplitudes to go from mono to stereo.