Ever thought of listening to 2 songs at the same time?? Well now you can.
Wav file can have multiple channels. If a wav file has 2 channels, & you are using headphones to listen to the audio, both the channels are played independently on the left & right side of the headphones.
mix.cpp takes 2 wav files as input and produces a third wav file as output. This output wav file has 2 channels. The first channel is composed of the the first input wav file & the 2nd channel is composed of the 2nd input wav file.
So when you listen to the output wav files, you can listen to 2 different songs (audio files) at the same time. One playing on the left side of the headphone & the other on the right side of the headphone.
Demo | |
---|---|
Input File 1 | demo / song1.wav |
Input File 1 Wave diagram |
|
Input File 2 | demo / song2.wav |
Input File 2 Wave diagram |
|
Output File | demo / song1 + song2.wav |
Output File Wave diagram |
stereo_to_mono.cpp is a C++ code which can convert a stereo Wav file to a mono Wav file.
Difference between mono & stereo - stackexchange.com
Data is stored in channels in a wav file. If a wav file has 2 channels, both the channels may have different content & it may sound different while using headphone as difference can be spotted through the left & right side of the headphone. On a single speaker device, both the channels are combined and played.
Virtual Barber Shop Haircut - soundcloud.com best example of how having 2 different channels can be beneficial and produce some great content.
But some people prefer mono over stereo. Stereo can be converted to mono by mixing both the channels of the stereo and forming a single mono channel. The data read from wav file has to be converted into Fractional Binary Fixed-Point Numbers[3] before mixing it into a single channel.
Demo | |
---|---|
Input Stereo file | demo / stereo_file.wav |
Wave of input stereo file |
|
Output Mono file | demo / mono_file.wav |
Wave of ouput mono file |
1. Microsoft WAVE soundfile format - soundfile.sapp.org
2. Wav (RIFF) File Format Tutorial - topherlee.com
3. Number Systems for Digital Audio - dsprelated.com