diff --git a/htdocs/lib/AudioEngine.js b/htdocs/lib/AudioEngine.js
index 7e67042..b82b9de 100644
--- a/htdocs/lib/AudioEngine.js
+++ b/htdocs/lib/AudioEngine.js
@@ -19,6 +19,7 @@ function AudioEngine(maxBufferLength, audioReporter) {
this.setupResampling();
this.resampler = new Interpolator(this.resamplingFactor);
+ this.hdResampler = new Interpolator(this.hdResamplingFactor);
this.maxBufferSize = maxBufferLength * this.getSampleRate();
}
@@ -165,30 +166,52 @@ AudioEngine.prototype.resetStats = function() {
};
AudioEngine.prototype.setupResampling = function() { //both at the server and the client
- var output_range_max = 12000;
- var output_range_min = 8000;
+ var audio_params = this.findRate(8000, 12000);
+ if (!audio_params) {
+ this.resamplingFactor = 0;
+ this.outputRate = 0;
+ divlog('Your audio card sampling rate (' + targetRate + ') is not supported.
Please change your operating system default settings in order to fix this.', 1);
+ } else {
+ this.resamplingFactor = audio_params.resamplingFactor;
+ this.outputRate = audio_params.outputRate;
+ }
+
+ var hd_audio_params = this.findRate(36000, 48000);
+ if (!hd_audio_params) {
+ this.hdResamplingFactor = 0;
+ this.hdOutputRate = 0;
+ divlog('Your audio card sampling rate (' + targetRate + ') is not supported for HD audio
Please change your operating system default settings in order to fix this.', 1);
+ } else {
+ this.hdResamplingFactor = hd_audio_params.resamplingFactor;
+ this.hdOutputRate = hd_audio_params.outputRate;
+ }
+};
+
+AudioEngine.prototype.findRate = function(low, high) {
var targetRate = this.audioContext.sampleRate;
var i = 1;
while (true) {
var audio_server_output_rate = Math.floor(targetRate / i);
- if (audio_server_output_rate < output_range_min) {
- this.resamplingFactor = 0;
- this.outputRate = 0;
- divlog('Your audio card sampling rate (' + targetRate + ') is not supported.
Please change your operating system default settings in order to fix this.', 1);
- break;
- } else if (audio_server_output_rate >= output_range_min && audio_server_output_rate <= output_range_max) {
- this.resamplingFactor = i;
- this.outputRate = audio_server_output_rate;
- break; //okay, we're done
+ if (audio_server_output_rate < low) {
+ return;
+ } else if (audio_server_output_rate >= low && audio_server_output_rate <= high) {
+ return {
+ resamplingFactor: i,
+ outputRate: audio_server_output_rate
+ }
}
i++;
- }
-};
+ };
+}
AudioEngine.prototype.getOutputRate = function() {
return this.outputRate;
};
+AudioEngine.prototype.getHdOutputRate = function() {
+ return this.hdOutputRate;
+}
+
AudioEngine.prototype.getSampleRate = function() {
return this.audioContext.sampleRate;
};
diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js
index dadd7e3..9d17f3b 100644
--- a/htdocs/openwebrx.js
+++ b/htdocs/openwebrx.js
@@ -1067,7 +1067,10 @@ function on_ws_opened() {
reconnect_timeout = false;
ws.send(JSON.stringify({
"type": "connectionproperties",
- "params": {"output_rate": audioEngine.getOutputRate()}
+ "params": {
+ "output_rate": audioEngine.getOutputRate(),
+ "hd_output_rate": audioEngine.getHdOutputRate()
+ }
}));
}
diff --git a/owrx/dsp.py b/owrx/dsp.py
index cc94097..1bbf1f8 100644
--- a/owrx/dsp.py
+++ b/owrx/dsp.py
@@ -30,6 +30,7 @@ class DspManager(csdr.output):
# local demodulator properties not forwarded to the sdr
self.props.addLayer(0, PropertyLayer().filter(
"output_rate",
+ "hd_output_rate",
"squelch_level",
"secondary_mod",
"low_cut",