If you are on a Unix OS like MacOS or Linux, this will be very easy. Just follow this tutorial.
If you are on Windows, it will be a bit harder:
Now open Bash. You should be able to run
$ g++ and
$ make. Test both commands and debug as needed.
To compile the code, just run
If you are on Windows and do not have
make installed, you can use this command:
$ g++ -o main main.cpp wave.cpp riff.cpp --std=c++11 -Wall -lws2_32
Some computers store numbers in reverse order than one would expect. Observe the diagrams:
There are pros and cons of using each encoding, however the biggest con is that no one can agree on a standard. Therefore, we must waste lots of energy converting between endians.
Fortunately, all operating systems provide the functions “host to network” and “network to host” (
ntoh()). Since all network traffic must use big endian, we now have a guaranteed function that will always give us a big endian output. Then we can just swap the endian to get little endian, the encoding for Wave files.