optimize
This commit is contained in:
parent
00c5467a89
commit
91b8c55de9
@ -2,7 +2,6 @@ class OwrxAudioProcessor extends AudioWorkletProcessor {
|
|||||||
constructor(options){
|
constructor(options){
|
||||||
super(options);
|
super(options);
|
||||||
this.maxLength = options.processorOptions.maxLength;
|
this.maxLength = options.processorOptions.maxLength;
|
||||||
this.reduceToLength = options.processorOptions.reduceToLength;
|
|
||||||
// initialize ringbuffer, make sure it aligns with the expected buffer size of 128
|
// initialize ringbuffer, make sure it aligns with the expected buffer size of 128
|
||||||
this.bufferSize = Math.round(sampleRate * this.maxLength / 128) * 128
|
this.bufferSize = Math.round(sampleRate * this.maxLength / 128) * 128
|
||||||
this.audioBuffer = new Float32Array(this.bufferSize);
|
this.audioBuffer = new Float32Array(this.bufferSize);
|
||||||
|
@ -1546,7 +1546,7 @@ function audio_prepare(data) {
|
|||||||
buffer = audio_resampler.process(sdrjs.ConvertI16_F(buffer));
|
buffer = audio_resampler.process(sdrjs.ConvertI16_F(buffer));
|
||||||
if (audio_node.port) {
|
if (audio_node.port) {
|
||||||
// AudioWorklets supported
|
// AudioWorklets supported
|
||||||
audio_node.port.postMessage(buffer, [buffer.buffer]);
|
audio_node.port.postMessage(buffer);
|
||||||
} else {
|
} else {
|
||||||
audio_buffers.push(buffer);
|
audio_buffers.push(buffer);
|
||||||
}
|
}
|
||||||
@ -1568,9 +1568,9 @@ function audio_onprocess(e) {
|
|||||||
var newLength = total + b.length;
|
var newLength = total + b.length;
|
||||||
// not enough space to fit all data, so splice and put back in the queue
|
// not enough space to fit all data, so splice and put back in the queue
|
||||||
if (newLength > audio_buffer_size) {
|
if (newLength > audio_buffer_size) {
|
||||||
var tokeep = b.slice(0, audio_buffer_size - total);
|
var tokeep = b.subarray(0, audio_buffer_size - total);
|
||||||
out.set(tokeep, total);
|
out.set(tokeep, total);
|
||||||
var tobuffer = b.slice(audio_buffer_size - total, b.length);
|
var tobuffer = b.subarray(audio_buffer_size - total, b.length);
|
||||||
audio_buffers.unshift(tobuffer);
|
audio_buffers.unshift(tobuffer);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -1732,8 +1732,7 @@ function audio_init() {
|
|||||||
numberOfOutputs: 1,
|
numberOfOutputs: 1,
|
||||||
outputChannelCount: [1],
|
outputChannelCount: [1],
|
||||||
processorOptions: {
|
processorOptions: {
|
||||||
maxLength: audio_buffer_maximal_length_sec,
|
maxLength: audio_buffer_maximal_length_sec
|
||||||
reduceToLength: audio_buffer_decrease_to_on_overrun_sec
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
audio_node.connect(gainNode);
|
audio_node.connect(gainNode);
|
||||||
|
Loading…
Reference in New Issue
Block a user