From e11eb7bf96137f6f3b1a2d16376b0e1246411027 Mon Sep 17 00:00:00 2001 From: Elliot Gerchak Date: Tue, 8 Mar 2016 05:20:38 +0000 Subject: [PATCH] Made song editable Based on pull request #1... The list of frequencies to be played has been moved from the JS to a textbox in the HTML. Editing the content of the box will change what gets played. The format also is more human human readable and consistent with the songfile from #1. If you copy and paste the smb.song file, it should work. --- In Javascript/airgap.html | 31 +++++++++++++++++++++++++-- In Javascript/airgap.js | 44 ++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/In Javascript/airgap.html b/In Javascript/airgap.html index b663ec7..4a2215d 100644 --- a/In Javascript/airgap.html +++ b/In Javascript/airgap.html @@ -16,8 +16,35 @@



- + +
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 68a4910..908d93d 100644 --- a/In Javascript/airgap.js +++ b/In Javascript/airgap.js @@ -29,30 +29,22 @@ function square_am_signal(time,freq) { } function start() { - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2093); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.790, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2349); - square_am_signal(0.790, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 3136); - square_am_signal(0.790, 3136); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2093); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2349); - square_am_signal(0.400, 2673); - square_am_signal(0.400, 2349); - square_am_signal(0.790, 2093); + var song = document.getElementById("tones").value.split(":"); + var length = song.length; + var i = 1, line, time, freq; + while (1 <= length) { + 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") { + // delay + } + if (song[i] == "end") { + i = 1; + } + i++; + } }