diff --git a/docs/index.html b/docs/index.html index 8a6c739..4ab585c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -20,42 +20,42 @@

System Bus Radio

+2673 400 +2349 400 +2093 400 +2349 400 +2673 400 +0 400 +2673 400 +0 400 +2673 790 +2349 400 +2349 400 +0 400 +2349 790 +2673 400 +3136 400 +0 400 +3136 790 +2673 400 +2349 400 +2093 400 +2349 400 +2673 400 +0 400 +2673 400 +0 400 +2673 400 +0 400 +2673 400 +2349 400 +0 400 +2349 400 +2673 400 +2349 400 +2093 790
-

Edit the above to make any music you like. Tune file format is time (ms) and frequency (Hz).

+

Edit the above to make any music you like. Tune file format is frequency (Hz) and time (ms).

Chrome has errors if you open this file locally (file://). Try using php -S localhost:8000 or similar for a quick web server.

Ported by Yeo Quan Yang & maintained by Elliot Gerchak.

Original machine code by William Entriken.

diff --git a/docs/worker.js b/docs/worker.js index 89ad9ab..db84d02 100644 --- a/docs/worker.js +++ b/docs/worker.js @@ -11,7 +11,7 @@ function now() { var NSEC_PER_SEC = 1000000000; var register = 3.1415; -function square_am_signal(time, freq) { // This funcion generates the radio waves +function square_am_signal(freq, time) { // This function generates the radio waves postMessage("\nPlaying / " + time + " seconds / " + freq + "Hz"); var period = NSEC_PER_SEC / freq; var start = now(); @@ -32,16 +32,16 @@ function square_am_signal(time, freq) { // This funcion generates the radio wave function play(song) { // Parse song data, and call on required scripts to run it song = song.split("\n"); var length = song.length; - var line, time, freq; + var line, freq, time; for (var i = 0; i < length; i++) { line = song[i].split(" "); if (+line[1] == 0) { pause(line[0]); } else { - freq = +line[1]; - time = (+line[0])*.001; - square_am_signal(time, freq); + time = (+line[1])*.001; + freq = +line[0]; + square_am_signal(freq, time); } } diff --git a/implementations/c-_mm_stream_si128/main.c b/implementations/c-_mm_stream_si128/main.c index 0b42669..0931d9b 100644 --- a/implementations/c-_mm_stream_si128/main.c +++ b/implementations/c-_mm_stream_si128/main.c @@ -50,7 +50,7 @@ __m128i reg_one; mach_port_t clock_port; mach_timespec_t remain; -static inline void square_am_signal(float time, float frequency) { +static inline void square_am_signal(float frequency, float time) { printf("Playing / %0.3f seconds / %4.0f Hz\n", time, frequency); uint64_t period = NSEC_PER_SEC / frequency; @@ -94,11 +94,11 @@ int main(int argc, char* argv[]) } char buffer[20] = {0}; - int time_ms; int freq_hz; + int time_ms; while (1) { fgets(buffer, 20 - 1, fp); - if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) { + if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) { square_am_signal(1.0 * time_ms / 1000, freq_hz); } if (feof(fp)) { diff --git a/implementations/c-neon-threads/main.c b/implementations/c-neon-threads/main.c index 028ba32..3df017e 100644 --- a/implementations/c-neon-threads/main.c +++ b/implementations/c-neon-threads/main.c @@ -53,7 +53,7 @@ void perform_high_bus_activity(void) { } } -static inline void square_am_signal(uint64_t time_ms, uint64_t freq_hz) { +static inline void square_am_signal(uint64_t freq_hz, uint64_t time_ms) { uint64_t start = mach_absolute_time(); uint64_t end = start + time_ms * 1000000 * timebase_info.denom / timebase_info.numer; @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) { } char buffer[64]; - int time_ms, freq_hz; + int freq_hz, time_ms; while (1) { if (!fgets(buffer, sizeof(buffer), fp)) { @@ -113,8 +113,8 @@ int main(int argc, char* argv[]) { } } - if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) { - square_am_signal(time_ms, freq_hz); + if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) { + square_am_signal(freq_hz, time_ms); } } diff --git a/implementations/cpp-counter-threads/main.cpp b/implementations/cpp-counter-threads/main.cpp index 6256b77..84ab2c0 100644 --- a/implementations/cpp-counter-threads/main.cpp +++ b/implementations/cpp-counter-threads/main.cpp @@ -32,7 +32,7 @@ void boost_song() { } } -void square_am_signal(float time, float frequency) { +void square_am_signal(float frequency, float time) { using namespace std::chrono; std::cout << "Playing / " << time << " seconds / " << frequency << " Hz\n"; @@ -77,12 +77,12 @@ int main(int argc, char* argv[]) { } char buffer[64] = {0}; // Buffer for reading lines from file - int time_ms; int freq_hz; + int time_ms; while (true) { if (fgets(buffer, sizeof(buffer) - 1, fp)) { - if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) { + if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) { square_am_signal(1.0 * time_ms / 1000, freq_hz); // Convert ms to seconds } } diff --git a/tunes/README.md b/tunes/README.md index 847f860..d3024a5 100644 --- a/tunes/README.md +++ b/tunes/README.md @@ -5,24 +5,22 @@ This file defines the `.tune` music file format. Following is a simple example of the beginning parts of the *Super Mario Brothers* theme song: ``` -100 660 -150 0 -100 660 -300 0 -100 660 -300 0 -100 510 +660 100 +0 150 +660 100 +0 300 +660 100 +0 300 +510 100 ``` ## Full specification -1. Simple text file -2. Each line represents a beep or a pause - 1. Column one is a positive integer number of milliseconds - 2. Column two is a positive integer frequency in Hz, or `0` which represents silence - 3. Columns are separated by a space -3. Line ending is unix format -4. File extension is `.tune` -5. Although not necessarily part of the tune, consider adding a silence at the end so that looped playback sounds good :-) +1. Each line in the file is ` ` + 1. `` is the frequency of the beep in Hz or `0` for silence + 2. `` is the duration of the beep in milliseconds +2. Line ending is unix format +3. File extension is `.tune` +4. Although not necessarily part of the tune, consider adding a silence at the end so that looped playback sounds good :-) Note: this is compatible with the [GRUB_INIT_TUNE](https://wiki.archlinux.org/title/GRUB/Tips_and_tricks#Play_a_tune) when using a `TEMPO` of 60,000 (bpm). diff --git a/tunes/mary_had_a_little_lamb.tune b/tunes/mary_had_a_little_lamb.tune index 70c0098..2f00875 100644 --- a/tunes/mary_had_a_little_lamb.tune +++ b/tunes/mary_had_a_little_lamb.tune @@ -1,27 +1,27 @@ -400 2673 -400 2349 -400 2093 -400 2349 -400 2673 -400 2673 -790 2673 -400 2349 -400 2349 -790 2349 -400 2673 -400 3136 -790 3136 -400 2673 -400 2349 -400 2093 -400 2349 -400 2673 -400 2673 -400 2673 -400 2673 -400 2349 -400 2349 -400 2673 -400 2349 -790 2093 -400 0 +2673 400 +2349 400 +2093 400 +2349 400 +2673 400 +2673 400 +2673 790 +2349 400 +2349 400 +2349 790 +2673 400 +3136 400 +3136 790 +2673 400 +2349 400 +2093 400 +2349 400 +2673 400 +2673 400 +2673 400 +2673 400 +2349 400 +2349 400 +2673 400 +2349 400 +2093 790 +0 400 diff --git a/tunes/morse_code_sos.tune b/tunes/morse_code_sos.tune index 2a6045e..4fedc0a 100644 --- a/tunes/morse_code_sos.tune +++ b/tunes/morse_code_sos.tune @@ -1,19 +1,19 @@ -200 1000 -200 0 -200 1000 -200 0 -200 1000 -200 0 -600 1000 -200 0 -600 1000 -200 0 -600 1000 -200 0 -200 1000 -200 0 -200 1000 -200 0 -200 1000 -200 0 -1400 0 +1000 200 +0 200 +1000 200 +0 200 +1000 200 +0 200 +1000 600 +0 200 +1000 600 +0 200 +1000 600 +0 200 +1000 200 +0 200 +1000 200 +0 200 +1000 200 +0 200 +0 1400 diff --git a/tunes/smb.tune b/tunes/smb.tune index 57abbdc..f975958 100644 --- a/tunes/smb.tune +++ b/tunes/smb.tune @@ -1,312 +1,312 @@ -100 660 -150 0 -100 660 -300 0 -100 660 -300 0 -100 510 -100 0 -100 660 -300 0 -100 770 -550 0 -100 380 -575 0 -100 510 -450 0 -100 380 -400 0 -100 320 -500 0 -100 440 -300 0 -80 480 -330 0 -100 450 -150 0 -100 430 -300 0 -100 380 -200 0 -80 660 -200 0 -50 760 -150 0 -100 860 -300 0 -80 700 -150 0 -50 760 -350 0 -80 660 -300 0 -80 520 -150 0 -80 580 -150 0 -80 480 -500 0 -100 510 -450 0 -100 380 -400 0 -100 320 -500 0 -100 440 -300 0 -80 480 -330 0 -100 450 -150 0 -100 430 -300 0 -100 380 -200 0 -80 660 -200 0 -50 760 -150 0 -100 860 -300 0 -80 700 -150 0 -50 760 -350 0 -80 660 -300 0 -80 520 -150 0 -80 580 -150 0 -80 480 -500 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -150 650 -300 0 -100 380 -150 0 -100 430 -150 0 -100 500 -300 0 -100 430 -150 0 -100 500 -100 0 -100 570 -220 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -200 650 -300 0 -80 1020 -300 0 -80 1020 -150 0 -80 1020 -300 0 -100 380 -300 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -150 650 -300 0 -100 380 -150 0 -100 430 -150 0 -100 500 -300 0 -100 430 -150 0 -100 500 -100 0 -100 570 -420 0 -100 585 -450 0 -100 550 -420 0 -100 500 -360 0 -100 380 -300 0 -100 500 -300 0 -100 500 -150 0 -100 500 -300 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -150 650 -300 0 -100 380 -150 0 -100 430 -150 0 -100 500 -300 0 -100 430 -150 0 -100 500 -100 0 -100 570 -220 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -200 650 -300 0 -80 1020 -300 0 -80 1020 -150 0 -80 1020 -300 0 -100 380 -300 0 -100 500 -300 0 -100 760 -100 0 -100 720 -150 0 -100 680 -150 0 -150 620 -300 0 -150 650 -300 0 -100 380 -150 0 -100 430 -150 0 -100 500 -300 0 -100 430 -150 0 -100 500 -100 0 -100 570 -420 0 -100 585 -450 0 -100 550 -420 0 -100 500 -360 0 -100 380 -300 0 -100 500 -300 0 -100 500 -150 0 -100 500 -300 0 -60 500 -150 0 -80 500 -300 0 -60 500 -350 0 -80 500 -150 0 -80 580 -350 0 -80 660 -150 0 -80 500 -300 0 -80 430 -150 0 -80 380 -600 0 -60 500 -150 0 -80 500 -300 0 -60 500 -350 0 -80 500 -150 0 -80 580 -150 0 -80 660 -550 0 -80 870 -325 0 -80 760 -600 0 -60 500 -150 0 -80 500 -300 0 -60 500 -350 0 -80 500 -150 0 -80 580 -350 0 -80 660 -150 0 -80 500 -300 0 -80 430 -150 0 -80 380 -600 0 -100 660 -150 0 -100 660 -300 0 -100 660 -300 0 -100 510 -100 0 -100 660 -300 0 -100 770 -550 0 -100 380 -575 0 +660 100 +0 150 +660 100 +0 300 +660 100 +0 300 +510 100 +0 100 +660 100 +0 300 +770 100 +0 550 +380 100 +0 575 +510 100 +0 450 +380 100 +0 400 +320 100 +0 500 +440 100 +0 300 +480 80 +0 330 +450 100 +0 150 +430 100 +0 300 +380 100 +0 200 +660 80 +0 200 +760 50 +0 150 +860 100 +0 300 +700 80 +0 150 +760 50 +0 350 +660 80 +0 300 +520 80 +0 150 +580 80 +0 150 +480 80 +0 500 +510 100 +0 450 +380 100 +0 400 +320 100 +0 500 +440 100 +0 300 +480 80 +0 330 +450 100 +0 150 +430 100 +0 300 +380 100 +0 200 +660 80 +0 200 +760 50 +0 150 +860 100 +0 300 +700 80 +0 150 +760 50 +0 350 +660 80 +0 300 +520 80 +0 150 +580 80 +0 150 +480 80 +0 500 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 150 +0 300 +380 100 +0 150 +430 100 +0 150 +500 100 +0 300 +430 100 +0 150 +500 100 +0 100 +570 100 +0 220 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 200 +0 300 +1020 80 +0 300 +1020 80 +0 150 +1020 80 +0 300 +380 100 +0 300 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 150 +0 300 +380 100 +0 150 +430 100 +0 150 +500 100 +0 300 +430 100 +0 150 +500 100 +0 100 +570 100 +0 420 +585 100 +0 450 +550 100 +0 420 +500 100 +0 360 +380 100 +0 300 +500 100 +0 300 +500 100 +0 150 +500 100 +0 300 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 150 +0 300 +380 100 +0 150 +430 100 +0 150 +500 100 +0 300 +430 100 +0 150 +500 100 +0 100 +570 100 +0 220 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 200 +0 300 +1020 80 +0 300 +1020 80 +0 150 +1020 80 +0 300 +380 100 +0 300 +500 100 +0 300 +760 100 +0 100 +720 100 +0 150 +680 100 +0 150 +620 150 +0 300 +650 150 +0 300 +380 100 +0 150 +430 100 +0 150 +500 100 +0 300 +430 100 +0 150 +500 100 +0 100 +570 100 +0 420 +585 100 +0 450 +550 100 +0 420 +500 100 +0 360 +380 100 +0 300 +500 100 +0 300 +500 100 +0 150 +500 100 +0 300 +500 60 +0 150 +500 80 +0 300 +500 60 +0 350 +500 80 +0 150 +580 80 +0 350 +660 80 +0 150 +500 80 +0 300 +430 80 +0 150 +380 80 +0 600 +500 60 +0 150 +500 80 +0 300 +500 60 +0 350 +500 80 +0 150 +580 80 +0 150 +660 80 +0 550 +870 80 +0 325 +760 80 +0 600 +500 60 +0 150 +500 80 +0 300 +500 60 +0 350 +500 80 +0 150 +580 80 +0 350 +660 80 +0 150 +500 80 +0 300 +430 80 +0 150 +380 80 +0 600 +660 100 +0 150 +660 100 +0 300 +660 100 +0 300 +510 100 +0 100 +660 100 +0 300 +770 100 +0 550 +380 100 +0 575