Fixed opus music seconds sound channel
parent
ebf3e9f7b9
commit
f743f9b3fc
|
@ -1 +1 @@
|
|||
Subproject commit b97dd67fdc75a39d0fc99ceee573921ba3e73b1f
|
||||
Subproject commit 655cc54c564b84ef2827f0b2152ce3811046201e
|
|
@ -73,6 +73,7 @@ extern "C" {
|
|||
printf("Initialize opus. (Channel count: %d Sample rate: %d Type: %d)!\n", channelCount, 48000, type);
|
||||
auto codec = new OpusHandle{};
|
||||
codec->opusType = type;
|
||||
codec->channelCount = channelCount;
|
||||
if(!reinitialize_decoder(codec)) return nullptr;
|
||||
if(!reinitialize_encoder(codec)) return nullptr;
|
||||
return codec;
|
||||
|
|
|
@ -68,9 +68,11 @@ class CodecWrapper extends BasicCodec {
|
|||
array[index] = data.data[index];
|
||||
|
||||
let audioBuf = this._audioContext.createBuffer(this.channelCount, array.length / this.channelCount, this._codecSampleRate);
|
||||
for (let channel = 0; channel < this.channelCount; channel++)
|
||||
for (let offset = 0; offset < audioBuf.length; offset++)
|
||||
audioBuf.getChannelData(channel)[offset] = array[channel * audioBuf.length + offset];
|
||||
for (let channel = 0; channel < this.channelCount; channel++) {
|
||||
for (let offset = 0; offset < audioBuf.length; offset++) {
|
||||
audioBuf.getChannelData(channel)[offset] = array[channel + offset * 2];
|
||||
}
|
||||
}
|
||||
resolve(audioBuf);
|
||||
} else {
|
||||
reject(data.message);
|
||||
|
|
|
@ -36,7 +36,7 @@ if(!AudioBuffer.prototype.copyToChannel) { //Webkit does not implement this func
|
|||
|
||||
class VoiceRecorder {
|
||||
private static readonly CHANNEL = 0;
|
||||
private static readonly CHANNELS = 1;
|
||||
private static readonly CHANNELS = 2;
|
||||
private static readonly BUFFER_SIZE = 1024 * 4;
|
||||
|
||||
handle: VoiceConnection;
|
||||
|
|
|
@ -95,6 +95,7 @@ class OpusWorker implements CodecWorker {
|
|||
if (result < 0) {
|
||||
return "invalid result on decode (" + result + ")";
|
||||
}
|
||||
console.log("Result: %o | Channel count %o", result, this.channelCount);
|
||||
return Module.HEAPF32.slice(this.decodeBuffer.byteOffset / 4, (this.decodeBuffer.byteOffset / 4) + (result * this.channelCount));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue