// // Programmer: Craig Stuart Sapp // Creation Date: Wed Apr 30 13:01:29 GMT-0800 1997 // Last Modified: Sun May 25 00:09:05 GMT-0800 1997 // Last Modified: Thu Aug 26 15:04:28 PDT 2004 (added Option class) // Filename: ...sig/doc/examples/sig/sigfile/silence/silence.cpp // Syntax: C++; sig // // Description: make a blank soundfile. // #include "sigAudio.h" #ifndef OLDCPP #include using namespace std; #else #include #endif void exitUsage(const char* command); int main(int argc, char* argv[]) { Options options; options.define("s|samples=i:44100", "number of samples to generate"); options.define("sec|seconds=d:1.0", "duration of sound if no -s option"); options.define("r|srate|sr=d:44100", "sampling rate of output sound"); options.define("c|channels|chan=i:1", "number of channels in output sound"); options.process(argc, argv); if (options.getArgCount() != 1) { exitUsage(options.getCommand()); } int srate = (int)options.getDouble("srate"); int numSamples = options.getInteger("samples"); if (!options.getBoolean("samples") && options.getBoolean("seconds")) { double seconds = options.getDouble("seconds"); numSamples = (int)(seconds * srate + 0.5); } if (numSamples < 1) { numSamples = 1000; } int channels = options.getInteger("channels"); if (channels < 1) { channels = 1; } SoundHeader header; header.setHighMono("This is a blank soundfile."); header.setChannels(channels); header.setSrate(srate); // Elements: Constant constant(0); SoundFileOut outsound(options.getArg(1), header); // Connections: int i; for (i=0; i