spessasynth_core 1.0.7 → 1.0.10
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/README.md +2 -1
- package/package.json +1 -1
- package/spessasynth_core/sequencer/sequencer.js +13 -0
- package/spessasynth_core/sequencer/worklet_sequencer/play.js +4 -16
- package/spessasynth_core/sequencer/worklet_sequencer/process_event.js +3 -2
- package/spessasynth_core/sequencer/worklet_sequencer/song_control.js +1 -1
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/system_exclusive.js +3 -2
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
A SoundFont2 synthesizer library, made for use with node.js.
|
|
3
3
|
A fork of [SpessaSynth](https://github.com/spessasus/SpessaSynth).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Jump to documentation](#api-reference)
|
|
6
6
|
|
|
7
|
+
`npm install --save spessasynth_core`
|
|
7
8
|
|
|
8
9
|
> Looking for a browser version? Try [SpessaSynth](https://github.com/spessasus/SpessaSynth).
|
|
9
10
|
|
package/package.json
CHANGED
|
@@ -90,6 +90,10 @@ class Sequencer
|
|
|
90
90
|
this.currentTime = time;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* The current playback time, in seconds
|
|
95
|
+
* @return {number}
|
|
96
|
+
*/
|
|
93
97
|
get currentTime()
|
|
94
98
|
{
|
|
95
99
|
// return the paused time if it's set to something other than undefined
|
|
@@ -148,6 +152,15 @@ class Sequencer
|
|
|
148
152
|
this.synth.stopAllChannels();
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Total track length, in seconds.
|
|
157
|
+
* @return {number}
|
|
158
|
+
*/
|
|
159
|
+
get duration()
|
|
160
|
+
{
|
|
161
|
+
return this.midiData.duration;
|
|
162
|
+
}
|
|
163
|
+
|
|
151
164
|
_resetTimers()
|
|
152
165
|
{
|
|
153
166
|
this.playedTime = 0
|
|
@@ -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:
|
|
@@ -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 +
|
|
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:
|