Procházet zdrojové kódy

Fix audio only using the right channel for volume; close #342

Dominic Szablewski před 5 roky
rodič
revize
c5fabf047f
3 změnil soubory, kde provedl 9 přidání a 13 odebrání
  1. 1 5
      jsmpeg.min.js
  2. 4 4
      src/mp2.js
  3. 4 4
      src/wasm/mp2.c

Diff nebyl zobrazen, protože je příliš veliký
+ 1 - 5
jsmpeg.min.js


+ 4 - 4
src/mp2.js Zobrazit soubor

@@ -22,7 +22,7 @@ var MP2 = function(options) {
22 22
 	this.D = new Float32Array(1024);
23 23
 	this.D.set(MP2.SYNTHESIS_WINDOW, 0);
24 24
 	this.D.set(MP2.SYNTHESIS_WINDOW, 512);
25
-	this.V = new Float32Array(1024);
25
+	this.V = [new Float32Array(1024), new Float32Array(1024)];
26 26
 	this.U = new Int32Array(32);
27 27
 	this.VPos = 0;
28 28
 
@@ -242,7 +242,7 @@ MP2.prototype.decodeFrame = function(left, right) {
242 242
 				this.VPos = (this.VPos - 64) & 1023;
243 243
 
244 244
 				for (var ch = 0;  ch < 2; ch++) {
245
-					MP2.MatrixTransform(this.sample[ch], p, this.V, this.VPos);
245
+					MP2.MatrixTransform(this.sample[ch], p, this.V[ch], this.VPos);
246 246
 
247 247
 					// Build U, windowing, calculate output
248 248
 					JSMpeg.Fill(this.U, 0);
@@ -251,7 +251,7 @@ MP2.prototype.decodeFrame = function(left, right) {
251 251
 					var vIndex = (this.VPos % 128) >> 1;
252 252
 					while (vIndex < 1024) {
253 253
 						for (var i = 0; i < 32; ++i) {
254
-							this.U[i] += this.D[dIndex++] * this.V[vIndex++];
254
+							this.U[i] += this.D[dIndex++] * this.V[ch][vIndex++];
255 255
 						}
256 256
 
257 257
 						vIndex += 128-32;
@@ -262,7 +262,7 @@ MP2.prototype.decodeFrame = function(left, right) {
262 262
 					dIndex -= (512 - 32);
263 263
 					while (vIndex < 1024) {
264 264
 						for (var i = 0; i < 32; ++i) {
265
-							this.U[i] += this.D[dIndex++] * this.V[vIndex++];
265
+							this.U[i] += this.D[dIndex++] * this.V[ch][vIndex++];
266 266
 						}
267 267
 
268 268
 						vIndex += 128-32;

+ 4 - 4
src/wasm/mp2.c Zobrazit soubor

@@ -217,7 +217,7 @@ typedef struct mp2_decoder_t {
217 217
 	float channel_left[SAMPLES_PER_FRAME];
218 218
 	float channel_right[SAMPLES_PER_FRAME];
219 219
 	float D[1024];
220
-	float V[1024];
220
+	float V[2][1024];
221 221
 	int U[32];
222 222
 } mp2_decoder_t;
223 223
 
@@ -459,7 +459,7 @@ int decode_frame(mp2_decoder_t *self) {
459 459
 				self->v_pos = (self->v_pos - 64) & 1023;
460 460
 
461 461
 				for (int ch = 0;  ch < 2; ch++) {
462
-					matrix_transform(self->sample[ch], p, self->V, self->v_pos);
462
+					matrix_transform(self->sample[ch], p, self->V[ch], self->v_pos);
463 463
 
464 464
 					// Build U, windowing, calculate output
465 465
 					memset(self->U, 0, sizeof(self->U));
@@ -468,7 +468,7 @@ int decode_frame(mp2_decoder_t *self) {
468 468
 					int v_index = (self->v_pos % 128) >> 1;
469 469
 					while (v_index < 1024) {
470 470
 						for (int i = 0; i < 32; ++i) {
471
-							self->U[i] += self->D[d_index++] * self->V[v_index++];
471
+							self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
472 472
 						}
473 473
 
474 474
 						v_index += 128-32;
@@ -479,7 +479,7 @@ int decode_frame(mp2_decoder_t *self) {
479 479
 					d_index -= (512 - 32);
480 480
 					while (v_index < 1024) {
481 481
 						for (int i = 0; i < 32; ++i) {
482
-							self->U[i] += self->D[d_index++] * self->V[v_index++];
482
+							self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
483 483
 						}
484 484
 
485 485
 						v_index += 128-32;