#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/kd.h>
#define NOTESCONUT 605
int k[NOTESCONUT][2] = {{0, 1374}, {277, 229}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 229}, {440, 229}, {330, 229}, {370, 229}, {277, 458}, {277, 229}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 229}, {554, 229}, {440, 229}, {494, 229}, {370, 458}, {277, 229}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 573}, {0, 115}, {330, 229}, {370, 229}, {440, 229}, {330, 229}, {370, 229}, {277, 229}, {330, 229}, {220, 229}, {247, 229}, {277, 458}, {440, 458}, {370, 458}, {554, 458}, {494, 229}, {554, 115}, {494, 115}, {440, 229}, {494, 229}, {370, 229}, {0, 115}, {554, 115}, {2794, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {659, 458}, {740, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {1175, 458}, {1109, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {659, 458}, {740, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {1480, 229}, {0, 458}, {740, 229}, {0, 229}, {740, 229}, {740, 229}, {0, 916}, {370, 229}, {370, 229}, {330, 115}, {330, 344}, {370, 229}, {330, 229}, {277, 229}, {277, 229}, {330, 115}, {277, 344}, {0, 1374}, {370, 229}, {370, 229}, {330, 229}, {370, 229}, {415, 229}, {440, 458}, {415, 458}, {370, 229}, {415, 115}, {370, 115}, {330, 458}, {0, 687}, {370, 229}, {370, 229}, {330, 115}, {330, 344}, {370, 229}, {330, 229}, {277, 229}, {277, 229}, {330, 115}, {277, 344}, {0, 458}, {330, 229}, {330, 229}, {370, 458}, {330, 229}, {330, 229}, {370, 458}, {370, 115}, {415, 115}, {440, 458}, {494, 458}, {370, 229}, {554, 229}, {554, 229}, {659, 229}, {740, 229}, {740, 458}, {1109, 229}, {988, 573}, {0, 115}, {740, 229}, {0, 229}, {740, 229}, {740, 229}, {1109, 229}, {988, 115}, {880, 115}, {1109, 115}, {1319, 115}, {1480, 687}, {988, 229}, {988, 229}, {932, 229}, {988, 229}, {880, 115}, {740, 344}, {659, 229}, {0, 229}, {659, 229}, {659, 229}, {740, 229}, {740, 229}, {554, 229}, {554, 229}, {659, 229}, {740, 229}, {740, 458}, {1109, 229}, {988, 573}, {0, 115}, {740, 229}, {0, 229}, {740, 229}, {740, 229}, {1109, 229}, {988, 115}, {554, 115}, {880, 115}, {740, 115}, {1480, 687}, {988, 229}, {988, 229}, {932, 229}, {988, 229}, {880, 115}, {740, 115}, {0, 229}, {659, 115}, {659, 344}, {740, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 229}, {740, 229}, {659, 115}, {659, 115}, {740, 229}, {740, 229}, {740, 229}, {1109, 229}, {1109, 229}, {0, 458}, {880, 115}, {880, 115}, {988, 229}, {880, 115}, {988, 344}, {1109, 229}, {740, 229}, {0, 458}, {659, 115}, {659, 115}, {740, 458}, {1109, 458}, {988, 229}, {880, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 115}, {740, 229}, {0, 115}, {880, 115}, {659, 458}, {0, 458}, {0, 115}, {740, 229}, {740, 115}, {740, 115}, {0, 229}, {659, 115}, {659, 115}, {740, 229}, {1109, 458}, {880, 229}, {988, 229}, {880, 115}, {988, 344}, {1109, 229}, {1109, 573}, {0, 115}, {659, 115}, {659, 115}, {740, 229}, {880, 458}, {659, 115}, {659, 115}, {740, 229}, {1109, 458}, {1109, 115}, {988, 115}, {880, 229}, {831, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 916}, {1480, 229}, {1319, 229}, {1109, 229}, {988, 229}, {1109, 229}, {880, 229}, {659, 229}, {370, 115}, {440, 115}, {494, 115}, {554, 115}, {659, 115}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {988, 115}, {880, 115}, {740, 115}, {659, 115}, {554, 115}, {494, 115}, {440, 115}, {659, 573}, {0, 115}, {659, 115}, {659, 115}, {659, 229}, {554, 229}, {494, 229}, {440, 229}, {370, 229}, {440, 229}, {1480, 229}, {1319, 229}, {1109, 229}, {988, 229}, {880, 229}, {740, 229}, {880, 115}, {554, 115}, {740, 115}, {554, 115}, {880, 115}, {554, 115}, {740, 115}, {554, 115}, {988, 229}, {0, 115}, {880, 229}, {0, 115}, {740, 115}, {0, 115}, {740, 229}, {740, 229}, {740, 229}, {740, 229}, {740, 229}, {880, 229}, {880, 229}, {880, 229}, {554, 458}, {988, 229}, {1109, 229}, {740, 573}, {0, 115}, {1109, 229}, {988, 229}, {880, 229}, {740, 229}, {659, 229}, {740, 115}, {659, 115}, {880, 115}, {659, 115}, {988, 115}, {659, 115}, {1109, 115}, {659, 115}, {1319, 115}, {1397, 115}, {1109, 115}, {1397, 115}, {1319, 115}, {1397, 115}, {1480, 115}, {1397, 115}, {1480, 229}, {554, 229}, {554, 229}, {659, 229}, {740, 229}, {740, 458}, {1109, 229}, {988, 573}, {0, 115}, {740, 229}, {0, 229}, {740, 229}, {740, 229}, {1109, 229}, {988, 115}, {880, 115}, {1109, 115}, {1319, 115}, {1480, 458}, {740, 115}, {880, 115}, {988, 115}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {880, 115}, {988, 115}, {1109, 115}, {1319, 115}, {1109, 115}, {1319, 115}, {1480, 115}, {1760, 115}, {1976, 115}, {2960, 115}, {2637, 115}, {2217, 115}, {1976, 115}, {2637, 115}, {2217, 115}, {1976, 115}, {1760, 115}, {1760, 115}, {1661, 115}, {1480, 115}, {1319, 115}, {1480, 115}, {0, 344}, {740, 229}, {740, 458}, {1109, 229}, {988, 573}, {0, 115}, {740, 229}, {0, 229}, {740, 229}, {740, 229}, {1109, 229}, {988, 115}, {554, 115}, {880, 115}, {740, 115}, {1480, 687}, {988, 229}, {988, 229}, {932, 229}, {988, 229}, {880, 115}, {740, 115}, {0, 229}, {659, 229}, {0, 229}, {740, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 229}, {740, 229}, {659, 115}, {659, 115}, {740, 229}, {740, 229}, {740, 229}, {1109, 229}, {1109, 229}, {0, 458}, {880, 115}, {880, 115}, {988, 229}, {880, 115}, {988, 344}, {1109, 229}, {740, 229}, {0, 458}, {659, 115}, {659, 115}, {740, 458}, {1109, 458}, {988, 229}, {880, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 115}, {740, 229}, {0, 115}, {880, 115}, {659, 458}, {0, 458}, {0, 115}, {740, 229}, {740, 115}, {740, 115}, {0, 229}, {659, 115}, {659, 115}, {740, 229}, {1109, 458}, {880, 229}, {988, 229}, {880, 115}, {988, 344}, {1109, 229}, {1109, 573}, {0, 115}, {659, 115}, {659, 115}, {740, 229}, {880, 458}, {659, 115}, {659, 115}, {740, 229}, {1109, 458}, {1109, 115}, {988, 115}, {880, 229}, {831, 229}, {740, 229}, {659, 229}, {740, 229}, {0, 458}, {659, 229}, {740, 229}, {880, 458}, {659, 229}, {740, 229}, {1319, 458}, {1109, 115}, {988, 115}, {554, 229}, {554, 229}, {659, 229}, {659, 229}, {1480, 458}, {0, 458}, {370, 229}, {0, 229}, {370, 229}, {0, 229}, {370, 229}, {0, 229}, {370, 115}, {440, 115}, {494, 115}, {554, 115}, {370, 229}, {0, 229}, {370, 229}, {0, 229}, {370, 229}, {330, 458}, {370, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {1175, 458}, {1109, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {659, 458}, {740, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 229}, {0, 229}, {740, 115}, {880, 115}, {988, 115}, {1109, 115}, {1480, 687}, {740, 229}, {0, 229}, {740, 229}, {740, 229}};
int main(void)
{
int console_fd;
int i;
if ((console_fd = open("/dev/console", O_WRONLY)) == -1)
{
fprintf(stderr, "Failed to open console. \n");
perror("open");
exit(1);
}
for (i = 0; i <= NOTESCONUT; i++)
{
printf("%d ", k[i][0]);
int magical_fairy_number = k[i][0] == 0 ? 0 : 1193180 / k[i][0];
ioctl(console_fd, KIOCSOUND, magical_fairy_number);
usleep(k[i][1] * 1000);
ioctl(console_fd, KIOCSOUND, 0);
usleep(10000);
}
return EXIT_SUCCESS;
}