Skip to end of metadata
Go to start of metadata

WAV Files

Python has built-in functionality for reading and writing WAV files. It is called the wave moudle. A link to the documentation can be found at

WAV files contain other information besides raw data. The files include number of audio channels, sample width, framerate, and other important information. The structure of a WAV file is important because we want to edit the correct information.

A detailed link about the structure of WAV files can be found at

The python WAV module allows us to easily change all header information (check the link above). Therefore in our attempt at editing the audio we will mostly be concerned with the raw sound data. This data starts at the 44th byte of the file and continues for the rest of the file. Data in these files are stored as byes. We need to way to modify this information so we convert each byte to an integer. This is accomplished with the built-in ord() function. Once our data is modified to our liking, we convert back to bytes using the built-in chr() function.

Remember that the header information of the file will mostly stay the same, however, but if you do something like modifying the length of the song then the number of channels must be modified.

  • No labels