diff --git a/Using _mm_stream_si128/main.c b/Using _mm_stream_si128/main.c index 5433c4e..0b42669 100644 --- a/Using _mm_stream_si128/main.c +++ b/Using _mm_stream_si128/main.c @@ -6,11 +6,11 @@ #include #include #include +#include #ifdef __MACH__ #include #include #endif -#include #ifndef NSEC_PER_SEC #define NSEC_PER_SEC 1000000000ull @@ -69,7 +69,7 @@ static inline void square_am_signal(float time, float frequency) { } } -int main() +int main(int argc, char* argv[]) { #ifdef __MACH__ mach_timebase_info_data_t theTimeBaseInfo; @@ -85,32 +85,24 @@ int main() reg_zero = _mm_set_epi32(0, 0, 0, 0); reg_one = _mm_set_epi32(-1, -1, -1, -1); + FILE* fp; + if (argc == 2) { + fp = fopen(argv[1], "r"); + } else { + printf("No song file given!\nUsage: %s file.song\n", argv[0]); + exit(1); + } + + char buffer[20] = {0}; + int time_ms; + int freq_hz; while (1) { - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2093); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.790, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2349); - square_am_signal(0.790, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 3136); - square_am_signal(0.790, 3136); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2093); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.790, 2093); + fgets(buffer, 20 - 1, fp); + if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) { + square_am_signal(1.0 * time_ms / 1000, freq_hz); + } + if (feof(fp)) { + rewind(fp); + } } } diff --git a/smb.song b/smb.song deleted file mode 100644 index bd85258..0000000 --- a/smb.song +++ /dev/null @@ -1,352 +0,0 @@ -:beep frequency=660 length=100ms; -:delay 150ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=510 length=100ms; -:delay 100ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=770 length=100ms; -:delay 550ms; -:beep frequency=380 length=100ms; -:delay 575ms; - -:beep frequency=510 length=100ms; -:delay 450ms; -:beep frequency=380 length=100ms; -:delay 400ms; -:beep frequency=320 length=100ms; -:delay 500ms; -:beep frequency=440 length=100ms; -:delay 300ms; -:beep frequency=480 length=80ms; -:delay 330ms; -:beep frequency=450 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 200ms; -:beep frequency=660 length=80ms; -:delay 200ms; -:beep frequency=760 length=50ms; -:delay 150ms; -:beep frequency=860 length=100ms; -:delay 300ms; -:beep frequency=700 length=80ms; -:delay 150ms; -:beep frequency=760 length=50ms; -:delay 350ms; -:beep frequency=660 length=80ms; -:delay 300ms; -:beep frequency=520 length=80ms; -:delay 150ms; -:beep frequency=580 length=80ms; -:delay 150ms; -:beep frequency=480 length=80ms; -:delay 500ms; - -:beep frequency=510 length=100ms; -:delay 450ms; -:beep frequency=380 length=100ms; -:delay 400ms; -:beep frequency=320 length=100ms; -:delay 500ms; -:beep frequency=440 length=100ms; -:delay 300ms; -:beep frequency=480 length=80ms; -:delay 330ms; -:beep frequency=450 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 200ms; -:beep frequency=660 length=80ms; -:delay 200ms; -:beep frequency=760 length=50ms; -:delay 150ms; -:beep frequency=860 length=100ms; -:delay 300ms; -:beep frequency=700 length=80ms; -:delay 150ms; -:beep frequency=760 length=50ms; -:delay 350ms; -:beep frequency=660 length=80ms; -:delay 300ms; -:beep frequency=520 length=80ms; -:delay 150ms; -:beep frequency=580 length=80ms; -:delay 150ms; -:beep frequency=480 length=80ms; -:delay 500ms; - -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=150ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 150ms; - -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=430 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 100ms; -:beep frequency=570 length=100ms; -:delay 220ms; - -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=200ms; -:delay 300ms; - -:beep frequency=1020 length=80ms; -:delay 300ms; -:beep frequency=1020 length=80ms; -:delay 150ms; -:beep frequency=1020 length=80ms; -:delay 300ms; - -:beep frequency=380 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=150ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 150ms; - -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=430 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 100ms; -:beep frequency=570 length=100ms; -:delay 420ms; - -:beep frequency=585 length=100ms; -:delay 450ms; - -:beep frequency=550 length=100ms; -:delay 420ms; - -:beep frequency=500 length=100ms; -:delay 360ms; - -:beep frequency=380 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=150ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 150ms; - -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=430 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 100ms; -:beep frequency=570 length=100ms; -:delay 220ms; - -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=200ms; -:delay 300ms; - -:beep frequency=1020 length=80ms; -:delay 300ms; -:beep frequency=1020 length=80ms; -:delay 150ms; -:beep frequency=1020 length=80ms; -:delay 300ms; - -:beep frequency=380 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=760 length=100ms; -:delay 100ms; -:beep frequency=720 length=100ms; -:delay 150ms; -:beep frequency=680 length=100ms; -:delay 150ms; -:beep frequency=620 length=150ms; -:delay 300ms; - -:beep frequency=650 length=150ms; -:delay 300ms; -:beep frequency=380 length=100ms; -:delay 150ms; -:beep frequency=430 length=100ms; -:delay 150ms; - -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=430 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 100ms; -:beep frequency=570 length=100ms; -:delay 420ms; - -:beep frequency=585 length=100ms; -:delay 450ms; - -:beep frequency=550 length=100ms; -:delay 420ms; - -:beep frequency=500 length=100ms; -:delay 360ms; - -:beep frequency=380 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 300ms; -:beep frequency=500 length=100ms; -:delay 150ms; -:beep frequency=500 length=100ms; -:delay 300ms; - -:beep frequency=500 length=60ms; -:delay 150ms; -:beep frequency=500 length=80ms; -:delay 300ms; -:beep frequency=500 length=60ms; -:delay 350ms; -:beep frequency=500 length=80ms; -:delay 150ms; -:beep frequency=580 length=80ms; -:delay 350ms; -:beep frequency=660 length=80ms; -:delay 150ms; -:beep frequency=500 length=80ms; -:delay 300ms; -:beep frequency=430 length=80ms; -:delay 150ms; -:beep frequency=380 length=80ms; -:delay 600ms; - -:beep frequency=500 length=60ms; -:delay 150ms; -:beep frequency=500 length=80ms; -:delay 300ms; -:beep frequency=500 length=60ms; -:delay 350ms; -:beep frequency=500 length=80ms; -:delay 150ms; -:beep frequency=580 length=80ms; -:delay 150ms; -:beep frequency=660 length=80ms; -:delay 550ms; - -:beep frequency=870 length=80ms; -:delay 325ms; -:beep frequency=760 length=80ms; -:delay 600ms; - -:beep frequency=500 length=60ms; -:delay 150ms; -:beep frequency=500 length=80ms; -:delay 300ms; -:beep frequency=500 length=60ms; -:delay 350ms; -:beep frequency=500 length=80ms; -:delay 150ms; -:beep frequency=580 length=80ms; -:delay 350ms; -:beep frequency=660 length=80ms; -:delay 150ms; -:beep frequency=500 length=80ms; -:delay 300ms; -:beep frequency=430 length=80ms; -:delay 150ms; -:beep frequency=380 length=80ms; -:delay 600ms; - -:beep frequency=660 length=100ms; -:delay 150ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=510 length=100ms; -:delay 100ms; -:beep frequency=660 length=100ms; -:delay 300ms; -:beep frequency=770 length=100ms; -:delay 550ms; -:beep frequency=380 length=100ms; -:delay 575ms; -:end \ No newline at end of file