Skip to content

🎥 Make videos programmatically with React

actual fix

Jonny Burgerdbf2cc7b5fc5
diff --git a/packages/media/src/convert-audiodata/convert-audiodata.ts b/packages/media/src/convert-audiodata/convert-audiodata.ts
index 9096aafa61..d2947dedf1 100644
--- a/packages/media/src/convert-audiodata/convert-audiodata.ts
+++ b/packages/media/src/convert-audiodata/convert-audiodata.ts
@@ -13,8 +13,6 @@ export type ConvertAudioDataOptions = {
isLast: boolean;
};
-const FORMAT: AudioSampleFormat = 's16';
-
export type PcmS16AudioData = {
data: Int16Array;
numberOfFrames: number;
@@ -83,16 +81,29 @@ export const convertAudioData = ({
);
}
+ // Always normalize through f32 to ensure consistent conversion across
+ // browsers. Firefox decodes audio as f32 while Chrome decodes as s16-planar.
+ // Relying on the browser's AudioData.copyTo() for the f32→s16 conversion
+ // produces different results per browser. By always going through f32 and
+ // converting to s16 ourselves, we guarantee identical output.
const srcChannels = new Int16Array(srcNumberOfChannels * frameCount);
-
- audioData.copyTo(srcChannels, {
- planeIndex: 0,
- format: FORMAT,
- frameOffset,
- frameCount,
- });
-
- console.log('srcChannels', srcChannels);
+ const f32Temp = new Float32Array(frameCount);
+
+ for (let ch = 0; ch < srcNumberOfChannels; ch++) {
+ audioData.copyTo(f32Temp, {
+ planeIndex: ch,
+ frameOffset,
+ frameCount,
+ format: 'f32-planar',
+ });
+ for (let i = 0; i < frameCount; i++) {
+ const clamped = Math.max(-1, Math.min(1, f32Temp[i]));
+ srcChannels[i * srcNumberOfChannels + ch] = Math.max(
+ -32768,
+ Math.min(32767, Math.round(clamped * 32768)),
+ );
+ }
+ }
const data = new Int16Array(newNumberOfFrames * TARGET_NUMBER_OF_CHANNELS);
const chunkSize = frameCount / newNumberOfFrames;
diff --git a/packages/media/src/test/__snapshots__/audio-encoding.test.ts.snap b/packages/media/src/test/__snapshots__/audio-encoding.test.ts.snap
index fe915407c0..40b959dc10 100644
--- a/packages/media/src/test/__snapshots__/audio-encoding.test.ts.snap
+++ b/packages/media/src/test/__snapshots__/audio-encoding.test.ts.snap
@@ -1,54 +1,1405 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-0-first10 1`] = `
+exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > audio-encoding 1`] = `
[
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-0-last10 1`] = `
-[
- -372,
- -549,
- -165,
- -271,
- 10,
- -107,
- 116,
- -12,
- 184,
- 151,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-0-sum 1`] = `-37638`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-1-first10 1`] = `
-[
- 219,
- 280,
- 175,
+ -789,
+ -1070,
+ -916,
+ -1137,
+ -793,
+ -996,
+ -791,
+ -1015,
+ -1008,
+ -1222,
+ -1020,
+ -1198,
+ -767,
+ -929,
+ -502,
+ -679,
+ -239,
+ -463,
+ -31,
+ -296,
+ -44,
+ -314,
+ -260,
+ -530,
+ -459,
+ -738,
+ -391,
+ -646,
+ -146,
+ -364,
+ -170,
+ -395,
+ -532,
+ -798,
+ -752,
+ -1038,
+ -527,
+ -789,
+ -103,
+ -340,
+ 60,
+ -169,
+ -62,
+ -264,
+ -38,
+ -198,
242,
- 129,
- 216,
- 178,
- 302,
- 233,
- 317,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-1-last10 1`] = `
-[
+ 68,
+ 533,
+ 298,
+ 814,
+ 567,
+ 1073,
+ 858,
+ 1168,
+ 951,
+ 1157,
+ 907,
+ 1093,
+ 830,
+ 1060,
+ 811,
+ 1338,
+ 1105,
+ 1670,
+ 1455,
+ 1429,
+ 1234,
+ 847,
+ 666,
+ 692,
+ 523,
+ 1066,
+ 943,
+ 1415,
+ 1352,
+ 1260,
+ 1199,
+ 841,
+ 748,
+ 722,
+ 654,
+ 689,
+ 668,
+ 305,
+ 293,
+ 19,
+ 22,
+ 157,
+ 212,
+ 222,
+ 301,
+ -26,
+ 33,
+ -293,
+ -245,
+ -349,
+ -289,
+ -150,
+ -71,
+ 58,
+ 142,
+ 85,
+ 137,
+ 204,
+ 240,
+ 360,
+ 459,
+ 28,
+ 198,
+ -506,
+ -338,
+ -351,
+ -201,
+ 395,
+ 573,
+ 731,
+ 919,
+ 192,
+ 333,
+ -564,
+ -446,
+ -598,
+ -446,
+ 75,
+ 255,
+ 603,
+ 805,
+ 521,
+ 783,
+ 121,
+ 403,
+ -163,
+ 30,
+ -62,
+ 28,
+ 553,
+ 627,
+ 1548,
+ 1643,
+ 2295,
+ 2412,
+ 1975,
+ 2137,
+ 735,
+ 931,
+ 80,
+ 255,
+ 1025,
+ 1172,
+ 2403,
+ 2561,
+ 2365,
+ 2549,
+ 983,
+ 1175,
+ -159,
+ 35,
+ -262,
+ -56,
+ 371,
+ 609,
+ 1328,
+ 1606,
+ 1943,
+ 2234,
+ 1508,
+ 1782,
+ 484,
+ 736,
+ 14,
+ 259,
+ 511,
+ 768,
+ 1576,
+ 1844,
+ 2262,
+ 2515,
+ 1720,
+ 1937,
+ 583,
+ 772,
+ 223,
+ 425,
+ 657,
+ 923,
+ 1013,
+ 1345,
+ 909,
+ 1257,
+ 361,
+ 673,
+ -289,
+ -17,
+ -518,
+ -274,
+ -421,
+ -189,
+ -322,
+ -73,
+ -114,
+ 166,
+ 99,
+ 389,
+ -51,
+ 220,
+ -308,
+ -70,
+ -50,
+ 146,
+ 593,
+ 734,
+ 840,
+ 921,
+ 520,
+ 557,
+ 345,
+ 367,
+ 672,
+ 715,
+ 1088,
+ 1160,
+ 1285,
+ 1349,
+ 1330,
+ 1341,
+ 1418,
+ 1366,
+ 1702,
+ 1603,
+ 1913,
+ 1783,
+ 1776,
+ 1639,
+ 1793,
+ 1667,
+ 2221,
+ 2109,
+ 2345,
+ 2234,
+ 1955,
+ 1825,
+ 1811,
+ 1625,
+ 2148,
+ 1905,
+ 2417,
+ 2177,
+ 2259,
+ 2056,
+ 1805,
+ 1610,
+ 1430,
+ 1247,
+ 1402,
+ 1273,
+ 1558,
+ 1457,
+ 1588,
+ 1457,
+ 1451,
+ 1301,
+ 1251,
+ 1136,
+ 1058,
+ 989,
+ 914,
+ 873,
+ 799,
+ 781,
+ 713,
+ 714,
+ 735,
+ 739,
+ 714,
+ 699,
+ 346,
+ 290,
+ -159,
+ -246,
+ -255,
+ -327,
+ -22,
+ -66,
+ -53,
+ -110,
+ -511,
+ -604,
+ -985,
+ -1097,
+ -1129,
+ -1258,
+ -1120,
+ -1269,
+ -1318,
+ -1452,
+ -1653,
+ -1743,
+ -1828,
+ -1911,
+ -1876,
+ -1988,
+ -1930,
+ -2057,
+ -1928,
+ -2052,
+ -1796,
+ -1929,
+ -1618,
+ -1749,
+ -1582,
+ -1687,
+ -1692,
+ -1786,
+ -1601,
+ -1723,
+ -1246,
+ -1409,
+ -1027,
+ -1221,
+ -995,
+ -1213,
+ -833,
+ -1080,
+ -627,
+ -879,
+ -697,
+ -912,
+ -949,
+ -1129,
+ -970,
+ -1158,
+ -779,
+ -984,
+ -853,
+ -1048,
+ -1129,
+ -1326,
+ -1110,
+ -1333,
+ -963,
+ -1163,
+ -1045,
+ -1159,
+ -1092,
+ -1155,
+ -1007,
+ -1088,
+ -1107,
+ -1194,
+ -1350,
+ -1418,
+ -1441,
+ -1534,
+ -1329,
+ -1484,
+ -1236,
+ -1396,
+ -1434,
+ -1549,
+ -1782,
+ -1874,
+ -1839,
+ -1928,
+ -1612,
+ -1684,
+ -1401,
+ -1483,
+ -1320,
+ -1443,
+ -1473,
+ -1602,
+ -1813,
+ -1921,
+ -1952,
+ -2065,
+ -1857,
+ -1948,
+ -1900,
+ -1897,
+ -2071,
+ -2004,
+ -2118,
+ -2089,
+ -2108,
+ -2117,
+ -2228,
+ -2199,
+ -2374,
+ -2331,
+ -2291,
+ -2302,
+ -2052,
+ -2073,
+ -2014,
+ -1951,
+ -2207,
+ -2098,
+ -2296,
+ -2230,
+ -2110,
+ -2057,
+ -1850,
+ -1755,
+ -1821,
+ -1725,
+ -1979,
+ -1933,
+ -1972,
+ -1947,
+ -1753,
+ -1712,
+ -1672,
+ -1618,
+ -1868,
+ -1815,
+ -2048,
+ -2004,
+ -1949,
+ -1910,
+ -1760,
+ -1705,
+ -1796,
+ -1723,
+ -1889,
+ -1816,
+ -1729,
+ -1670,
+ -1518,
+ -1493,
+ -1541,
+ -1552,
+ -1620,
+ -1638,
+ -1540,
+ -1556,
+ -1409,
+ -1426,
+ -1437,
+ -1394,
+ -1631,
+ -1517,
+ -1746,
+ -1680,
+ -1587,
+ -1632,
+ -1268,
+ -1340,
+ -1175,
+ -1225,
+ -1534,
+ -1591,
+ -1777,
+ -1804,
+ -1327,
+ -1273,
+ -874,
+ -786,
+ -1145,
+ -1085,
+ -1539,
+ -1505,
+ -1370,
+ -1377,
+ -847,
+ -917,
+ -515,
+ -584,
+ -656,
+ -642,
+ -967,
+ -896,
+ -928,
+ -858,
+ -561,
+ -472,
+ -379,
+ -244,
+ -600,
+ -492,
+ -828,
+ -793,
+ -779,
+ -748,
+ -708,
+ -598,
+ -705,
+ -482,
+ -645,
+ -312,
+ -644,
+ -262,
+ -581,
+ -251,
+ -203,
+ 58,
+ 171,
+ 425,
+ 259,
+ 552,
+ 453,
+ 804,
+ 922,
+ 1343,
+ 1219,
+ 1670,
+ 1248,
+ 1650,
+ 1362,
+ 1708,
+ 1674,
+ 2015,
+ 1978,
+ 2306,
+ 1983,
+ 2270,
+ 1924,
+ 2223,
+ 2371,
+ 2754,
+ 2872,
+ 3316,
+ 2737,
+ 3191,
+ 2547,
+ 3000,
+ 2786,
+ 3217,
+ 3165,
+ 3556,
+ 3579,
+ 3985,
+ 3853,
+ 4331,
+ 3850,
+ 4373,
+ 3844,
+ 4365,
+ 3884,
+ 4395,
+ 4048,
+ 4536,
+ 4586,
+ 5034,
+ 5059,
+ 5473,
+ 4823,
+ 5208,
+ 4152,
+ 4517,
+ 3854,
+ 4212,
+ 4174,
+ 4525,
+ 4615,
+ 4969,
+ 4644,
+ 5013,
+ 4232,
+ 4576,
+ 3789,
+ 4056,
+ 3620,
+ 3844,
+ 3690,
+ 3932,
+ 3954,
+ 4218,
+ 4108,
+ 4377,
+ 3681,
+ 3957,
+ 3110,
+ 3356,
+ 3128,
+ 3298,
+ 3493,
+ 3642,
+ 3640,
+ 3858,
+ 3391,
+ 3642,
+ 2916,
+ 3095,
+ 2665,
+ 2773,
+ 2770,
+ 2871,
+ 2844,
+ 2940,
+ 2691,
+ 2796,
+ 2489,
+ 2672,
+ 2360,
+ 2604,
+ 2251,
+ 2469,
+ 2145,
+ 2344,
+ 2071,
+ 2303,
+ 2092,
+ 2325,
+ 2230,
+ 2434,
+ 2131,
+ 2371,
+ 1675,
+ 1992,
+ 1510,
+ 1865,
+ 1793,
+ 2161,
+ 1857,
+ 2239,
+ 1535,
+ 1897,
+ 1242,
+ 1576,
+ 1289,
+ 1661,
+ 1558,
+ 1981,
+ 1470,
+ 1883,
+ 966,
+ 1394,
+ 746,
+ 1267,
+ 994,
+ 1543,
+ 1165,
+ 1641,
+ 978,
+ 1416,
+ 733,
+ 1148,
+ 672,
+ 1026,
+ 545,
+ 947,
+ 247,
+ 799,
+ 69,
+ 598,
+ -8,
+ 327,
+ -155,
+ 90,
+ -396,
+ -117,
+ -850,
+ -568,
+ -1288,
+ -1035,
+ -1324,
+ -1076,
+ -1403,
+ -1142,
+ -1890,
+ -1669,
+ -2145,
+ -2084,
+ -1932,
+ -2012,
+ -1907,
+ -1927,
+ -2235,
+ -2182,
+ -2514,
+ -2603,
+ -2574,
+ -2812,
+ -2430,
+ -2654,
+ -2330,
+ -2578,
+ -2611,
+ -2954,
+ -3006,
+ -3340,
+ -3089,
+ -3411,
+ -3043,
+ -3501,
+ -3185,
+ -3767,
+ -3441,
+ -4024,
+ -3636,
+ -4193,
+ -3854,
+ -4408,
+ -4226,
+ -4795,
+ -4447,
+ -5065,
+ -4287,
+ -4985,
+ -4191,
+ -4976,
+ -4355,
+ -5212,
+ -4442,
+ -5323,
+ -4452,
+ -5337,
+ -4483,
+ -5366,
+ -4358,
+ -5172,
+ -4100,
+ -4840,
+ -3872,
+ -4690,
+ -3774,
+ -4759,
+ -3835,
+ -4884,
+ -3716,
+ -4738,
+ -3257,
+ -4248,
+ -3076,
+ -3975,
+ -3467,
+ -4222,
+ -3735,
+ -4473,
+ -3426,
+ -4326,
+ -3024,
+ -4058,
+ -3091,
+ -4085,
+ -3529,
+ -4389,
+ -3812,
+ -4518,
+ -3658,
+ -4224,
+ -3319,
+ -3907,
+ -3224,
+ -4012,
+ -3422,
+ -4311,
+ -3487,
+ -4259,
+ -3289,
+ -3917,
+ -3321,
+ -3854,
+ -3651,
+ -4123,
+ -3760,
+ -4307,
+ -3621,
+ -4306,
+ -3597,
+ -4245,
+ -3718,
+ -4232,
+ -3884,
+ -4368,
+ -4047,
+ -4558,
+ -4070,
+ -4585,
+ -3852,
+ -4332,
+ -3713,
+ -4092,
+ -4004,
+ -4311,
+ -4276,
+ -4623,
+ -4003,
+ -4400,
+ -3561,
+ -3975,
+ -3453,
+ -3889,
+ -3807,
+ -4154,
+ -4275,
+ -4449,
+ -4134,
+ -4275,
+ -3668,
+ -3895,
+ -3749,
+ -4073,
+ -4105,
+ -4574,
+ -4366,
+ -4836,
+ -4534,
+ -4719,
+ -4160,
+ -4175,
+ -3757,
+ -3925,
+ -4254,
+ -4545,
+ -4691,
+ -4989,
+ -4189,
+ -4514,
+ -3617,
+ -3818,
+ -3556,
+ -3542,
+ -3802,
+ -3845,
+ -4012,
+ -4205,
+ -3777,
+ -3856,
+ -3327,
+ -3276,
+ -3109,
+ -3142,
+ -3204,
+ -3279,
+ -3530,
+ -3509,
+ -3440,
+ -3377,
+ -3033,
+ -2959,
+ -3382,
+ -3213,
+ -3744,
+ -3569,
+ -3136,
+ -3164,
+ -2536,
+ -2705,
+ -2291,
+ -2318,
+ -2611,
+ -2458,
+ -4072,
+ -3887,
+ -4494,
+ -4280,
+ -2344,
+ -2160,
+ -528,
+ -582,
+ -1125,
+ -1281,
+ -2774,
+ -2639,
+ -4011,
+ -3607,
+ -3510,
+ -3140,
+ -624,
+ -330,
+ 1797,
+ 2103,
+ 914,
+ 1204,
+ -1350,
+ -1094,
+ -2244,
+ -1993,
+ -1094,
+ -784,
+ 2008,
+ 2473,
+ 3747,
+ 4325,
+ 1160,
+ 1675,
+ -1646,
+ -1272,
+ -756,
+ -444,
+ 1646,
+ 2060,
+ 3269,
+ 3900,
+ 3790,
+ 4511,
+ 3876,
+ 4528,
+ 4857,
+ 5536,
+ 6718,
+ 7492,
+ 9795,
+ 10557,
+ 14080,
+ 14907,
+ 16417,
+ 17426,
+ 15929,
+ 16948,
+ 15716,
+ 16644,
+ 16845,
+ 17834,
+ 18740,
+ 19792,
+ 20490,
+ 21492,
+ 19140,
+ 20157,
+ 14576,
+ 15666,
+ 12364,
+ 13465,
+ 14859,
+ 15975,
+ 16857,
+ 18003,
+ 14491,
+ 15560,
+ 10180,
+ 11072,
+ 7904,
+ 8668,
+ 9244,
+ 10043,
+ 11790,
+ 12686,
+ 11900,
+ 12755,
+ 9993,
+ 10708,
+ 8092,
+ 8724,
+ 6662,
+ 7218,
+ 6559,
+ 6999,
+ 7372,
+ 7790,
+ 7352,
+ 7817,
+ 6574,
+ 7005,
+ 4824,
+ 5189,
+ 2022,
+ 2364,
+ 1217,
+ 1531,
+ 3478,
+ 3764,
+ 4970,
+ 5246,
+ 3418,
+ 3633,
+ 943,
+ 1046,
+ -153,
+ -137,
+ 213,
+ 213,
+ 820,
+ 832,
+ 379,
+ 342,
+ -1164,
+ -1303,
+ -2861,
+ -3002,
+ -4083,
+ -4138,
+ -4338,
+ -4401,
+ -3483,
+ -3635,
+ -2337,
+ -2512,
+ -1537,
+ -1705,
+ -1254,
+ -1450,
+ -1214,
+ -1400,
+ -279,
+ -389,
+ 1599,
+ 1526,
+ 2824,
+ 2688,
+ 2751,
+ 2510,
+ 2188,
+ 1902,
+ 1932,
+ 1651,
+ 1964,
+ 1626,
+ 1693,
+ 1283,
+ 951,
+ 601,
+ 66,
+ -201,
+ -715,
+ -1069,
+ -1453,
+ -1940,
+ -2302,
+ -2789,
+ -2820,
+ -3309,
+ -2756,
+ -3317,
+ -2809,
+ -3345,
+ -3169,
+ -3617,
+ -3418,
+ -3907,
+ -3554,
+ -4143,
+ -3496,
+ -4104,
+ -3258,
+ -3859,
+ -3417,
+ -4033,
+ -4150,
+ -4774,
+ -4767,
+ -5421,
+ -4803,
+ -5472,
+ -4724,
+ -5340,
+ -4879,
+ -5497,
+ -5118,
+ -5824,
+ -5611,
+ -6341,
+ -6061,
+ -6794,
+ -5789,
+ -6617,
+ -5420,
+ -6261,
+ -5708,
+ -6408,
+ -6242,
+ -6895,
+ -6616,
+ -7394,
+ -6595,
+ -7442,
+ -6099,
+ -6878,
+ -5702,
+ -6418,
+ -5664,
+ -6397,
+ -5584,
+ -6317,
+ -5294,
+ -5947,
+ -4813,
+ -5409,
+ -4012,
+ -4621,
+ -2863,
+ -3433,
+ -1801,
+ -2288,
+ -1324,
+ -1860,
+ -983,
+ -1638,
+ 10,
+ -589,
+ 1338,
+ 913,
+ 2143,
+ 1753,
+ 2267,
+ 1770,
+ 2175,
+ 1634,
+ 2401,
+ 1910,
+ 2926,
+ 2460,
+ 3120,
+ 2665,
+ 2737,
+ 2345,
+ 2295,
+ 1899,
+ 2210,
+ 1715,
+ 2313,
+ 1862,
+ 2373,
+ 2082,
+ 2456,
+ 2174,
+ 2503,
+ 2170,
+ 2341,
+ 2098,
+ 2315,
+ 2116,
+ 2656,
+ 2417,
+ 2888,
+ 2746,
+ 2807,
+ 2757,
+ 2598,
+ 2466,
+ 2226,
+ 2099,
+ 1984,
+ 1975,
+ 2147,
+ 2117,
+ 2085,
+ 2061,
+ 1318,
+ 1475,
+ 445,
+ 628,
+ 50,
+ 81,
+ -65,
+ -24,
+ -279,
+ -173,
+ -797,
+ -790,
+ -1602,
+ -1612,
+ -2197,
+ -2015,
+ -2229,
+ -1955,
+ -2235,
+ -2051,
+ -2614,
+ -2441,
+ -2946,
+ -2653,
+ -2925,
+ -2583,
+ -2701,
+ -2431,
+ -2583,
+ -2300,
+ -2737,
+ -2291,
+ -2796,
+ -2256,
+ -2434,
+ -1926,
+ -2002,
+ -1468,
+ -1745,
+ -1147,
+ -1362,
+ -842,
+ -864,
+ -413,
+ -645,
+ -86,
+ -595,
+ 4,
+ -338,
+ 126,
+ -97,
+ 364,
+ -124,
+ 478,
+ -112,
+ 436,
+ -50,
+ 299,
+ -241,
+ 110,
+ -452,
+ 52,
+ -379,
+ 161,
+ -306,
+ 172,
+ -575,
+ -145,
+ -1076,
+ -661,
+ -1391,
+ -938,
+ -1311,
+ -817,
+ -1118,
+ -683,
+ -1266,
+ -891,
+ -1754,
+ -1333,
+ -2110,
+ -1663,
+ -2085,
+ -1689,
+ -1927,
+ -1568,
+ -1997,
+ -1712,
+ -2420,
+ -2254,
+ -2975,
+ -2784,
+ -3386,
+ -3085,
+ -3612,
+ -3368,
+ -3703,
+ -3582,
+ -3855,
+ -3718,
+ -4206,
+ -4054,
+ -4422,
+ -4358,
+ -4265,
+ -4232,
+ -3930,
+ -3861,
+ -3725,
+ -3655,
+ -3888,
+ -3804,
+ -4036,
+ -3916,
+ -3628,
+ -3549,
+ -3143,
+ -3111,
+ -2983,
+ -2894,
+ -2696,
+ -2538,
+ -2266,
+ -2112,
+ -1998,
+ -1828,
+ -1686,
+ -1467,
+ -1195,
+ -1014,
+ -784,
+ -669,
+ -496,
+ -324,
+ -56,
+ 189,
+ 467,
+ 660,
+ 718,
+ 887,
+ 872,
+ 1162,
+ 1309,
+ 1664,
+ 1995,
+ 2246,
+ 2641,
+ 2824,
+ 2832,
+ 3075,
+ 2641,
+ 2889,
+ 2723,
+ 2878,
+ 3128,
+ 3302,
+ 3429,
+ 3751,
+ 3556,
+ 3915,
+ 3535,
+ 3793,
+ 3505,
+ 3726,
+ 3805,
+ 4005,
+ 4368,
+ 4446,
+ 4632,
+ 4699,
+ 4366,
+ 4590,
+ 4136,
+ 4371,
+ 4317,
+ 4431,
+ 4437,
+ 4601,
+ 4337,
+ 4582,
+ 4278,
+ 4392,
+ 4063,
+ 4078,
+ 3715,
+ 3817,
+ 3624,
+ 3741,
+ 3588,
+ 3613,
+ 3332,
+ 3372,
+ 3158,
+ 3260,
+ 3177,
+ 3226,
+ 3117,
+ 3057,
+ 3064,
+ 2942,
+ 3273,
+ 3171,
+ 3504,
+ 3486,
+ 3448,
+ 3462,
+ 3260,
+ 3175,
+ 3256,
+ 3074,
+ 3449,
+ 3296,
+ 3425,
+ 3377,
+ 3020,
+ 3006,
+ 2768,
+ 2681,
+ 2918,
+ 2798,
+ 2936,
+ 2892,
+ 2520,
+ 2494,
+ 2131,
+ 1983,
+ 2251,
+ 2037,
+ 2707,
+ 2517,
+ 3025,
+ 2786,
+ 2958,
+ 2677,
+ 2592,
+ 2364,
+ 2474,
+ 2197,
+ 2900,
+ 2471,
+ 3209,
+ 2789,
+ 3002,
+ 2636,
+ 2632,
+ 2128,
+ 2182,
+ 1593,
+ 1710,
+ 1272,
+ 1516,
+ 1158,
+ 1499,
+ 1016,
+ 1330,
+ 803,
+ 898,
+ 455,
+ 366,
+ -122,
+ 155,
+ -511,
+ 393,
+ -336,
+ 544,
+ -69,
+ 128,
+ -386,
-515,
-1100,
-795,
@@ -59,13 +1410,6 @@ exports[`Audio samples from MP3 should produce identical s16 output on Chrome an
-1386,
-793,
-1558,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-1-sum 1`] = `184794`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-2-first10 1`] = `
-[
-1449,
-2252,
-2129,
@@ -76,246 +1420,1787 @@ exports[`Audio samples from MP3 should produce identical s16 output on Chrome an
-2629,
-1934,
-2760,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-2-last10 1`] = `
-[
- 29,
+ -2154,
+ -2946,
+ -2397,
+ -3077,
+ -2509,
+ -3208,
+ -2529,
+ -3298,
+ -2586,
+ -3314,
+ -2687,
+ -3337,
+ -2834,
+ -3487,
+ -2997,
+ -3687,
+ -3232,
+ -3937,
+ -3547,
+ -4302,
+ -3632,
+ -4415,
+ -3488,
+ -4124,
+ -3480,
+ -3921,
+ -3590,
+ -4067,
+ -3582,
+ -4198,
+ -3255,
+ -3829,
+ -2678,
+ -3136,
+ -2386,
+ -2797,
+ -2507,
+ -2815,
+ -2542,
+ -2750,
+ -2323,
+ -2595,
+ -2070,
+ -2401,
+ -1933,
+ -2196,
+ -1907,
+ -2130,
+ -1942,
+ -2169,
+ -2017,
+ -2220,
+ -1977,
+ -2192,
+ -1750,
+ -1989,
+ -1525,
+ -1745,
+ -1341,
+ -1605,
+ -1187,
+ -1522,
+ -1148,
+ -1413,
+ -1120,
+ -1272,
+ -999,
+ -1149,
+ -832,
+ -1014,
+ -702,
+ -845,
+ -735,
+ -775,
+ -887,
+ -844,
+ -949,
+ -959,
+ -877,
+ -994,
+ -862,
+ -930,
+ -1026,
+ -936,
+ -1112,
+ -974,
+ -988,
+ -892,
+ -952,
+ -878,
+ -1020,
+ -996,
+ -951,
+ -1005,
+ -789,
+ -842,
+ -730,
+ -726,
+ -877,
+ -870,
+ -1016,
+ -995,
+ -866,
+ -751,
+ -653,
+ -513,
+ -611,
+ -534,
+ -660,
+ -521,
+ -736,
+ -468,
+ -647,
+ -397,
+ -363,
+ -126,
+ -155,
+ 220,
+ -82,
+ 355,
+ -114,
+ 263,
+ -109,
+ 315,
+ 172,
+ 671,
+ 440,
+ 876,
+ 439,
+ 817,
+ 424,
+ 855,
+ 424,
+ 928,
+ 374,
+ 938,
+ 403,
+ 991,
+ 420,
+ 933,
+ 254,
+ 722,
+ 31,
+ 634,
+ -43,
+ 736,
+ -97,
+ 690,
+ -332,
+ 378,
+ -439,
+ 282,
+ -283,
+ 494,
+ -301,
+ 469,
+ -536,
+ 202,
+ -630,
+ 91,
+ -524,
+ 176,
+ -386,
+ 312,
+ -476,
+ 219,
+ -814,
+ -163,
+ -1015,
+ -356,
+ -980,
+ -272,
+ -1007,
+ -355,
+ -1176,
+ -574,
+ -1329,
+ -584,
+ -1391,
+ -483,
+ -1414,
+ -516,
+ -1403,
+ -584,
+ -1265,
+ -470,
+ -1049,
+ -257,
+ -1070,
+ -304,
+ -1371,
+ -620,
+ -1436,
+ -588,
+ -1031,
+ -82,
+ -667,
+ 100,
+ -872,
+ -436,
+ -1559,
+ -1150,
+ -1903,
+ -1248,
+ -1245,
+ -472,
+ -450,
+ 253,
+ -733,
+ -89,
+ -1526,
+ -904,
+ -1540,
+ -956,
+ -735,
+ -142,
+ 6,
+ 702,
+ 55,
+ 786,
+ -439,
+ 115,
+ -753,
+ -355,
+ -503,
+ -4,
+ -161,
452,
- 239,
- 640,
- 151,
+ -158,
+ 357,
+ -347,
+ 33,
+ -647,
+ -321,
+ -767,
+ -521,
+ -305,
+ -129,
+ 61,
+ 310,
+ -303,
+ 92,
+ -573,
+ -217,
+ -46,
+ 28,
+ 753,
+ 683,
+ 938,
+ 1113,
+ 332,
+ 747,
+ -235,
+ 58,
+ 26,
+ 80,
+ 949,
+ 844,
+ 1455,
+ 1186,
+ 714,
+ 422,
+ -232,
+ -305,
+ 45,
+ 109,
+ 980,
+ 955,
+ 1397,
+ 1284,
+ 1135,
+ 988,
+ 740,
+ 539,
+ 853,
+ 675,
+ 1419,
+ 1310,
+ 1823,
+ 1670,
+ 1666,
+ 1484,
+ 1273,
+ 1229,
+ 1472,
+ 1480,
+ 1841,
+ 1656,
+ 1505,
+ 1168,
+ 1322,
+ 979,
+ 1791,
+ 1370,
+ 2035,
+ 1554,
+ 1860,
+ 1546,
+ 1499,
+ 1343,
+ 1295,
+ 1050,
+ 1656,
+ 1293,
+ 2026,
+ 1720,
+ 1959,
+ 1774,
+ 1780,
+ 1639,
+ 1539,
+ 1408,
+ 1323,
+ 1216,
+ 1575,
+ 1411,
+ 2351,
+ 2016,
+ 2489,
+ 2103,
+ 1149,
+ 925,
+ 365,
+ 238,
+ 1670,
+ 1498,
+ 2830,
+ 2645,
+ 2361,
+ 2094,
+ 1588,
+ 1108,
+ 1396,
+ 865,
+ 1759,
+ 1428,
+ 2442,
+ 2307,
+ 2769,
+ 2723,
+ 2333,
+ 2252,
+ 1602,
+ 1371,
+ 1339,
+ 1028,
+ 1423,
+ 1181,
+ 1403,
+ 1239,
+ 1425,
+ 1344,
+ 1163,
+ 1130,
+ 533,
+ 296,
+ 579,
+ 29,
+ 1165,
+ 647,
+ 1139,
+ 957,
+ 601,
+ 579,
+ 387,
+ 193,
+ 908,
+ 467,
+ 1530,
+ 1061,
+ 1099,
+ 867,
+ -33,
+ -30,
+ -326,
+ -397,
+ 541,
+ 214,
+ 1205,
+ 802,
+ 522,
+ 210,
+ -627,
+ -911,
+ -698,
+ -941,
+ 83,
+ -38,
+ 369,
+ 196,
+ -330,
+ -778,
+ -1073,
+ -1694,
+ -786,
+ -1352,
+ 13,
+ -380,
+ 44,
+ -108,
+ -662,
+ -692,
+ -893,
+ -1088,
+ -148,
+ -531,
+ 481,
+ 167,
+ 135,
+ -38,
+ -481,
+ -668,
+ -614,
+ -902,
+ -228,
+ -605,
+ 275,
+ -166,
+ 40,
+ -379,
+ -863,
+ -1151,
+ -1193,
+ -1367,
+ -628,
+ -840,
+ -98,
+ -461,
+ -238,
+ -704,
+ -677,
+ -1153,
+ -794,
+ -1261,
+ -692,
+ -1100,
+ -708,
+ -909,
+ -774,
+ -776,
+ -775,
+ -866,
+ -755,
+ -1065,
+ -833,
+ -1121,
+ -889,
+ -1056,
+ -626,
+ -879,
+ -417,
+ -713,
+ -787,
+ -893,
+ -1237,
+ -1286,
+ -1040,
+ -1215,
+ -489,
+ -553,
+ -358,
+ -220,
+ -646,
+ -648,
+ -766,
+ -1004,
+ -612,
+ -821,
+ -414,
+ -475,
+ -454,
+ -380,
+ -926,
+ -734,
+ -1208,
+ -1105,
+ -908,
+ -1023,
+ -870,
+ -949,
+ -1474,
+ -1322,
+ -2052,
+ -1819,
+ -2014,
+ -1784,
+ -1273,
+ -1001,
+ -704,
+ -487,
+ -1154,
+ -989,
+ -1754,
+ -1417,
+ -1363,
+ -870,
+ -446,
+ -12,
+ -112,
+ 336,
+ -642,
+ -98,
+ -1257,
+ -825,
+ -1097,
+ -791,
+ -457,
+ -31,
+ -313,
+ 175,
+ -901,
+ -512,
+ -1493,
+ -1061,
+ -1391,
+ -874,
+ -915,
+ -489,
+ -967,
+ -547,
+ -1480,
+ -873,
+ -1556,
+ -890,
+ -1193,
+ -629,
+ -1016,
+ -467,
+ -1057,
+ -457,
+ -1196,
+ -587,
+ -1243,
+ -586,
+ -794,
+ -37,
+ -306,
+ 457,
+ -510,
+ 135,
+ -894,
+ -321,
+ -789,
+ -170,
+ -469,
+ 163,
+ -329,
+ 229,
+ -523,
+ 47,
+ -957,
+ -258,
+ -1144,
+ -389,
+ -962,
+ -275,
+ -900,
+ -297,
+ -1056,
+ -505,
+ -1007,
+ -406,
+ -723,
+ 64,
+ -695,
+ 158,
+ -998,
+ -356,
+ -1030,
+ -515,
+ -576,
+ 114,
+ -194,
+ 553,
+ -275,
+ 243,
+ -661,
+ -214,
+ -898,
+ -284,
+ -540,
+ 109,
+ 68,
+ 621,
+ 73,
+ 555,
+ -364,
+ -30,
+ -422,
+ -171,
+ -88,
+ 350,
+ 176,
+ 715,
+ 280,
587,
- -95,
+ 278,
+ 424,
+ 186,
+ 415,
+ 83,
+ 376,
+ 52,
+ 348,
+ 185,
+ 485,
+ 460,
+ 654,
+ 511,
+ 564,
+ 260,
+ 287,
+ 213,
+ 245,
+ 474,
+ 506,
+ 617,
+ 725,
+ 574,
+ 701,
+ 511,
+ 485,
+ 558,
+ 421,
+ 771,
+ 680,
+ 833,
+ 740,
+ 614,
+ 447,
+ 652,
+ 511,
+ 1020,
+ 913,
+ 966,
+ 780,
+ 396,
+ 202,
+ 260,
+ 165,
+ 862,
+ 758,
+ 1357,
+ 1184,
+ 1216,
+ 1066,
+ 783,
+ 622,
+ 634,
+ 422,
+ 1028,
+ 953,
+ 1433,
+ 1551,
+ 1200,
+ 1284,
+ 788,
+ 736,
+ 870,
+ 789,
+ 1034,
+ 970,
+ 731,
+ 697,
+ 420,
+ 440,
+ 641,
+ 655,
+ 872,
+ 822,
+ 517,
+ 444,
+ -8,
+ -104,
+ -108,
+ -259,
+ 242,
+ 139,
+ 529,
+ 563,
+ 45,
+ 59,
+ -822,
+ -987,
+ -783,
+ -1008,
+ 33,
+ -93,
+ 286,
+ 232,
+ -212,
+ -250,
+ -574,
+ -640,
+ -446,
+ -650,
+ -139,
+ -445,
+ 67,
+ -158,
+ 47,
+ -105,
+ -154,
+ -372,
+ -271,
+ -532,
+ -291,
+ -549,
+ -496,
+ -811,
+ -668,
+ -1010,
+ -342,
+ -606,
+ 28,
+ -199,
+ -302,
+ -594,
+ -873,
+ -1234,
+ -913,
+ -1277,
+ -628,
+ -931,
+ -302,
+ -522,
+ -53,
+ -252,
+ -297,
+ -594,
+ -648,
+ -1072,
+ -320,
+ -740,
+ 172,
+ -128,
+ 243,
+ 17,
+ 317,
+ 90,
+ 460,
+ 220,
+ 440,
+ 155,
+ 581,
+ 235,
+ 967,
+ 624,
+ 1144,
+ 819,
+ 951,
+ 602,
+ 705,
+ 370,
+ 691,
+ 396,
+ 803,
+ 455,
+ 778,
+ 340,
+ 627,
+ 191,
+ 567,
+ 166,
+ 636,
+ 223,
+ 735,
+ 316,
+ 742,
+ 370,
+ 579,
+ 238,
+ 623,
+ 271,
+ 1146,
+ 828,
+ 1381,
+ 1139,
+ 908,
+ 707,
+ 533,
374,
+ 660,
+ 587,
+ 1005,
+ 950,
+ 1212,
+ 1068,
+ 868,
+ 662,
+ 396,
+ 228,
+ 602,
+ 518,
+ 1047,
+ 1030,
+ 938,
+ 916,
+ 439,
+ 361,
+ 299,
+ 194,
+ 849,
+ 766,
+ 1277,
+ 1229,
+ 875,
+ 883,
+ 301,
+ 387,
+ 274,
+ 441,
+ 736,
+ 960,
+ 1204,
+ 1437,
+ 1044,
+ 1278,
+ 444,
+ 720,
+ 461,
+ 783,
+ 1328,
+ 1677,
+ 1930,
+ 2309,
+ 1483,
+ 1872,
+ 852,
+ 1207,
+ 999,
+ 1343,
+ 1456,
+ 1838,
+ 1565,
+ 1985,
+ 1195,
+ 1627,
+ 455,
+ 871,
+ 122,
+ 513,
+ 598,
+ 983,
+ 1001,
+ 1367,
+ 744,
+ 1078,
+ 269,
+ 624,
+ 166,
+ 572,
+ 542,
+ 967,
+ 833,
+ 1264,
+ 616,
+ 1043,
+ 360,
+ 742,
+ 521,
+ 879,
+ 750,
+ 1152,
+ 553,
+ 1006,
+ 145,
+ 617,
+ 141,
+ 626,
+ 579,
+ 1074,
+ 767,
+ 1238,
+ 185,
+ 595,
+ -595,
+ -259,
+ -484,
+ -193,
+ 314,
+ 606,
+ 489,
+ 806,
-247,
- 214,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-2-sum 1`] = `-4022`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-3-first10 1`] = `
-[
- -402,
- 68,
- -419,
- 58,
- -412,
- 35,
- -911,
- -460,
- -1605,
- -1107,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-3-last10 1`] = `
-[
- 144,
- -354,
- 352,
- -168,
- 810,
- 264,
- 1096,
+ 38,
+ -930,
+ -752,
+ -845,
+ -741,
+ -193,
+ -69,
+ 209,
+ 376,
+ -205,
+ -33,
+ -893,
+ -741,
+ -880,
+ -768,
+ -338,
+ -239,
+ -114,
+ 31,
+ -174,
+ -5,
+ -208,
+ -89,
+ -424,
+ -351,
+ -605,
+ -555,
+ -363,
+ -335,
+ -10,
+ 16,
+ 91,
+ 113,
+ -127,
+ -165,
+ -668,
+ -780,
+ -999,
+ -1142,
+ -500,
+ -625,
+ 239,
+ 163,
+ 82,
+ 25,
+ -759,
+ -881,
+ -1204,
+ -1415,
+ -1006,
+ -1233,
+ -583,
+ -758,
+ -457,
+ -587,
+ -980,
+ -1130,
+ -1593,
+ -1810,
+ -1584,
+ -1866,
+ -1278,
+ -1610,
+ -1240,
+ -1598,
+ -1486,
+ -1820,
+ -1593,
+ -1906,
+ -1277,
+ -1618,
+ -1088,
+ -1451,
+ -1406,
+ -1755,
+ -1562,
+ -1914,
+ -1274,
+ -1648,
+ -1075,
+ -1454,
+ -1235,
+ -1618,
+ -1725,
+ -2123,
+ -2206,
+ -2597,
+ -2145,
+ -2515,
+ -1935,
+ -2323,
+ -2305,
+ -2760,
+ -2727,
+ -3239,
+ -2552,
+ -3088,
+ -2244,
+ -2788,
+ -2051,
+ -2578,
+ -1902,
+ -2397,
+ -2029,
+ -2520,
+ -1904,
+ -2375,
+ -1144,
+ -1556,
+ -830,
+ -1241,
+ -1312,
+ -1755,
+ -1472,
+ -1849,
+ -920,
+ -1197,
+ -333,
+ -609,
+ -261,
+ -566,
+ -556,
+ -856,
+ -632,
+ -938,
+ -172,
+ -456,
+ 500,
+ 273,
+ 525,
+ 257,
+ -231,
+ -623,
+ -554,
+ -980,
+ -4,
+ -370,
505,
- 877,
+ 179,
+ 538,
+ 210,
+ 112,
+ -237,
+ -473,
+ -872,
+ -357,
+ -782,
+ 445,
+ 69,
+ 740,
+ 396,
+ 49,
+ -355,
+ -725,
+ -1163,
+ -939,
+ -1322,
+ -1122,
+ -1487,
+ -1425,
+ -1826,
+ -1439,
+ -1832,
+ -1608,
+ -2020,
+ -2231,
+ -2750,
+ -2839,
+ -3405,
+ -3248,
+ -3775,
+ -3218,
+ -3758,
+ -2880,
+ -3455,
+ -3154,
+ -3723,
+ -3941,
+ -4563,
+ -4329,
+ -5056,
+ -4192,
+ -4939,
+ -3805,
+ -4523,
+ -3595,
+ -4325,
+ -3854,
+ -4574,
+ -4159,
+ -4856,
+ -4337,
+ -5085,
+ -4559,
+ -5344,
+ -4362,
+ -5044,
+ -3638,
+ -4227,
+ -3422,
+ -4063,
+ -4095,
+ -4777,
+ -4537,
+ -5150,
+ -4028,
+ -4556,
+ -3185,
+ -3618,
+ -2678,
+ -3000,
+ -2641,
+ -2989,
+ -2879,
+ -3346,
+ -2765,
+ -3178,
+ -2047,
+ -2304,
+ -1616,
+ -1865,
+ -2056,
+ -2338,
+ -2499,
+ -2734,
+ -2347,
+ -2590,
+ -2365,
+ -2626,
+ -2936,
+ -3091,
+ -3409,
+ -3496,
+ -3605,
+ -3733,
+ -3775,
+ -3828,
+ -3527,
+ -3433,
+ -2541,
+ -2460,
+ -1179,
+ -1103,
+ 751,
+ 1004,
+ 3414,
+ 3772,
+ 5196,
+ 5483,
+ 5699,
+ 6006,
+ 7583,
+ 8017,
+ 10929,
+ 11423,
+ 12564,
+ 13148,
+ 12031,
+ 12734,
+ 10429,
+ 11035,
+ 8576,
+ 9056,
+ 9313,
+ 10005,
+ 12242,
+ 13204,
+ 11583,
+ 12511,
+ 7097,
+ 7931,
+ 5501,
+ 6365,
+ 8709,
+ 9566,
+ 12396,
+ 13313,
+ 13439,
+ 14562,
+ 11639,
+ 12760,
+ 9448,
+ 10369,
+ 10752,
+ 11737,
+ 14401,
+ 15602,
+ 14560,
+ 15718,
+ 10983,
+ 12073,
+ 9000,
+ 10238,
+ 9662,
+ 10956,
+ 9772,
+ 11007,
+ 8085,
+ 9425,
+ 6093,
+ 7502,
+ 6062,
+ 7323,
+ 8052,
+ 9314,
+ 8662,
+ 10078,
+ 6032,
+ 7329,
+ 3484,
+ 4587,
+ 4252,
+ 5486,
+ 6130,
+ 7467,
+ 5128,
+ 6267,
+ 1263,
+ 2296,
+ -2067,
+ -976,
+ -2272,
+ -1245,
+ -650,
+ 397,
+ -996,
242,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-3-sum 1`] = `-55271`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-4-first10 1`] = `
-[
- -104,
- -766,
- -1564,
- -2251,
- -2308,
- -3028,
- -1853,
- -2605,
- -1386,
- -2163,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-4-last10 1`] = `
-[
- -808,
- -660,
- -1141,
- -983,
- -822,
+ -3727,
+ -2596,
+ -4914,
+ -4106,
+ -2543,
+ -1689,
+ 839,
+ 1906,
+ 2061,
+ 3034,
+ 1204,
+ 2071,
+ 938,
+ 1873,
+ 2522,
+ 3354,
+ 4316,
+ 5004,
+ 4155,
+ 4981,
+ 2089,
+ 2963,
+ 486,
+ 1136,
+ 365,
+ 1005,
+ -36,
+ 772,
+ -1533,
+ -872,
+ -2974,
+ -2516,
+ -3292,
+ -2732,
+ -2303,
+ -1725,
+ -1498,
+ -1103,
+ -2346,
+ -1915,
+ -3323,
+ -2787,
+ -2344,
+ -1958,
+ -350,
+ -35,
+ 198,
+ 630,
+ -1202,
+ -908,
+ -2568,
+ -2506,
+ -2243,
+ -2039,
+ -936,
+ -559,
+ -763,
+ -544,
+ -2825,
+ -2734,
+ -5251,
+ -5143,
+ -5362,
+ -5383,
+ -3856,
+ -3926,
+ -3474,
+ -3316,
+ -4886,
+ -4679,
+ -6600,
+ -6606,
+ -7188,
+ -7200,
+ -6593,
+ -6489,
+ -5854,
+ -5873,
+ -5944,
+ -6071,
+ -6778,
+ -6812,
+ -7299,
+ -7371,
+ -7160,
+ -7360,
+ -6978,
+ -7090,
+ -6504,
+ -6545,
+ -5495,
+ -5696,
+ -5156,
+ -5421,
+ -5835,
+ -6011,
+ -5973,
+ -6200,
+ -4667,
+ -4952,
+ -2818,
+ -2961,
+ -1606,
+ -1699,
+ -1417,
+ -1672,
+ -1758,
+ -2072,
+ -1356,
+ -1625,
+ 272,
+ -56,
+ 1527,
+ 1177,
+ 1222,
+ 970,
+ 355,
+ 71,
+ -20,
+ -437,
+ 204,
+ -186,
+ 727,
+ 414,
+ 890,
+ 514,
+ 603,
+ 175,
+ 533,
+ 137,
+ 967,
+ 531,
+ 1693,
+ 1206,
+ 2359,
+ 1947,
+ 2741,
+ 2392,
+ 2989,
+ 2576,
+ 3256,
+ 2784,
+ 3539,
+ 3064,
+ 3669,
+ 3166,
+ 3346,
+ 2838,
+ 2705,
+ 2256,
+ 2091,
+ 1639,
+ 1371,
+ 821,
+ 519,
+ -83,
+ 85,
+ -491,
+ 248,
+ -324,
+ 271,
+ -327,
+ -358,
+ -957,
+ -1023,
+ -1621,
+ -916,
+ -1514,
+ -144,
+ -698,
+ 362,
+ -157,
+ -31,
+ -606,
+ -625,
+ -1275,
+ -490,
+ -1113,
+ 19,
+ -519,
+ 99,
+ -419,
+ -304,
+ -842,
+ -587,
+ -1123,
+ -317,
+ -867,
+ 75,
+ -502,
+ -50,
+ -605,
+ -464,
+ -975,
+ -443,
+ -927,
+ -1,
+ -439,
+ 5,
+ -401,
+ -505,
+ -982,
+ -618,
+ -1154,
+ -239,
+ -687,
+ 19,
+ -319,
+ -123,
+ -472,
+ -701,
+ -1078,
+ -1074,
+ -1408,
+ -640,
+ -948,
+ -70,
+ -390,
+ -49,
+ -374,
+ -493,
+ -848,
+ -1018,
+ -1393,
+ -999,
+ -1294,
+ -615,
+ -823,
+ -790,
+ -1031,
+ -1508,
+ -1807,
+ -2115,
+ -2419,
+ -2305,
+ -2621,
+ -2255,
+ -2557,
+ -2524,
+ -2722,
+ -3199,
+ -3340,
+ -3876,
+ -4074,
+ -4264,
+ -4494,
+ -4173,
+ -4368,
+ -4020,
+ -4223,
+ -4425,
+ -4639,
+ -4969,
+ -5127,
+ -5058,
+ -5176,
+ -4884,
+ -4997,
+ -4852,
+ -4934,
+ -5020,
+ -5089,
+ -4885,
+ -4985,
+ -4247,
+ -4318,
+ -3909,
+ -3914,
+ -4472,
+ -4497,
+ -5299,
+ -5354,
+ -5177,
+ -5173,
+ -4004,
+ -3955,
+ -3271,
+ -3261,
+ -3943,
+ -3982,
+ -5151,
+ -5228,
+ -5457,
+ -5554,
+ -4410,
+ -4452,
+ -3239,
+ -3217,
+ -3334,
+ -3351,
+ -4221,
+ -4295,
+ -4580,
+ -4623,
+ -3884,
+ -3889,
+ -2676,
+ -2676,
+ -2188,
+ -2151,
+ -2607,
+ -2541,
+ -2751,
+ -2715,
+ -2137,
+ -2098,
+ -1347,
+ -1271,
+ -887,
+ -849,
-674,
- -450,
- -318,
- -739,
- -623,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-4-sum 1`] = `29618`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-5-first10 1`] = `
-[
- -1351,
+ -696,
+ -468,
+ -477,
+ -476,
+ -484,
+ -571,
+ -631,
+ -342,
+ -415,
+ -206,
+ -258,
+ -202,
+ -263,
+ 59,
+ 1,
+ -89,
+ -109,
+ -699,
+ -706,
+ -660,
+ -640,
+ 260,
+ 368,
+ 1441,
+ 1597,
+ 2110,
+ 2251,
+ 2055,
+ 2218,
+ 2168,
+ 2370,
+ 2977,
+ 3165,
+ 4242,
+ 4432,
+ 5498,
+ 5740,
+ 5871,
+ 6118,
+ 5447,
+ 5675,
+ 5278,
+ 5544,
+ 5574,
+ 5886,
+ 6154,
+ 6471,
+ 6491,
+ 6846,
+ 5987,
+ 6407,
+ 5505,
+ 5954,
+ 5600,
+ 6083,
+ 5485,
+ 6019,
+ 5206,
+ 5742,
+ 5229,
+ 5743,
+ 5367,
+ 5910,
+ 5313,
+ 5888,
+ 4805,
+ 5359,
+ 4249,
+ 4790,
+ 4303,
+ 4848,
+ 4744,
+ 5280,
+ 5004,
+ 5558,
+ 4522,
+ 5121,
+ 3536,
+ 4141,
+ 3342,
+ 3931,
+ 4041,
+ 4667,
+ 4599,
+ 5268,
+ 4475,
+ 5151,
+ 3468,
+ 4165,
+ 2404,
+ 3122,
+ 2512,
+ 3202,
+ 3100,
+ 3765,
+ 2670,
+ 3348,
+ 1158,
+ 1821,
+ -81,
+ 544,
+ 17,
+ 651,
+ 426,
+ 1075,
+ -266,
+ 350,
-1261,
- -2024,
- -1977,
- -3314,
- -3322,
- -5005,
- -5067,
- -5783,
- -5890,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-5-last10 1`] = `
-[
- 14921,
- 13311,
- 13080,
- 11552,
- 12247,
- 10809,
- 12936,
- 11575,
- 13706,
- 12422,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-5-sum 1`] = `-87014`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-6-first10 1`] = `
-[
- 13593,
- 12389,
- 12470,
- 11329,
- 10323,
- 9243,
- 7674,
- 6675,
- 5618,
- 4712,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-6-last10 1`] = `
-[
- 10202,
- 10087,
- 8771,
- 8704,
- 6993,
- 7010,
- 7535,
- 7649,
- 9049,
- 9227,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-6-sum 1`] = `140323`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-7-first10 1`] = `
-[
- 8301,
- 8528,
- 4900,
- 5210,
- 2057,
- 2449,
- 1704,
- 2090,
- 1229,
- 1520,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-7-last10 1`] = `
-[
- 3407,
- 3507,
- 2608,
- 2859,
- 1579,
- 2207,
- 949,
- 1995,
- 703,
- 1945,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-7-sum 1`] = `-104504`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-8-first10 1`] = `
-[
- 763,
- 1813,
- 1299,
- 1865,
- 1900,
- 1992,
- 1928,
- 1803,
- 1667,
- 1599,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-8-last10 1`] = `
-[
- -5267,
- -5582,
- -4603,
- -4819,
- -3590,
- -3835,
- -2846,
- -3244,
- -2548,
- -3094,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-8-sum 1`] = `32453`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-9-first10 1`] = `
-[
- -2889,
- -3455,
- -3223,
- -3719,
- -2819,
- -3262,
- -2644,
- -3079,
- -3705,
- -4128,
-]
-`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-9-last10 1`] = `
-[
- -4728,
- -6248,
- -4051,
- -5481,
- -3687,
- -4959,
- -4434,
- -5413,
- -5342,
- -5825,
+ -657,
+ -1131,
+ -480,
+ -131,
+ 555,
+ 470,
+ 1150,
+ 272,
+ 945,
+ 2,
+ 666,
+ 160,
+ 824,
+ 752,
+ 1447,
+ 1345,
+ 2050,
+ 934,
+ 1580,
+ -345,
+ 244,
+ -1059,
+ -474,
+ -951,
+ -371,
+ -922,
+ -371,
+ -1380,
+ -841,
+ -2173,
+ -1641,
+ -2851,
+ -2349,
+ -2956,
+ -2463,
+ -2663,
+ -2148,
+ -2560,
+ -2044,
+ -2635,
+ -2139,
+ -2441,
+ -1936,
+ -2245,
+ -1735,
+ -2421,
+ -1956,
+ -2419,
+ -2005,
+ -1961,
+ -1562,
+ -1599,
+ -1222,
+ -1624,
+ -1301,
+ -1923,
+ -1655,
+ -2258,
+ -2043,
+ -2196,
+ -2027,
+ -1619,
+ -1465,
+ -1103,
+ -953,
+ -1262,
+ -1153,
+ -1846,
+ -1792,
+ -1940,
+ -1905,
+ -1291,
+ -1256,
+ -733,
+ -721,
+ -955,
+ -983,
+ -1565,
+ -1634,
+ -1663,
+ -1780,
+ -1071,
+ -1225,
+ -540,
+ -721,
+ -519,
+ -738,
+ -484,
+ -741,
+ 39,
+ -237,
+ 788,
+ 484,
+ 1173,
+ 829,
+ 1011,
+ 653,
+ 1081,
+ 725,
+ 1943,
+ 1572,
+ 2690,
+ 2309,
+ 2496,
+ 2116,
+ 1905,
+ 1507,
+ 1740,
+ 1311,
+ 2066,
+ 1636,
+ 2222,
+ 1789,
+ 1739,
+ 1267,
+ 986,
+ 482,
+ 548,
+ 31,
+ 734,
+ 194,
+ 1254,
+ 690,
+ 1354,
+ 785,
+ 1070,
+ 478,
+ 1078,
+ 461,
+ 1541,
+ 946,
+ 2159,
+ 1589,
+ 2419,
+ 1829,
+ 2086,
+ 1494,
+ 1656,
+ 1098,
+ 1694,
+ 1147,
+ 2231,
+ 1678,
+ 2568,
+ 2033,
+ 2123,
+ 1588,
+ 1665,
+ 1101,
+ 1977,
+ 1429,
]
`;
-
-exports[`Audio samples from MP3 should produce identical s16 output on Chrome and Firefox > sample-9-sum 1`] = `-378527`;
diff --git a/packages/media/src/test/audio-encoding.test.ts b/packages/media/src/test/audio-encoding.test.ts
index 50fd8e3017..c4dac0a6ca 100644
--- a/packages/media/src/test/audio-encoding.test.ts
+++ b/packages/media/src/test/audio-encoding.test.ts
@@ -1,65 +1,36 @@
-import {ALL_FORMATS, AudioSampleSink, Input, UrlSource} from 'mediabunny';
-import {expect, test} from 'vitest';
-import {convertAudioData} from '../convert-audiodata/convert-audiodata';
+import {assert, expect, test} from 'vitest';
+import {extractAudio} from '../audio-extraction/extract-audio';
+import {getMaxVideoCacheSize} from '../caches';
test('Audio samples from MP3 should produce identical s16 output on Chrome and Firefox', async () => {
- const input = new Input({
- source: new UrlSource('/sample-audio.mp3'),
- formats: ALL_FORMATS,
+ const a = await extractAudio({
+ src: '/sample-audio.mp3',
+ timeInSeconds: 0.03333333333333333,
+ logLevel: 'info',
+ loop: false,
+ trimAfter: undefined,
+ trimBefore: undefined,
+ playbackRate: 1,
+ fps: 30,
+ maxCacheSize: getMaxVideoCacheSize('info'),
+ durationInSeconds: 1 / 30,
+ audioStreamIndex: 0,
});
- const audioTrack = await input.getPrimaryAudioTrack();
- if (!audioTrack) {
- throw new Error('No audio track found');
+ if (a === 'cannot-decode') {
+ throw new Error('Cannot decode');
}
- const decodable = await audioTrack.canDecode();
- expect(decodable).toBe(true);
-
- const sink = new AudioSampleSink(audioTrack);
-
- let sampleIndex = 0;
-
- for await (const sample of sink.samples()) {
- const audioData = sample.toAudioData();
- const {numberOfChannels, numberOfFrames, format} = audioData;
-
- expect(numberOfFrames).toBe(1152);
- expect(numberOfChannels).toBe(2);
- expect(format === 'f32' || format === 's16-planar').toBe(true);
-
- const result = convertAudioData({
- audioData,
- trimStartInSeconds: 0,
- trimEndInSeconds: 0,
- playbackRate: 1,
- audioDataTimestamp: audioData.timestamp / 1_000_000,
- isLast: false,
- });
-
- expect(result.numberOfFrames).toBe(numberOfFrames);
- expect(result.data.length).toBe(numberOfFrames * 2);
-
- const {data} = result;
- let sum = 0;
- for (let i = 0; i < data.length; i++) {
- sum += data[i];
- }
-
- const first10 = Array.from(data.slice(0, 10));
- const last10 = Array.from(data.slice(-10));
-
- expect(first10).toMatchSnapshot(`sample-${sampleIndex}-first10`);
- expect(last10).toMatchSnapshot(`sample-${sampleIndex}-last10`);
- expect(sum).toMatchSnapshot(`sample-${sampleIndex}-sum`);
-
- audioData.close();
- sampleIndex++;
+ if (a === 'unknown-container-format') {
+ throw new Error('Unknown container format');
+ }
- if (sampleIndex >= 10) {
- break;
- }
+ if (a === 'network-error') {
+ throw new Error('Network error');
}
- expect(sampleIndex).toBe(10);
+ assert(a);
+ assert(a.data);
+
+ expect(Array.from(a.data.data)).toMatchSnapshot('audio-encoding');
});