Skip to content

Commit

Permalink
New song format
Browse files Browse the repository at this point in the history
Changed over the song parser and accompanying code to be inline with the new, as suggested in issue fulldecent#28.
  • Loading branch information
rocketinventor committed Oct 26, 2016
1 parent 8175668 commit a063772
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
54 changes: 27 additions & 27 deletions In Javascript/airgap.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@
</br>
<input type="button" value="Play Song" onclick="start()"></br></br>
<textarea id="logs" style="width:70%;min-height:100px">Tested with Chrome at 1560Khz</textarea>
<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>
<textarea id="tones" style="width:70%;min-height:200px">
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.
:beep frequency=2673 length=400;
:beep frequency=2349 length=400;
:beep frequency=2093 length=400;
:beep frequency=2349 length=400;
:beep frequency=2673 length=400;
:beep frequency=2673 length=400;
:beep frequency=2673 length=790;
:beep frequency=2349 length=400;
:beep frequency=2349 length=400;
:beep frequency=2349 length=790;
:beep frequency=2673 length=400;
:beep frequency=3136 length=400;
:beep frequency=3136 length=790;
:beep frequency=2673 length=400;
:beep frequency=2349 length=400;
:beep frequency=2093 length=400;
:beep frequency=2349 length=400;
:beep frequency=2673 length=400;
:beep frequency=2673 length=400;
:beep frequency=2673 length=400;
:beep frequency=2673 length=400;
:beep frequency=2349 length=400;
:beep frequency=2349 length=400;
:beep frequency=2673 length=400;
:beep frequency=2349 length=400;
:beep frequency=2093 length=790;</textarea>
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</textarea>
<div style="font-size:14px">Ported by Yeo Quan Yang. Credits to the original author William Entriken @https://github.com/fulldecent</div><br/>
<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/>
<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>
Expand Down
21 changes: 8 additions & 13 deletions In Javascript/airgap.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,18 @@ function square_am_signal(time, freq) {
}

function start() {
var song = document.getElementById("tones").value.split(":");
var song = document.getElementById("tones").value.split("\n");
var length = song.length;
var i = 1,
line, time, freq;
while (1 <= length) {
var line, time, freq;
for (var i = 0; i < length; i++) {
line = song[i].split(" ");
if (line[0] == "beep") {
freq = +line[0].split("=")[1];
time = +line[2].split("=")[1].slice(0, -1);
square_am_signal(time, freq);
}
if (line[0] == "delay") {
if (line[1] == "0") {
// delay
}
if (song[i] == "end") {
i = 1;
else {
freq = +line[1];
time = +line[0];
square_am_signal(time, freq);
}
i++;
}
}

0 comments on commit a063772

Please sign in to comment.