Skip to content

Commit a063772

Browse files
New song format
Changed over the song parser and accompanying code to be inline with the new, as suggested in issue #28.
1 parent 8175668 commit a063772

File tree

2 files changed

+35
-40
lines changed

2 files changed

+35
-40
lines changed

In Javascript/airgap.html

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,34 @@
1717
</br>
1818
<input type="button" value="Play Song" onclick="start()"></br></br>
1919
<textarea id="logs" style="width:70%;min-height:100px">Tested with Chrome at 1560Khz</textarea>
20+
<p style="font-size:14px">Feel free to edit the code below or copy and paste any <em>valid</em> code.<br>Column one is time in <i>milliseconds</i>, and column two is <i>frequency</i>.</p>
2021
<textarea id="tones" style="width:70%;min-height:200px">
21-
Feel free to edit the code below. Just make sure you keep to the format that it's in and have all of the punctuation.
22-
:beep frequency=2673 length=400;
23-
:beep frequency=2349 length=400;
24-
:beep frequency=2093 length=400;
25-
:beep frequency=2349 length=400;
26-
:beep frequency=2673 length=400;
27-
:beep frequency=2673 length=400;
28-
:beep frequency=2673 length=790;
29-
:beep frequency=2349 length=400;
30-
:beep frequency=2349 length=400;
31-
:beep frequency=2349 length=790;
32-
:beep frequency=2673 length=400;
33-
:beep frequency=3136 length=400;
34-
:beep frequency=3136 length=790;
35-
:beep frequency=2673 length=400;
36-
:beep frequency=2349 length=400;
37-
:beep frequency=2093 length=400;
38-
:beep frequency=2349 length=400;
39-
:beep frequency=2673 length=400;
40-
:beep frequency=2673 length=400;
41-
:beep frequency=2673 length=400;
42-
:beep frequency=2673 length=400;
43-
:beep frequency=2349 length=400;
44-
:beep frequency=2349 length=400;
45-
:beep frequency=2673 length=400;
46-
:beep frequency=2349 length=400;
47-
:beep frequency=2093 length=790;</textarea>
22+
400 2673
23+
400 2349
24+
400 2093
25+
400 2349
26+
400 2673
27+
400 2673
28+
790 2673
29+
400 2349
30+
400 2349
31+
790 2349
32+
400 2673
33+
400 3136
34+
790 3136
35+
400 2673
36+
400 2349
37+
400 2093
38+
400 2349
39+
400 2673
40+
400 2673
41+
400 2673
42+
400 2673
43+
400 2349
44+
400 2349
45+
400 2673
46+
400 2349
47+
790 2093</textarea>
4848
<div style="font-size:14px">Ported by Yeo Quan Yang. Credits to the original author William Entriken @https://github.com/fulldecent</div><br/>
4949
<div style="font-size:14px">Project site at <a href="https://github.com/fulldecent/system-bus-radio">https://github.com/fulldecent/system-bus-radio</a></div><br/>
5050
<div style="font-size:14px">List of computers that work and what frequency to try at <a href="https://github.com/fulldecent/system-bus-radio/blob/master/TEST-DATA.tsv">https://github.com/fulldecent/system-bus-radio/blob/master/TEST-DATA.tsv</a></div>

In Javascript/airgap.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ function square_am_signal(time, freq) {
2828
}
2929

3030
function start() {
31-
var song = document.getElementById("tones").value.split(":");
31+
var song = document.getElementById("tones").value.split("\n");
3232
var length = song.length;
33-
var i = 1,
34-
line, time, freq;
35-
while (1 <= length) {
33+
var line, time, freq;
34+
for (var i = 0; i < length; i++) {
3635
line = song[i].split(" ");
37-
if (line[0] == "beep") {
38-
freq = +line[0].split("=")[1];
39-
time = +line[2].split("=")[1].slice(0, -1);
40-
square_am_signal(time, freq);
41-
}
42-
if (line[0] == "delay") {
36+
if (line[1] == "0") {
4337
// delay
4438
}
45-
if (song[i] == "end") {
46-
i = 1;
39+
else {
40+
freq = +line[1];
41+
time = +line[0];
42+
square_am_signal(time, freq);
4743
}
48-
i++;
4944
}
5045
}

0 commit comments

Comments
 (0)