Example #1
0
static void ShowErrors(WaveFile& from, WaveFile& to)
{
	bool any = from.GetError() || to.GetError();

	if (from.GetError())
		cout << "Error on input: " << from.GetError() << "." << endl;

	if (to.GetError())
		cout << "Error on output: " << to.GetError() << "." << endl;

	if (!any)
		cout << "Success." << endl;
}
Example #2
0
int main(int , char **)
{
	WaveFile wf;

	wf.SetupFormat();

	if (!wf.OpenWrite("A440.wav")) {
		cout << "Can't open for writing: " << wf.GetError();
		return 1;
	}

	const dataLength = 1 /*sec*/ * wf.GetSampleRate();  // in samples

	float alpha = 0;
	for (int i = 0; i < dataLength; i++) {
		wf.WriteSample(sin(alpha) / 2);

		alpha += 2 * M_PI * frequency / wf.GetSampleRate();
	}

	return 0;
}