spessasynth_core 1.0.6 → 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 +1 -1
- package/spessasynth_core/sequencer/worklet_sequencer/play.js +4 -16
- package/spessasynth_core/sequencer/worklet_sequencer/process_event.js +4 -22
- package/spessasynth_core/sequencer/worklet_sequencer/song_control.js +25 -3
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/system_exclusive.js +3 -2
package/package.json
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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:
|
|
@@ -50,27 +51,8 @@ export function _processEvent(event, trackIndex)
|
|
|
50
51
|
}
|
|
51
52
|
break;
|
|
52
53
|
|
|
54
|
+
// recognized but ignored
|
|
53
55
|
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
56
|
case messageTypes.endOfTrack:
|
|
75
57
|
case messageTypes.midiChannelPrefix:
|
|
76
58
|
case messageTypes.timeSignature:
|
|
@@ -100,7 +82,7 @@ export function _processEvent(event, trackIndex)
|
|
|
100
82
|
break;
|
|
101
83
|
|
|
102
84
|
case messageTypes.systemExclusive:
|
|
103
|
-
this.synth.systemExclusive(event.messageData);
|
|
85
|
+
this.synth.systemExclusive(event.messageData, offset);
|
|
104
86
|
break;
|
|
105
87
|
|
|
106
88
|
case messageTypes.reset:
|
|
@@ -33,17 +33,39 @@ export function loadNewSequence(parsedMidi)
|
|
|
33
33
|
*/
|
|
34
34
|
this.tracks = this.midiData.tracks;
|
|
35
35
|
|
|
36
|
-
//
|
|
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 + 15) {
|
|
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)
|
|
@@ -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:
|