determine hd audio rate and send it to the server
This commit is contained in:
parent
ef2ec1e1c5
commit
da3f59fb9b
@ -19,6 +19,7 @@ function AudioEngine(maxBufferLength, audioReporter) {
|
|||||||
|
|
||||||
this.setupResampling();
|
this.setupResampling();
|
||||||
this.resampler = new Interpolator(this.resamplingFactor);
|
this.resampler = new Interpolator(this.resamplingFactor);
|
||||||
|
this.hdResampler = new Interpolator(this.hdResamplingFactor);
|
||||||
|
|
||||||
this.maxBufferSize = maxBufferLength * this.getSampleRate();
|
this.maxBufferSize = maxBufferLength * this.getSampleRate();
|
||||||
}
|
}
|
||||||
@ -165,30 +166,52 @@ AudioEngine.prototype.resetStats = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
AudioEngine.prototype.setupResampling = function() { //both at the server and the client
|
AudioEngine.prototype.setupResampling = function() { //both at the server and the client
|
||||||
var output_range_max = 12000;
|
var audio_params = this.findRate(8000, 12000);
|
||||||
var output_range_min = 8000;
|
if (!audio_params) {
|
||||||
|
this.resamplingFactor = 0;
|
||||||
|
this.outputRate = 0;
|
||||||
|
divlog('Your audio card sampling rate (' + targetRate + ') is not supported.<br />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<br />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 targetRate = this.audioContext.sampleRate;
|
||||||
var i = 1;
|
var i = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
var audio_server_output_rate = Math.floor(targetRate / i);
|
var audio_server_output_rate = Math.floor(targetRate / i);
|
||||||
if (audio_server_output_rate < output_range_min) {
|
if (audio_server_output_rate < low) {
|
||||||
this.resamplingFactor = 0;
|
return;
|
||||||
this.outputRate = 0;
|
} else if (audio_server_output_rate >= low && audio_server_output_rate <= high) {
|
||||||
divlog('Your audio card sampling rate (' + targetRate + ') is not supported.<br />Please change your operating system default settings in order to fix this.', 1);
|
return {
|
||||||
break;
|
resamplingFactor: i,
|
||||||
} else if (audio_server_output_rate >= output_range_min && audio_server_output_rate <= output_range_max) {
|
outputRate: audio_server_output_rate
|
||||||
this.resamplingFactor = i;
|
}
|
||||||
this.outputRate = audio_server_output_rate;
|
|
||||||
break; //okay, we're done
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
AudioEngine.prototype.getOutputRate = function() {
|
AudioEngine.prototype.getOutputRate = function() {
|
||||||
return this.outputRate;
|
return this.outputRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AudioEngine.prototype.getHdOutputRate = function() {
|
||||||
|
return this.hdOutputRate;
|
||||||
|
}
|
||||||
|
|
||||||
AudioEngine.prototype.getSampleRate = function() {
|
AudioEngine.prototype.getSampleRate = function() {
|
||||||
return this.audioContext.sampleRate;
|
return this.audioContext.sampleRate;
|
||||||
};
|
};
|
||||||
|
@ -1067,7 +1067,10 @@ function on_ws_opened() {
|
|||||||
reconnect_timeout = false;
|
reconnect_timeout = false;
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
"type": "connectionproperties",
|
"type": "connectionproperties",
|
||||||
"params": {"output_rate": audioEngine.getOutputRate()}
|
"params": {
|
||||||
|
"output_rate": audioEngine.getOutputRate(),
|
||||||
|
"hd_output_rate": audioEngine.getHdOutputRate()
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ class DspManager(csdr.output):
|
|||||||
# local demodulator properties not forwarded to the sdr
|
# local demodulator properties not forwarded to the sdr
|
||||||
self.props.addLayer(0, PropertyLayer().filter(
|
self.props.addLayer(0, PropertyLayer().filter(
|
||||||
"output_rate",
|
"output_rate",
|
||||||
|
"hd_output_rate",
|
||||||
"squelch_level",
|
"squelch_level",
|
||||||
"secondary_mod",
|
"secondary_mod",
|
||||||
"low_cut",
|
"low_cut",
|
||||||
|
Loading…
Reference in New Issue
Block a user