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
 	this.D = new Float32Array(1024);
22
 	this.D = new Float32Array(1024);
23
 	this.D.set(MP2.SYNTHESIS_WINDOW, 0);
23
 	this.D.set(MP2.SYNTHESIS_WINDOW, 0);
24
 	this.D.set(MP2.SYNTHESIS_WINDOW, 512);
24
 	this.D.set(MP2.SYNTHESIS_WINDOW, 512);
25
-	this.V = new Float32Array(1024);
25
+	this.V = [new Float32Array(1024), new Float32Array(1024)];
26
 	this.U = new Int32Array(32);
26
 	this.U = new Int32Array(32);
27
 	this.VPos = 0;
27
 	this.VPos = 0;
28
 
28
 
242
 				this.VPos = (this.VPos - 64) & 1023;
242
 				this.VPos = (this.VPos - 64) & 1023;
243
 
243
 
244
 				for (var ch = 0;  ch < 2; ch++) {
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
 					// Build U, windowing, calculate output
247
 					// Build U, windowing, calculate output
248
 					JSMpeg.Fill(this.U, 0);
248
 					JSMpeg.Fill(this.U, 0);
251
 					var vIndex = (this.VPos % 128) >> 1;
251
 					var vIndex = (this.VPos % 128) >> 1;
252
 					while (vIndex < 1024) {
252
 					while (vIndex < 1024) {
253
 						for (var i = 0; i < 32; ++i) {
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
 						vIndex += 128-32;
257
 						vIndex += 128-32;
262
 					dIndex -= (512 - 32);
262
 					dIndex -= (512 - 32);
263
 					while (vIndex < 1024) {
263
 					while (vIndex < 1024) {
264
 						for (var i = 0; i < 32; ++i) {
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
 						vIndex += 128-32;
268
 						vIndex += 128-32;

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

217
 	float channel_left[SAMPLES_PER_FRAME];
217
 	float channel_left[SAMPLES_PER_FRAME];
218
 	float channel_right[SAMPLES_PER_FRAME];
218
 	float channel_right[SAMPLES_PER_FRAME];
219
 	float D[1024];
219
 	float D[1024];
220
-	float V[1024];
220
+	float V[2][1024];
221
 	int U[32];
221
 	int U[32];
222
 } mp2_decoder_t;
222
 } mp2_decoder_t;
223
 
223
 
459
 				self->v_pos = (self->v_pos - 64) & 1023;
459
 				self->v_pos = (self->v_pos - 64) & 1023;
460
 
460
 
461
 				for (int ch = 0;  ch < 2; ch++) {
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
 					// Build U, windowing, calculate output
464
 					// Build U, windowing, calculate output
465
 					memset(self->U, 0, sizeof(self->U));
465
 					memset(self->U, 0, sizeof(self->U));
468
 					int v_index = (self->v_pos % 128) >> 1;
468
 					int v_index = (self->v_pos % 128) >> 1;
469
 					while (v_index < 1024) {
469
 					while (v_index < 1024) {
470
 						for (int i = 0; i < 32; ++i) {
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
 						v_index += 128-32;
474
 						v_index += 128-32;
479
 					d_index -= (512 - 32);
479
 					d_index -= (512 - 32);
480
 					while (v_index < 1024) {
480
 					while (v_index < 1024) {
481
 						for (int i = 0; i < 32; ++i) {
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
 						v_index += 128-32;
485
 						v_index += 128-32;