spessasynth_core 1.1.0 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spessasynth_core",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "SoundFont2 synthesizer library for node.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -36,8 +36,8 @@ export class MIDI{
36
36
  throw new RangeError(`Invalid MIDI header chunk size! Expected 6, got ${headerChunk.size}`);
37
37
  }
38
38
 
39
- // format (ignore)
40
- readBytesAsUintBigEndian(headerChunk.data, 2);
39
+ // format
40
+ const format = readBytesAsUintBigEndian(headerChunk.data, 2);
41
41
  // tracks count
42
42
  this.tracksAmount = readBytesAsUintBigEndian(headerChunk.data, 2);
43
43
  // time division
@@ -95,6 +95,11 @@ export class MIDI{
95
95
  let runningByte = undefined;
96
96
 
97
97
  let totalTicks = 0;
98
+ // format 2 plays sequentially
99
+ if(format === 2 && i > 0)
100
+ {
101
+ totalTicks += this.tracks[i - 1][this.tracks[i - 1].length - 1].ticks;
102
+ }
98
103
  // loop until we reach the end of track
99
104
  while(trackChunk.data.currentIndex < trackChunk.size)
100
105
  {
@@ -63,7 +63,9 @@ export function noteOn(channel, midiNote, velocity, enableDebugging = false)
63
63
  }
64
64
  computeModulators(voice, this.workletProcessorChannels[channel].midiControllers);
65
65
  voice.currentAttenuationDb = 100;
66
- })
66
+ // set initial pan to avoid split second changing from middle to the correct value
67
+ voice.currentPan = ( (Math.max(-500, Math.min(500, voice.modulatedGenerators[generatorTypes.pan] )) + 500) / 1000) // 0 to 1
68
+ });
67
69
 
68
70
  this.totalVoicesAmount += voices.length;
69
71
  // cap the voices