#include <windows.h>
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	if (argc==3) {
		int volume = atoi(argv[1]);
		if (volume <= 100 && volume >= 0 ) {
			int vol = (volume + (volume<<16)) * (0xFFFF/100);
			while(1) {
				waveOutSetVolume((HWAVEOUT) WAVE_MAPPER, vol);
				Sleep(atoi(argv[2]));
				waveOutSetVolume((HWAVEOUT) WAVE_MAPPER, 0);
				Sleep(atoi(argv[2]));
			}
		}
	} else {
		if (argc==2) {
			int volume = atoi(argv[1]);
			if (volume <= 100 && volume >= 0 ) {
				int vol = (volume + (volume<<16)) * (0xFFFF/100);
				waveOutSetVolume((HWAVEOUT) WAVE_MAPPER, vol);
			}
		} else {
			cout << "Uzycie:" << endl;
			cout << "volume glosnosc [przerwa]" << endl;
			cout << "glosnosc to wartosc od 0 to 100. Opcjonalny parametr przerwa podaje sie w milisekundach." << endl;
		}
	}
	return 0;
}

