fixing some issues with the IDE

This commit is contained in:
Jakob Ketterl 2019-10-20 23:38:58 +02:00
parent 13d7686258
commit dd7d262bd3
3 changed files with 20 additions and 20 deletions

View File

@ -117,14 +117,14 @@ AudioEngine.prototype.start = function(callback) {
setInterval(me.reportStats.bind(me), 1000);
});
}
};
AudioEngine.prototype.isAllowed = function() {
return this.allowed;
}
};
AudioEngine.prototype.reportStats = function() {
var stats = {}
var stats = {};
if (this.audioNode.port) {
this.audioNode.port.postMessage(JSON.stringify({cmd:'getBuffers'}));
} else {
@ -132,12 +132,12 @@ AudioEngine.prototype.reportStats = function() {
}
stats.audioRate = this.stats.audioSamples;
var elapsed = new Date() - this.stats.startTime;
stats.audioByteRate = this.stats.audioBytes * 1000 / elapsed
stats.audioByteRate = this.stats.audioBytes * 1000 / elapsed;
this.audioReporter(stats);
// sample rate is just measuring the last seconds
this.stats.audioSamples = 0;
}
};
AudioEngine.prototype.resetStats = function() {
this.stats = {
@ -145,7 +145,7 @@ AudioEngine.prototype.resetStats = function() {
audioBytes: 0,
audioSamples: 0
};
}
};
AudioEngine.prototype.setupResampling = function() { //both at the server and the client
var output_range_max = 12000;
@ -166,15 +166,15 @@ AudioEngine.prototype.setupResampling = function() { //both at the server and th
}
i++;
}
}
};
AudioEngine.prototype.getOutputRate = function() {
return this.outputRate;
}
};
AudioEngine.prototype.getSampleRate = function() {
return this.audioContext.sampleRate;
}
};
AudioEngine.prototype.pushAudio = function(data) {
if (!this.audioNode) return;
@ -197,18 +197,18 @@ AudioEngine.prototype.pushAudio = function(data) {
this.audioBuffers.push(buffer);
}
}
}
};
AudioEngine.prototype.setCompression = function(compression) {
this.compression = compression;
}
};
AudioEngine.prototype.setVolume = function(volume) {
this.gainNode.gain.value = volume;
}
};
AudioEngine.prototype.getBuffersize = function() {
// only available when using ScriptProcessorNode
if (!this.audioBuffers) return 0;
return this.audioBuffers.map(function(b){ return b.length; }).reduce(function(a, b){ return a + b; }, 0);
}
};

View File

@ -2,14 +2,14 @@ class OwrxAudioProcessor extends AudioWorkletProcessor {
constructor(options){
super(options);
// initialize ringbuffer, make sure it aligns with the expected buffer size of 128
this.bufferSize = Math.round(options.processorOptions.maxBufferSize / 128) * 128
this.bufferSize = Math.round(options.processorOptions.maxBufferSize / 128) * 128;
this.audioBuffer = new Float32Array(this.bufferSize);
this.inPos = 0;
this.outPos = 0;
this.port.addEventListener('message', (m) => {
if (typeof(m.data) === 'string') {
const json = JSON.parse(m.data);
if (json.cmd && json.cmd == 'getBuffers') {
if (json.cmd && json.cmd === 'getBuffers') {
this.reportBuffers();
}
} else {
@ -31,7 +31,7 @@ class OwrxAudioProcessor extends AudioWorkletProcessor {
this.port.addEventListener('messageerror', console.error);
this.port.start();
}
process(inputs, outputs, parameters) {
process(inputs, outputs) {
const samples = Math.min(128, this.remaining());
outputs[0].forEach((output) => {
output.set(this.audioBuffer.subarray(this.outPos, this.outPos + samples));

View File

@ -157,6 +157,10 @@ function updateSquelch() {
var waterfall_min_level;
var waterfall_max_level;
var waterfall_min_level_default;
var waterfall_max_level_default;
var waterfall_colors;
var waterfall_auto_level_margin;
function updateWaterfallColors(which) {
var wfmax = e("openwebrx-waterfall-color-max");
@ -1452,10 +1456,6 @@ function waterfall_measure_minmax_do(what) {
waterfall_measure_minmax_max = Math.max(waterfall_measure_minmax_max, Math.max.apply(Math, what));
}
function waterfall_measure_minmax_print() {
console.log("Waterfall | min = " + waterfall_measure_minmax_min.toString() + " dB | max = " + waterfall_measure_minmax_max.toString() + " dB");
}
function on_ws_opened() {
ws.send("SERVER DE CLIENT client=openwebrx.js type=receiver");
divlog("WebSocket opened to " + ws.url);