Skip to content

Commit a02d542

Browse files
committed
match grub format
1 parent 48d6ed5 commit a02d542

File tree

9 files changed

+421
-423
lines changed

9 files changed

+421
-423
lines changed

docs/index.html

+35-35
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,42 @@ <h1>System Bus Radio</h1>
2020
<section style="display:flex;width:60%;margin:auto">
2121
<textarea style="width:2rem" id="progress" readonly></textarea>
2222
<textarea style="flex:1;height:50rem" id="tune">
23-
400 2673
24-
400 2349
25-
400 2093
26-
400 2349
27-
400 2673
28-
400 0
29-
400 2673
30-
400 0
31-
790 2673
32-
400 2349
33-
400 2349
34-
400 0
35-
790 2349
36-
400 2673
37-
400 3136
38-
400 0
39-
790 3136
40-
400 2673
41-
400 2349
42-
400 2093
43-
400 2349
44-
400 2673
45-
400 0
46-
400 2673
47-
400 0
48-
400 2673
49-
400 0
50-
400 2673
51-
400 2349
52-
400 0
53-
400 2349
54-
400 2673
55-
400 2349
56-
790 2093</textarea>
23+
2673 400
24+
2349 400
25+
2093 400
26+
2349 400
27+
2673 400
28+
0 400
29+
2673 400
30+
0 400
31+
2673 790
32+
2349 400
33+
2349 400
34+
0 400
35+
2349 790
36+
2673 400
37+
3136 400
38+
0 400
39+
3136 790
40+
2673 400
41+
2349 400
42+
2093 400
43+
2349 400
44+
2673 400
45+
0 400
46+
2673 400
47+
0 400
48+
2673 400
49+
0 400
50+
2673 400
51+
2349 400
52+
0 400
53+
2349 400
54+
2673 400
55+
2349 400
56+
2093 790</textarea>
5757
</section>
58-
<p>Edit the above to make any music you like. <a href="https://github.com/fulldecent/system-bus-radio/issues/28">Tune file format</a> is time (ms) and frequency (Hz).</p>
58+
<p>Edit the above to make any music you like. <a href="https://github.com/fulldecent/system-bus-radio/issues/28">Tune file format</a> is frequency (Hz) and time (ms).</p>
5959
<p>Chrome has errors if you open this file locally (<code>file://</code>). Try using <code>php -S localhost:8000</code> or similar for a quick web server.</p>
6060
<p>Ported by <a href="https://github.com/quanyang">Yeo Quan Yang</a> & maintained by <a href="https://github.com/rocketinventor">Elliot Gerchak</a>.</p>
6161
<p>Original machine code by <a href="https://github.com/fulldecent">William Entriken</a>.</p>

docs/worker.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function now() {
1111
var NSEC_PER_SEC = 1000000000;
1212
var register = 3.1415;
1313

14-
function square_am_signal(time, freq) { // This funcion generates the radio waves
14+
function square_am_signal(freq, time) { // This function generates the radio waves
1515
postMessage("\nPlaying / " + time + " seconds / " + freq + "Hz");
1616
var period = NSEC_PER_SEC / freq;
1717
var start = now();
@@ -32,16 +32,16 @@ function square_am_signal(time, freq) { // This funcion generates the radio wave
3232
function play(song) { // Parse song data, and call on required scripts to run it
3333
song = song.split("\n");
3434
var length = song.length;
35-
var line, time, freq;
35+
var line, freq, time;
3636
for (var i = 0; i < length; i++) {
3737
line = song[i].split(" ");
3838
if (+line[1] == 0) {
3939
pause(line[0]);
4040
}
4141
else {
42-
freq = +line[1];
43-
time = (+line[0])*.001;
44-
square_am_signal(time, freq);
42+
time = (+line[1])*.001;
43+
freq = +line[0];
44+
square_am_signal(freq, time);
4545
}
4646
}
4747

implementations/c-_mm_stream_si128/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ __m128i reg_one;
5050
mach_port_t clock_port;
5151
mach_timespec_t remain;
5252

53-
static inline void square_am_signal(float time, float frequency) {
53+
static inline void square_am_signal(float frequency, float time) {
5454
printf("Playing / %0.3f seconds / %4.0f Hz\n", time, frequency);
5555
uint64_t period = NSEC_PER_SEC / frequency;
5656

@@ -94,11 +94,11 @@ int main(int argc, char* argv[])
9494
}
9595

9696
char buffer[20] = {0};
97-
int time_ms;
9897
int freq_hz;
98+
int time_ms;
9999
while (1) {
100100
fgets(buffer, 20 - 1, fp);
101-
if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) {
101+
if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) {
102102
square_am_signal(1.0 * time_ms / 1000, freq_hz);
103103
}
104104
if (feof(fp)) {

implementations/c-neon-threads/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void perform_high_bus_activity(void) {
5353
}
5454
}
5555

56-
static inline void square_am_signal(uint64_t time_ms, uint64_t freq_hz) {
56+
static inline void square_am_signal(uint64_t freq_hz, uint64_t time_ms) {
5757
uint64_t start = mach_absolute_time();
5858
uint64_t end = start + time_ms * 1000000 * timebase_info.denom / timebase_info.numer;
5959

@@ -100,7 +100,7 @@ int main(int argc, char* argv[]) {
100100
}
101101

102102
char buffer[64];
103-
int time_ms, freq_hz;
103+
int freq_hz, time_ms;
104104

105105
while (1) {
106106
if (!fgets(buffer, sizeof(buffer), fp)) {
@@ -113,8 +113,8 @@ int main(int argc, char* argv[]) {
113113
}
114114
}
115115

116-
if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) {
117-
square_am_signal(time_ms, freq_hz);
116+
if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) {
117+
square_am_signal(freq_hz, time_ms);
118118
}
119119
}
120120

implementations/cpp-counter-threads/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void boost_song() {
3232
}
3333
}
3434

35-
void square_am_signal(float time, float frequency) {
35+
void square_am_signal(float frequency, float time) {
3636
using namespace std::chrono;
3737
std::cout << "Playing / " << time << " seconds / " << frequency << " Hz\n";
3838

@@ -77,12 +77,12 @@ int main(int argc, char* argv[]) {
7777
}
7878

7979
char buffer[64] = {0}; // Buffer for reading lines from file
80-
int time_ms;
8180
int freq_hz;
81+
int time_ms;
8282

8383
while (true) {
8484
if (fgets(buffer, sizeof(buffer) - 1, fp)) {
85-
if (sscanf(buffer, "%d %d", &time_ms, &freq_hz) == 2) {
85+
if (sscanf(buffer, "%d %d", &freq_hz, &time_ms) == 2) {
8686
square_am_signal(1.0 * time_ms / 1000, freq_hz); // Convert ms to seconds
8787
}
8888
}

tunes/README.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@ This file defines the `.tune` music file format.
55
Following is a simple example of the beginning parts of the *Super Mario Brothers* theme song:
66

77
```
8-
100 660
9-
150 0
10-
100 660
11-
300 0
12-
100 660
13-
300 0
14-
100 510
8+
660 100
9+
0 150
10+
660 100
11+
0 300
12+
660 100
13+
0 300
14+
510 100
1515
```
1616

1717
## Full specification
1818

19-
1. Simple text file
20-
2. Each line represents a beep or a pause
21-
1. Column one is a positive integer number of milliseconds
22-
2. Column two is a positive integer frequency in Hz, or `0` which represents silence
23-
3. Columns are separated by a space
24-
3. Line ending is unix format
25-
4. File extension is `.tune`
26-
5. Although not necessarily part of the tune, consider adding a silence at the end so that looped playback sounds good :-)
19+
1. Each line in the file is `<frequency> <duration>`
20+
1. `<frequency>` is the frequency of the beep in Hz or `0` for silence
21+
2. `<duration>` is the duration of the beep in milliseconds
22+
2. Line ending is unix format
23+
3. File extension is `.tune`
24+
4. Although not necessarily part of the tune, consider adding a silence at the end so that looped playback sounds good :-)
2725

2826
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).

tunes/mary_had_a_little_lamb.tune

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
400 2673
2-
400 2349
3-
400 2093
4-
400 2349
5-
400 2673
6-
400 2673
7-
790 2673
8-
400 2349
9-
400 2349
10-
790 2349
11-
400 2673
12-
400 3136
13-
790 3136
14-
400 2673
15-
400 2349
16-
400 2093
17-
400 2349
18-
400 2673
19-
400 2673
20-
400 2673
21-
400 2673
22-
400 2349
23-
400 2349
24-
400 2673
25-
400 2349
26-
790 2093
27-
400 0
1+
2673 400
2+
2349 400
3+
2093 400
4+
2349 400
5+
2673 400
6+
2673 400
7+
2673 790
8+
2349 400
9+
2349 400
10+
2349 790
11+
2673 400
12+
3136 400
13+
3136 790
14+
2673 400
15+
2349 400
16+
2093 400
17+
2349 400
18+
2673 400
19+
2673 400
20+
2673 400
21+
2673 400
22+
2349 400
23+
2349 400
24+
2673 400
25+
2349 400
26+
2093 790
27+
0 400

tunes/morse_code_sos.tune

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
200 1000
2-
200 0
3-
200 1000
4-
200 0
5-
200 1000
6-
200 0
7-
600 1000
8-
200 0
9-
600 1000
10-
200 0
11-
600 1000
12-
200 0
13-
200 1000
14-
200 0
15-
200 1000
16-
200 0
17-
200 1000
18-
200 0
19-
1400 0
1+
1000 200
2+
0 200
3+
1000 200
4+
0 200
5+
1000 200
6+
0 200
7+
1000 600
8+
0 200
9+
1000 600
10+
0 200
11+
1000 600
12+
0 200
13+
1000 200
14+
0 200
15+
1000 200
16+
0 200
17+
1000 200
18+
0 200
19+
0 1400

0 commit comments

Comments
 (0)