spessasynth_lib 3.20.23 → 3.20.24

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.
@@ -13,10 +13,11 @@ export class DLSZone extends BasicInstrumentZone {
13
13
  * @param sampleKey {number}
14
14
  * @param sample {BasicSample}
15
15
  * @param sampleID {number}
16
+ * @param samplePitchCorrection {number} cents
16
17
  */
17
18
  setWavesample(attenuationCb: number, loopingMode: number, loop: {
18
19
  start: number;
19
20
  end: number;
20
- }, sampleKey: number, sample: BasicSample, sampleID: number): void;
21
+ }, sampleKey: number, sample: BasicSample, sampleID: number, samplePitchCorrection: number): void;
21
22
  }
22
23
  import { BasicInstrumentZone } from '../basic_soundfont/basic_zones.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.20.23",
3
+ "version": "3.20.24",
4
4
  "description": "MIDI and SoundFont2 or DLS Synthesizer library with no compromises",
5
5
  "browser": "index.js",
6
6
  "types": "@types/index.d.ts",
@@ -22,6 +22,7 @@ export class DLSZone extends BasicInstrumentZone
22
22
  * @param sampleKey {number}
23
23
  * @param sample {BasicSample}
24
24
  * @param sampleID {number}
25
+ * @param samplePitchCorrection {number} cents
25
26
  */
26
27
  setWavesample(
27
28
  attenuationCb,
@@ -30,6 +31,7 @@ export class DLSZone extends BasicInstrumentZone
30
31
  sampleKey,
31
32
  sample,
32
33
  sampleID,
34
+ samplePitchCorrection,
33
35
  )
34
36
  {
35
37
  if(loopingMode !== 0)
@@ -39,6 +41,18 @@ export class DLSZone extends BasicInstrumentZone
39
41
  this.generators.push(new Generator(generatorTypes.initialAttenuation, attenuationCb));
40
42
  this.isGlobal = false;
41
43
 
44
+ // correct tuning if needed
45
+ const coarseTune = Math.trunc(samplePitchCorrection / 100);
46
+ if(coarseTune !== 0)
47
+ {
48
+ this.generators.push(new Generator(generatorTypes.coarseTune, coarseTune));
49
+ }
50
+ const fineTune = samplePitchCorrection - (coarseTune * 100);
51
+ if(fineTune !== 0)
52
+ {
53
+ this.generators.push(new Generator(generatorTypes.fineTune, fineTune));
54
+ }
55
+
42
56
  // correct loop if needed
43
57
  const diffStart = loop.start - (sample.sampleLoopStartIndex / 2);
44
58
  const diffEnd = loop.end - (sample.sampleLoopEndIndex / 2);
@@ -1,4 +1,4 @@
1
- import { readLittleEndian } from '../../utils/byte_functions/little_endian.js'
1
+ import { readLittleEndian, signedInt16 } from '../../utils/byte_functions/little_endian.js'
2
2
  import { findRIFFListType, readRIFFChunk } from '../basic_soundfont/riff_chunk.js'
3
3
  import { Generator, generatorTypes } from '../read_sf2/generators.js'
4
4
  import { DLSZone } from './dls_zone.js'
@@ -57,8 +57,12 @@ export function readRegion(chunk)
57
57
  // cbSize
58
58
  readLittleEndian(waveSampleChunk.chunkData, 4);
59
59
  const originalKey = readLittleEndian(waveSampleChunk.chunkData, 2);
60
- // pitch correction is read from the wave wsmpl chunk
61
- readLittleEndian(waveSampleChunk.chunkData, 2);
60
+
61
+ // sFineTune
62
+ const pitchCorrection = signedInt16(
63
+ waveSampleChunk.chunkData[waveSampleChunk.chunkData.currentIndex++],
64
+ waveSampleChunk.chunkData[waveSampleChunk.chunkData.currentIndex++]
65
+ );
62
66
 
63
67
  // gain correction: Each unit of gain represents 1/655360 dB
64
68
  const gainCorrection = readLittleEndian(waveSampleChunk.chunkData, 4);
@@ -124,6 +128,7 @@ export function readRegion(chunk)
124
128
  loop,
125
129
  originalKey,
126
130
  sample,
127
- sampleID);
131
+ sampleID,
132
+ pitchCorrection);
128
133
  return zone;
129
134
  }