spessasynth_core 1.0.7 → 1.0.9

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.7",
3
+ "version": "1.0.9",
4
4
  "description": "SoundFont2 synthesizer library for node.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -77,8 +77,11 @@ export function _playTo(time, ticks = undefined)
77
77
  break;
78
78
 
79
79
  case messageTypes.controllerChange:
80
+
80
81
  // do not skip data entries
81
82
  const controllerNumber = event.messageData[0];
83
+ // Keep in mind midi ports to determine channel!!
84
+ const channel = info.channel + (this.midiPortChannelOffsets[this.midiPorts[trackIndex]] || 0);
82
85
  if(
83
86
  controllerNumber === midiControllers.dataDecrement ||
84
87
  controllerNumber === midiControllers.dataEntryMsb ||
@@ -93,12 +96,10 @@ export function _playTo(time, ticks = undefined)
93
96
  controllerNumber === midiControllers.resetAllControllers
94
97
  )
95
98
  {
96
- this.synth.controllerChange(info.channel, controllerNumber, event.messageData[1]);
99
+ this.synth.controllerChange(channel, controllerNumber, event.messageData[1]);
97
100
  }
98
101
  else
99
102
  {
100
- // Keep in mind midi ports to determine channel!!
101
- const channel = info.channel + (this.midiPortChannelOffsets[this.midiPorts[trackIndex]] || 0);
102
103
  if(savedControllers[channel] === undefined)
103
104
  {
104
105
  savedControllers[channel] = Array.from(defaultControllerArray);
@@ -106,19 +107,6 @@ export function _playTo(time, ticks = undefined)
106
107
  savedControllers[channel][controllerNumber] = event.messageData[1];
107
108
  }
108
109
  break;
109
-
110
- // midiport: handle it and make sure that the saved controllers table is the same size as synth channels
111
- case messageTypes.midiPort:
112
- this._processEvent(event, trackIndex);
113
- if(this.synth.workletProcessorChannels.length > savedControllers.length)
114
- {
115
- while(this.synth.workletProcessorChannels.length > savedControllers.length)
116
- {
117
- savedControllers.push(Array.from(defaultControllerArray));
118
- }
119
- }
120
- break;
121
-
122
110
  default:
123
111
  this._processEvent(event, trackIndex);
124
112
  break;
@@ -14,7 +14,8 @@ export function _processEvent(event, trackIndex)
14
14
  {
15
15
  if(this.ignoreEvents) return;
16
16
  const statusByteData = getEvent(event.messageStatusByte);
17
- statusByteData.channel += this.midiPortChannelOffsets[this.midiPorts[trackIndex]] || 0;
17
+ const offset = this.midiPortChannelOffsets[this.midiPorts[trackIndex]] || 0;
18
+ statusByteData.channel += offset;
18
19
  // process the event
19
20
  switch (statusByteData.status) {
20
21
  case messageTypes.noteOn:
@@ -81,7 +82,7 @@ export function _processEvent(event, trackIndex)
81
82
  break;
82
83
 
83
84
  case messageTypes.systemExclusive:
84
- this.synth.systemExclusive(event.messageData);
85
+ this.synth.systemExclusive(event.messageData, offset);
85
86
  break;
86
87
 
87
88
  case messageTypes.reset:
@@ -50,7 +50,7 @@ export function loadNewSequence(parsedMidi)
50
50
 
51
51
  if(this.midiPortChannelOffsets[port] === undefined)
52
52
  {
53
- if(this.synth.workletProcessorChannels.length < this.midiPortChannelOffset + 16) {
53
+ if(this.synth.workletProcessorChannels.length < this.midiPortChannelOffset + 15) {
54
54
  this._addNewMidiPort();
55
55
  }
56
56
  this.midiPortChannelOffsets[port] = this.midiPortChannelOffset;
@@ -3,10 +3,11 @@ import { SpessaSynthInfo, SpessaSynthWarn } from '../../../utils/loggin.js'
3
3
  /**
4
4
  * Executes a system exclusive
5
5
  * @param messageData {number[]} - the message data without f0
6
+ * @param channelOffset {number}
6
7
  * @this {Synthesizer}
7
8
  */
8
9
 
9
- export function systemExclusive(messageData)
10
+ export function systemExclusive(messageData, channelOffset = 0)
10
11
  {
11
12
  const type = messageData[0];
12
13
  switch (type)
@@ -117,7 +118,7 @@ export function systemExclusive(messageData)
117
118
  {
118
119
  // this is an individual part (channel) parameter
119
120
  // determine the channel 0 means channel 10 (default), 1 means 1 etc.
120
- const channel = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15][messageData[5] & 0x0F]; // for example 1A means A = 11, which corresponds to channel 12 (counting from 1)
121
+ const channel = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15][messageData[5] & 0x0F] + channelOffset; // for example 1A means A = 11, which corresponds to channel 12 (counting from 1)
121
122
  switch (messageData[6])
122
123
  {
123
124
  default: