// // Programmer: Craig Stuart Sapp // Creation Date: Wed Jan 23 21:10:32 PST 2002 // Last Modified: Sun Feb 3 11:08:04 PST 2002 (updated for soundfile 2.0) // Filename: ...soundfile/examples/multi2mono.cpp // Syntax: C++ // // Description: Adds all channels in the input sound file and writes // a sound file with the summation of all channels. // Amplitude scaling factor can be given to prevent // clipping if necessary. // #include "soundfile.h" #include #ifndef OLDCPP #include using namespace std; #else #include #endif int main(int argc, char** argv) { Options options; options.define("a|amp=d:1.0", "amplitude scaling factor"); options.process(argc, argv); double amp = options.getDouble("amp"); const char* inputname = options.getArg(1); const char* outputname = options.getArg(2); SoundFileRead insound(inputname); SoundHeader header = insound; header.setChannels(1); SoundFileWrite outsound(outputname, header); int i, channel; double newsample; for (i=0; i