Save SDL2 audio to WAV

The same question was asked quite recently. You should find what you need there.