Skip to content

Commit 1029934

Browse files
committed
simplify busy work
1 parent 406465e commit 1029934

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

In Javascript/airgap.js

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,25 @@
22
//As well as Jordan Harband for the nodejs simd library
33
//Tested to be working on Chrome at 1560khz
44

5-
var _i32x4 = new Int32Array(4);
6-
Int32x4 = function(x, y, z, w) {
7-
if (!(this instanceof Int32x4)) {
8-
return new Int32x4(x, y, z, w);
9-
}
10-
11-
this.x_ = x|0;
12-
this.y_ = y|0;
13-
this.z_ = z|0;
14-
this.w_ = w|0;
15-
}
16-
17-
Int32x4store = function(tarray, index, value) {
18-
var bpe = tarray.BYTES_PER_ELEMENT;
19-
_i32x4[0] = value.x_;
20-
_i32x4[1] = value.y_;
21-
_i32x4[2] = value.z_;
22-
_i32x4[3] = value.w_;
23-
var array = bpe == 1 ? _i8x16 :
24-
bpe == 2 ? _i16x8 :
25-
bpe == 4 ? (tarray instanceof Float32Array ? _f32x4 : _i32x4) :
26-
_f64x2;
27-
var n = 16 / bpe;
28-
for (var i = 0; i < n; ++i)
29-
tarray[index + i] = array[i];
30-
return value;
31-
}
32-
335
function now() {
346
return performance.now()*1000000;
357
}
368

37-
var tarray = new Int32Array(4);
38-
var zero = Int32x4(0,0,0,0);
39-
var one = Int32x4(-1,-1,-1,-1);
409
var NSEC_PER_SEC = 1000000000;
10+
var register = 3.1415
4111

4212
function square_am_signal(time,freq) {
43-
document.getElementById('logs').value += "Playing / "+time+" seconds / "+freq+"Hz\n";
13+
document.getElementById('logs').value += "Playing / "+time+" seconds / "+freq+"Hz\n";
4414
var period = NSEC_PER_SEC/freq;
4515
var start = now();
4616
var end = now()+time*NSEC_PER_SEC;
4717
while (now() < end) {
4818
var mid = start+period/2;
4919
var reset = start+period;
5020
while (now()<mid) {
51-
Int32x4store(tarray, 0, one);
52-
Int32x4store(tarray, 0, zero);
21+
for (i = 0; i < 100; i++) {
22+
register = 1 - Math.log(register) / 1.7193
23+
}
5324
}
5425
while(now() < reset){
5526
}

0 commit comments

Comments
 (0)