spessasynth_core 1.0.6 → 1.0.7

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.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "SoundFont2 synthesizer library for node.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -50,27 +50,8 @@ export function _processEvent(event, trackIndex)
50
50
  }
51
51
  break;
52
52
 
53
+ // recognized but ignored
53
54
  case messageTypes.midiPort:
54
- const port = event.messageData[0];
55
- // assign new 16 channels if the port is not occupied yet
56
- if(this.midiPortChannelOffset === 0)
57
- {
58
- this.midiPortChannelOffset += 16;
59
- this.midiPortChannelOffsets[port] = 0;
60
- }
61
-
62
- if(this.midiPortChannelOffsets[port] === undefined)
63
- {
64
- if(this.synth.workletProcessorChannels.length < this.midiPortChannelOffset + 16) {
65
- this._addNewMidiPort();
66
- }
67
- this.midiPortChannelOffsets[port] = this.midiPortChannelOffset;
68
- this.midiPortChannelOffset += 16;
69
- }
70
-
71
- this.midiPorts[trackIndex] = port;
72
- break;
73
-
74
55
  case messageTypes.endOfTrack:
75
56
  case messageTypes.midiChannelPrefix:
76
57
  case messageTypes.timeSignature:
@@ -33,17 +33,39 @@ export function loadNewSequence(parsedMidi)
33
33
  */
34
34
  this.tracks = this.midiData.tracks;
35
35
 
36
- // copy over the port data (can be overwritten in real time if needed)
36
+ // clear last port data
37
+ this.midiPortChannelOffset = 0;
38
+ this.midiPortChannelOffsets = {};
39
+ // copy over the port data
37
40
  this.midiPorts = this.midiData.midiPorts;
38
41
 
42
+ // assign port offsets
43
+ this.midiData.midiPorts.forEach((port, trackIndex) => {
44
+ // assign new 16 channels if the port is not occupied yet
45
+ if(this.midiPortChannelOffset === 0)
46
+ {
47
+ this.midiPortChannelOffset += 16;
48
+ this.midiPortChannelOffsets[port] = 0;
49
+ }
50
+
51
+ if(this.midiPortChannelOffsets[port] === undefined)
52
+ {
53
+ if(this.synth.workletProcessorChannels.length < this.midiPortChannelOffset + 16) {
54
+ this._addNewMidiPort();
55
+ }
56
+ this.midiPortChannelOffsets[port] = this.midiPortChannelOffset;
57
+ this.midiPortChannelOffset += 16;
58
+ }
59
+
60
+ this.midiPorts[trackIndex] = port;
61
+ });
62
+
39
63
  /**
40
64
  * Same as Audio.duration (seconds)
41
65
  * @type {number}
42
66
  */
43
67
  this.duration = this.midiData.duration;
44
68
  SpessaSynthInfo(`%cTotal song time: ${formatTime(Math.ceil(this.duration)).time}`, consoleColors.recognized);
45
- this.midiPortChannelOffset = 0;
46
- this.midiPortChannelOffsets = {};
47
69
 
48
70
  this.synth.resetAllControllers();
49
71
  if(this.duration <= 1)