New song format

Changed over the song parser and accompanying code to be inline with the new, as suggested in issue #28.
This commit is contained in:
Elliot Gerchak 2016-10-26 22:33:22 +00:00
parent 81756689ba
commit a0637721ce
2 changed files with 35 additions and 40 deletions

View File

@ -17,34 +17,34 @@
</br> </br>
<input type="button" value="Play Song" onclick="start()"></br></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> <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"> <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. 400 2673
:beep frequency=2673 length=400; 400 2349
:beep frequency=2349 length=400; 400 2093
:beep frequency=2093 length=400; 400 2349
:beep frequency=2349 length=400; 400 2673
:beep frequency=2673 length=400; 400 2673
:beep frequency=2673 length=400; 790 2673
:beep frequency=2673 length=790; 400 2349
:beep frequency=2349 length=400; 400 2349
:beep frequency=2349 length=400; 790 2349
:beep frequency=2349 length=790; 400 2673
:beep frequency=2673 length=400; 400 3136
:beep frequency=3136 length=400; 790 3136
:beep frequency=3136 length=790; 400 2673
:beep frequency=2673 length=400; 400 2349
:beep frequency=2349 length=400; 400 2093
:beep frequency=2093 length=400; 400 2349
:beep frequency=2349 length=400; 400 2673
:beep frequency=2673 length=400; 400 2673
:beep frequency=2673 length=400; 400 2673
:beep frequency=2673 length=400; 400 2673
:beep frequency=2673 length=400; 400 2349
:beep frequency=2349 length=400; 400 2349
:beep frequency=2349 length=400; 400 2673
:beep frequency=2673 length=400; 400 2349
:beep frequency=2349 length=400; 790 2093</textarea>
:beep frequency=2093 length=790;</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">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">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> <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>

View File

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