mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Adds a Local ADS-B layer fed by your own receivers: a browser WebUSB RTL-SDR (with FM listening) and local 1090/978 MHz decoder feeds (LOCAL_RECEIVER_FEEDS, local and private addresses only). Local aircraft draw in magenta with class, silhouettes, 3D models, trails and a position sanity filter; the click card names the band and input that heard them. Builds on Sameh Khamis's SDR prototype and the initial GEV port by Mazeyar Moeini Feizabadi (#134); the decoder-feed design follows the notes on #57. Closes #57. Co-authored-by: Sameh Khamis <[email protected]> Co-authored-by: Mazeyar Moeini Feizabadi <[email protected]>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
class GevSdrAudioPlayer extends AudioWorkletProcessor {
|
|
constructor() {
|
|
super();
|
|
this.queue = [];
|
|
this.offset = 0;
|
|
this.volume = 0.8;
|
|
this.port.onmessage = (event) => {
|
|
if (
|
|
event.data?.type === 'samples' &&
|
|
event.data.samples instanceof Float32Array
|
|
) {
|
|
this.queue.push(event.data.samples);
|
|
if (this.queue.length > 48)
|
|
this.queue.splice(0, this.queue.length - 48);
|
|
} else if (event.data?.type === 'volume') {
|
|
this.volume = Math.max(0, Math.min(1, Number(event.data.value) || 0));
|
|
} else if (event.data?.type === 'clear') {
|
|
this.queue.length = 0;
|
|
this.offset = 0;
|
|
}
|
|
};
|
|
}
|
|
|
|
process(_inputs, outputs) {
|
|
const output = outputs[0]?.[0];
|
|
if (!output) return true;
|
|
output.fill(0);
|
|
let outputOffset = 0;
|
|
while (outputOffset < output.length && this.queue.length) {
|
|
const samples = this.queue[0];
|
|
const available = samples.length - this.offset;
|
|
const count = Math.min(output.length - outputOffset, available);
|
|
for (let index = 0; index < count; index += 1) {
|
|
output[outputOffset + index] =
|
|
samples[this.offset + index] * this.volume;
|
|
}
|
|
outputOffset += count;
|
|
this.offset += count;
|
|
if (this.offset >= samples.length) {
|
|
this.queue.shift();
|
|
this.offset = 0;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
registerProcessor('gev-sdr-audio-player', GevSdrAudioPlayer);
|