sf2-json 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/sf2-json.js +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sf2-json",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "SF2 to JSON Converter for WebAudioFonts",
5
5
  "keywords": [
6
6
  "sf2",
package/src/sf2-json.js CHANGED
@@ -17,6 +17,7 @@ const require = createRequire(import.meta.url);
17
17
  const ffmpegPath = require('ffmpeg-static');
18
18
 
19
19
 
20
+ const MAX_NORMALIZE_FACTOR = 1.5;
20
21
  const RESAMPLE_RATE = 48000;
21
22
 
22
23
  const GM_CATEGORIES = [
@@ -62,7 +63,7 @@ const GM_INSTRUMENTS = [
62
63
  ];
63
64
 
64
65
 
65
- function encodeOpus(wavBuffer, bitrate = 128, sampleRate = 32000) {
66
+ function encodeOpus(wavBuffer, bitrate = 96, sampleRate = 32000) {
66
67
  const result = spawnSync(ffmpegPath, [
67
68
  '-hide_banner',
68
69
  '-loglevel', 'error',
@@ -128,7 +129,7 @@ function normalizeBuffer(buffer, targetPeak = 0.9) {
128
129
  }
129
130
  if (peak === 0) return buffer;
130
131
  const targetPeakInt = targetPeak * 32767;
131
- const factor = Math.min(targetPeakInt / peak, 3.0);
132
+ const factor = Math.min(targetPeakInt / peak, MAX_NORMALIZE_FACTOR);
132
133
  if (factor <= 1.0) return buffer;
133
134
  for (let i = 0; i < samples.length; i++) {
134
135
  samples[i] = Math.round(samples[i] * factor);