spessasynth_lib 3.20.40 → 3.20.42
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.
- package/@types/soundfont/basic_soundfont/basic_sample.d.ts +2 -2
- package/package.json +1 -1
- package/soundfont/basic_soundfont/basic_sample.js +2 -2
- package/soundfont/basic_soundfont/write_sf2/shdr.js +2 -2
- package/soundfont/dls/dls_sample.js +2 -2
- package/soundfont/dls/dls_zone.js +6 -6
- package/soundfont/read_sf2/samples.js +4 -4
- package/synthetizer/worklet_processor.min.js +8 -8
- package/synthetizer/worklet_system/worklet_methods/snapshot.js +3 -0
- package/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +12 -0
- package/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +5 -13
- package/utils/loggin.js +2 -2
|
@@ -42,12 +42,12 @@ export class BasicSample {
|
|
|
42
42
|
*/
|
|
43
43
|
sampleType: number;
|
|
44
44
|
/**
|
|
45
|
-
* Relative to start of the sample
|
|
45
|
+
* Relative to start of the sample in sample points
|
|
46
46
|
* @type {number}
|
|
47
47
|
*/
|
|
48
48
|
sampleLoopStartIndex: number;
|
|
49
49
|
/**
|
|
50
|
-
* Relative to start of the sample
|
|
50
|
+
* Relative to start of the sample in sample points
|
|
51
51
|
* @type {number}
|
|
52
52
|
*/
|
|
53
53
|
sampleLoopEndIndex: number;
|
package/package.json
CHANGED
|
@@ -58,12 +58,12 @@ export class BasicSample {
|
|
|
58
58
|
*/
|
|
59
59
|
this.sampleType = sampleType
|
|
60
60
|
/**
|
|
61
|
-
* Relative to start of the sample
|
|
61
|
+
* Relative to start of the sample in sample points
|
|
62
62
|
* @type {number}
|
|
63
63
|
*/
|
|
64
64
|
this.sampleLoopStartIndex = loopStart
|
|
65
65
|
/**
|
|
66
|
-
* Relative to start of the sample
|
|
66
|
+
* Relative to start of the sample in sample points
|
|
67
67
|
* @type {number}
|
|
68
68
|
*/
|
|
69
69
|
this.sampleLoopEndIndex = loopEnd;
|
|
@@ -23,8 +23,8 @@ export function getSHDR(smplStartOffsets, smplEndOffsets)
|
|
|
23
23
|
const dwEnd = smplEndOffsets[index];
|
|
24
24
|
writeDword(shdrData, dwEnd);
|
|
25
25
|
// loop is stored as relative in sample points, change it to absolute sample points here
|
|
26
|
-
let loopStart = sample.sampleLoopStartIndex
|
|
27
|
-
let loopEnd = sample.sampleLoopEndIndex
|
|
26
|
+
let loopStart = sample.sampleLoopStartIndex + dwStart;
|
|
27
|
+
let loopEnd = sample.sampleLoopEndIndex + dwStart;
|
|
28
28
|
if(sample.isCompressed)
|
|
29
29
|
{
|
|
30
30
|
// https://github.com/FluidSynth/fluidsynth/wiki/SoundFont3Format
|
|
@@ -30,8 +30,8 @@ export class DLSSample extends BasicSample
|
|
|
30
30
|
pitchCorrection,
|
|
31
31
|
0,
|
|
32
32
|
1,
|
|
33
|
-
loopStart
|
|
34
|
-
|
|
33
|
+
loopStart,
|
|
34
|
+
loopEnd - 1 // -1 sample because soundfont end is last sample and dls end is next sample
|
|
35
35
|
);
|
|
36
36
|
this.sampleData = data;
|
|
37
37
|
this.sampleDbAttenuation = sampleDbAttenuation;
|
|
@@ -55,17 +55,17 @@ export class DLSZone extends BasicInstrumentZone
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// correct loop if needed
|
|
58
|
-
const diffStart = loop.start -
|
|
59
|
-
const diffEnd = loop.end -
|
|
58
|
+
const diffStart = loop.start - sample.sampleLoopStartIndex;
|
|
59
|
+
const diffEnd = loop.end - sample.sampleLoopEndIndex;
|
|
60
60
|
if(diffStart !== 0)
|
|
61
61
|
{
|
|
62
62
|
const fine = diffStart % 32768;
|
|
63
63
|
this.generators.push(new Generator(generatorTypes.startloopAddrsOffset, fine));
|
|
64
64
|
// coarse generator uses 32768 samples per step
|
|
65
|
-
const coarse = (diffStart
|
|
65
|
+
const coarse = Math.trunc(diffStart / 32768);
|
|
66
66
|
if(coarse !== 0)
|
|
67
67
|
{
|
|
68
|
-
this.generators.push(new Generator(generatorTypes.startloopAddrsCoarseOffset,
|
|
68
|
+
this.generators.push(new Generator(generatorTypes.startloopAddrsCoarseOffset, coarse));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if(diffEnd !== 0)
|
|
@@ -73,10 +73,10 @@ export class DLSZone extends BasicInstrumentZone
|
|
|
73
73
|
const fine = diffEnd % 32768;
|
|
74
74
|
this.generators.push(new Generator(generatorTypes.endloopAddrsOffset, fine));
|
|
75
75
|
// coarse generator uses 32768 samples per step
|
|
76
|
-
const coarse = (diffEnd
|
|
76
|
+
const coarse = Math.trunc(diffEnd / 32768);
|
|
77
77
|
if(coarse !== 0)
|
|
78
78
|
{
|
|
79
|
-
this.generators.push(new Generator(generatorTypes.endloopAddrsCoarseOffset,
|
|
79
|
+
this.generators.push(new Generator(generatorTypes.endloopAddrsCoarseOffset, coarse));
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
// correct key if needed
|
|
@@ -47,8 +47,8 @@ export class LoadedSample extends BasicSample
|
|
|
47
47
|
samplePitchCorrection,
|
|
48
48
|
sampleLink,
|
|
49
49
|
sampleType,
|
|
50
|
-
sampleLoopStartIndex - sampleStartIndex,
|
|
51
|
-
sampleLoopEndIndex - sampleStartIndex
|
|
50
|
+
sampleLoopStartIndex - (sampleStartIndex / 2),
|
|
51
|
+
sampleLoopEndIndex - (sampleStartIndex / 2)
|
|
52
52
|
);
|
|
53
53
|
this.sampleName = sampleName
|
|
54
54
|
// in bytes
|
|
@@ -245,10 +245,10 @@ function readSample(index, sampleHeaderData, smplArrayData, isDataRaw) {
|
|
|
245
245
|
let sampleEndIndex = readLittleEndian(sampleHeaderData, 4) * 2;
|
|
246
246
|
|
|
247
247
|
// read the sample looping start index
|
|
248
|
-
let sampleLoopStartIndex = readLittleEndian(sampleHeaderData, 4)
|
|
248
|
+
let sampleLoopStartIndex = readLittleEndian(sampleHeaderData, 4);
|
|
249
249
|
|
|
250
250
|
// read the sample looping end index
|
|
251
|
-
let sampleLoopEndIndex = readLittleEndian(sampleHeaderData, 4)
|
|
251
|
+
let sampleLoopEndIndex = readLittleEndian(sampleHeaderData, 4);
|
|
252
252
|
|
|
253
253
|
// read the sample rate
|
|
254
254
|
let sampleRate = readLittleEndian(sampleHeaderData, 4);
|