Test-Driving Changes

We can now test-drive our changes to writeData to incorporate the number of channels. The channel count represents the number of tracks (sound from separate sources) to play simultaneously. For monaural (mono) output, the channel count is one. For stereo, it is two. Playback of the WAV requires iterating through all the samples in order. A given sample is comprised of a series of subsamples, one per channel. Monaural representation for a four-sample audio clip, where a sample is a single byte, might look like this:

 
AA BB CC DD

Suppose there is a second channel with the following sample sequence:

 
01 02 03 04

The resulting WAV stream should appear like this:

 
AA 01 BB 02 CC 03 DD 04

Here’s a test showing how increasing the ...

Get Modern C++ Programming with Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.