spessasynth_lib 3.20.22 → 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';
@@ -156,7 +156,7 @@ export class Synthetizer {
156
156
  * @param audioNodes {AudioNode[]}
157
157
  */
158
158
  connectIndividualOutputs(audioNodes: AudioNode[]): void;
159
- lockAndResetChannelVibrato(): void;
159
+ disableGSNRPparams(): void;
160
160
  /**
161
161
  * A message for debugging
162
162
  */
@@ -19,7 +19,7 @@
19
19
  * @property {boolean} lockPreset - indicates whether the program on the channel is locked
20
20
  * @property {boolean} presetUsesOverride - indcates if the channel uses a preset from the override soundfont.
21
21
  *
22
- * @property {boolean} lockVibrato - indicates whether the custom vibrato is locked
22
+ * @property {boolean} lockGSNRPNParams - indicates whether the GS NRPN parameters are enabled
23
23
  * @property {Object} channelVibrato - vibrato settings for the channel
24
24
  * @property {number} channelVibrato.depth - depth of the vibrato effect (cents)
25
25
  * @property {number} channelVibrato.delay - delay before the vibrato effect starts (seconds)
@@ -119,9 +119,9 @@ export type WorkletProcessorChannel = {
119
119
  */
120
120
  presetUsesOverride: boolean;
121
121
  /**
122
- * - indicates whether the custom vibrato is locked
122
+ * - indicates whether the GS NRPN parameters are enabled
123
123
  */
124
- lockVibrato: boolean;
124
+ lockGSNRPNParams: boolean;
125
125
  /**
126
126
  * - vibrato settings for the channel
127
127
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_lib",
3
- "version": "3.20.22",
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
  }
@@ -401,9 +401,9 @@ export class Synthetizer {
401
401
  }
402
402
 
403
403
  /*
404
- * Prevents any further changes to the vibrato via NRPN messages and sets it to disabled
404
+ * Disables the GS NRPN parameters like vibrato or drum key tuning
405
405
  */
406
- lockAndResetChannelVibrato()
406
+ disableGSNRPparams()
407
407
  {
408
408
  // rate -1 disables, see worklet_message.js line 9
409
409
  // channel -1 is all