From a0637721ce6376b489ce84240a41b2c945490ae3 Mon Sep 17 00:00:00 2001 From: Elliot Gerchak Date: Wed, 26 Oct 2016 22:33:22 +0000 Subject: [PATCH] New song format Changed over the song parser and accompanying code to be inline with the new, as suggested in issue #28. --- In Javascript/airgap.html | 54 +++++++++++++++++++-------------------- In Javascript/airgap.js | 21 ++++++--------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/In Javascript/airgap.html b/In Javascript/airgap.html index 4a2215d..4c91257 100644 --- a/In Javascript/airgap.html +++ b/In Javascript/airgap.html @@ -17,34 +17,34 @@


+

Feel free to edit the code below or copy and paste any valid code.
Column one is time in milliseconds, and column two is frequency.

+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
Ported by Yeo Quan Yang. Credits to the original author William Entriken @https://github.com/fulldecent

Project site at https://github.com/fulldecent/system-bus-radio

List of computers that work and what frequency to try at https://github.com/fulldecent/system-bus-radio/blob/master/TEST-DATA.tsv
diff --git a/In Javascript/airgap.js b/In Javascript/airgap.js index a0aef3a..6b8c463 100644 --- a/In Javascript/airgap.js +++ b/In Javascript/airgap.js @@ -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++; } }