mirror of
https://github.com/danog/system-bus-radio.git
synced 2024-12-02 14:47:45 +01:00
Merge pull request #24 from rocketinventor/master
Updated song parser for JS
This commit is contained in:
commit
1874e2a2ab
@ -16,9 +16,38 @@
|
||||
<div class="content">
|
||||
</br>
|
||||
<input type="button" value="Play Song" onclick="start()"></br></br>
|
||||
<textarea id="logs" style="width:70%;min-height:300px">Tested with Chrome at 1560Khz
|
||||
</textarea>
|
||||
<div style="font-size:14px">Ported by Yeo Quan Yang. Credits to the original author William Entriken @https://github.com/fulldecent</div><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">
|
||||
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 <a href="https://github.com/quanyang">Yeo Quan Yang</a> & maintained by <a href="https://github.com/rocketinventor">Elliot Gerchak</a>.
|
||||
<br>
|
||||
Original machine code by <a href="https://github.com/fulldecent">William Entriken</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>
|
||||
|
@ -3,56 +3,43 @@
|
||||
//Tested to be working on Chrome at 1560khz
|
||||
|
||||
function now() {
|
||||
return performance.now()*1000000;
|
||||
return window.performance.now() * 1000000;
|
||||
}
|
||||
|
||||
var NSEC_PER_SEC = 1000000000;
|
||||
var register = 3.1415
|
||||
var register = 3.1415;
|
||||
|
||||
function square_am_signal(time,freq) {
|
||||
document.getElementById('logs').value += "Playing / "+time+" seconds / "+freq+"Hz\n";
|
||||
var period = NSEC_PER_SEC/freq;
|
||||
var start = now();
|
||||
var end = now()+time*NSEC_PER_SEC;
|
||||
while (now() < end) {
|
||||
var mid = start+period/2;
|
||||
var reset = start+period;
|
||||
while (now()<mid) {
|
||||
for (i = 0; i < 100; i++) {
|
||||
register = 1 - Math.log(register) / 1.7193
|
||||
}
|
||||
}
|
||||
while(now() < reset){
|
||||
}
|
||||
start = reset
|
||||
}
|
||||
function square_am_signal(time, freq) {
|
||||
document.getElementById('logs').value += "Playing / " + time + " seconds / " + freq + "Hz\n";
|
||||
var period = NSEC_PER_SEC / freq;
|
||||
var start = now();
|
||||
var end = now() + time * NSEC_PER_SEC;
|
||||
while (now() < end) {
|
||||
var mid = start + period / 2;
|
||||
var reset = start + period;
|
||||
while (now() < mid) {
|
||||
for (var i = 0; i < 100; i++) {
|
||||
register = 1 - Math.log(register) / 1.7193;
|
||||
}
|
||||
}
|
||||
while (now() < reset) {}
|
||||
start = reset;
|
||||
}
|
||||
}
|
||||
|
||||
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("\n");
|
||||
var length = song.length;
|
||||
var line, time, freq;
|
||||
for (var i = 0; i < length; i++) {
|
||||
line = song[i].split(" ");
|
||||
if (line[1] == "0") {
|
||||
// delay
|
||||
}
|
||||
else {
|
||||
freq = +line[1];
|
||||
time = +line[0];
|
||||
square_am_signal(time, freq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,4 +97,15 @@ input[type="text"]:focus ,input[type="password"]:focus,textarea:focus,select:foc
|
||||
input, textarea, keygen, select, button, isindex {
|
||||
outline:none;
|
||||
resize: none;
|
||||
}
|
||||
a
|
||||
{
|
||||
color: white;
|
||||
font-weight:bold;
|
||||
background-color: rgba(220, 220, 220, 0.35);
|
||||
text-decoration:none;
|
||||
}
|
||||
a:hover
|
||||
{
|
||||
background-color: rgba(240, 240, 240, 0.52);
|
||||
}
|
352
smb.song
Normal file
352
smb.song
Normal file
@ -0,0 +1,352 @@
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=510 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=770 length=100ms;
|
||||
:delay 550ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 575ms;
|
||||
|
||||
:beep frequency=510 length=100ms;
|
||||
:delay 450ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 400ms;
|
||||
:beep frequency=320 length=100ms;
|
||||
:delay 500ms;
|
||||
:beep frequency=440 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=480 length=80ms;
|
||||
:delay 330ms;
|
||||
:beep frequency=450 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 200ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 200ms;
|
||||
:beep frequency=760 length=50ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=860 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=700 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=760 length=50ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=520 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=580 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=480 length=80ms;
|
||||
:delay 500ms;
|
||||
|
||||
:beep frequency=510 length=100ms;
|
||||
:delay 450ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 400ms;
|
||||
:beep frequency=320 length=100ms;
|
||||
:delay 500ms;
|
||||
:beep frequency=440 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=480 length=80ms;
|
||||
:delay 330ms;
|
||||
:beep frequency=450 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 200ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 200ms;
|
||||
:beep frequency=760 length=50ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=860 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=700 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=760 length=50ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=520 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=580 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=480 length=80ms;
|
||||
:delay 500ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=150ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=570 length=100ms;
|
||||
:delay 220ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=200ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=150ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=570 length=100ms;
|
||||
:delay 420ms;
|
||||
|
||||
:beep frequency=585 length=100ms;
|
||||
:delay 450ms;
|
||||
|
||||
:beep frequency=550 length=100ms;
|
||||
:delay 420ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 360ms;
|
||||
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=150ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=570 length=100ms;
|
||||
:delay 220ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=200ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=1020 length=80ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=760 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=720 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=680 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=620 length=150ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=650 length=150ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=570 length=100ms;
|
||||
:delay 420ms;
|
||||
|
||||
:beep frequency=585 length=100ms;
|
||||
:delay 450ms;
|
||||
|
||||
:beep frequency=550 length=100ms;
|
||||
:delay 420ms;
|
||||
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 360ms;
|
||||
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=100ms;
|
||||
:delay 300ms;
|
||||
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=580 length=80ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=380 length=80ms;
|
||||
:delay 600ms;
|
||||
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=580 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 550ms;
|
||||
|
||||
:beep frequency=870 length=80ms;
|
||||
:delay 325ms;
|
||||
:beep frequency=760 length=80ms;
|
||||
:delay 600ms;
|
||||
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=500 length=60ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=580 length=80ms;
|
||||
:delay 350ms;
|
||||
:beep frequency=660 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=500 length=80ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=430 length=80ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=380 length=80ms;
|
||||
:delay 600ms;
|
||||
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 150ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=510 length=100ms;
|
||||
:delay 100ms;
|
||||
:beep frequency=660 length=100ms;
|
||||
:delay 300ms;
|
||||
:beep frequency=770 length=100ms;
|
||||
:delay 550ms;
|
||||
:beep frequency=380 length=100ms;
|
||||
:delay 575ms;
|
||||
:end
|
Loading…
Reference in New Issue
Block a user