Adjust the RIFF header file size in the stream writer using the size of the extra chunks, instead of rewriting it later from the file size.
Move more into the stream writer class and adjust methods to be more compact.