@marmooo/midy 0.4.7 → 0.4.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/README.md +6 -2
- package/esm/midy-GM1.d.ts +25 -2
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +97 -16
- package/esm/midy-GM2.d.ts +39 -3
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +176 -39
- package/esm/midy-GMLite.d.ts +23 -2
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +85 -15
- package/esm/midy.d.ts +41 -3
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +212 -51
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +25 -2
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +97 -16
- package/script/midy-GM2.d.ts +39 -3
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +176 -39
- package/script/midy-GMLite.d.ts +23 -2
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +85 -15
- package/script/midy.d.ts +41 -3
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +212 -51
package/script/midy.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export class Midy extends EventTarget {
|
|
|
96
96
|
controlChangeHandlers: any[];
|
|
97
97
|
keyBasedControllerHandlers: any[];
|
|
98
98
|
effectHandlers: any[];
|
|
99
|
-
channels:
|
|
99
|
+
channels: Channel[];
|
|
100
100
|
reverbEffect: {
|
|
101
101
|
input: any;
|
|
102
102
|
output: any;
|
|
@@ -121,8 +121,7 @@ export class Midy extends EventTarget {
|
|
|
121
121
|
gainR: any;
|
|
122
122
|
merger: any;
|
|
123
123
|
};
|
|
124
|
-
|
|
125
|
-
createChannels(audioContext: any): any[];
|
|
124
|
+
createChannels(audioContext: any): Channel[];
|
|
126
125
|
decodeOggVorbis(sample: any): Promise<any>;
|
|
127
126
|
createAudioBuffer(voiceParams: any): Promise<any>;
|
|
128
127
|
isLoopDrum(channel: any, noteNumber: any): boolean;
|
|
@@ -260,6 +259,7 @@ export class Midy extends EventTarget {
|
|
|
260
259
|
updatePortamento(channel: any, scheduleTime: any): void;
|
|
261
260
|
setPortamentoTime(channelNumber: any, value: any, scheduleTime: any): void;
|
|
262
261
|
setVolume(channelNumber: any, value: any, scheduleTime: any): void;
|
|
262
|
+
applyVolume(channel: any, scheduleTime: any): void;
|
|
263
263
|
panToGain(pan: any): {
|
|
264
264
|
gainLeft: number;
|
|
265
265
|
gainRight: number;
|
|
@@ -363,7 +363,11 @@ export class Midy extends EventTarget {
|
|
|
363
363
|
getLFOAmplitudeDepth(channel: any, note: any): number;
|
|
364
364
|
createEffectHandlers(): any[];
|
|
365
365
|
setControlChangeEffects(channel: any, note: any, scheduleTime: any): void;
|
|
366
|
+
setChannelPressureEffects(channel: any, note: any, scheduleTime: any): void;
|
|
367
|
+
setPolyphonicKeyPressureEffects(channel: any, note: any, scheduleTime: any): void;
|
|
366
368
|
setPressureEffects(channel: any, note: any, tableName: any, scheduleTime: any): void;
|
|
369
|
+
handleChannelPressureSysEx(data: any, scheduleTime: any): void;
|
|
370
|
+
handlePolyphonicKeyPressureSysEx(data: any, scheduleTime: any): void;
|
|
367
371
|
handlePressureSysEx(data: any, tableName: any, scheduleTime: any): void;
|
|
368
372
|
handleControlChangeSysEx(data: any, scheduleTime: any): void;
|
|
369
373
|
getRelativeKeyBasedValue(channel: any, keyNumber: any, controllerType: any): any;
|
|
@@ -374,6 +378,37 @@ export class Midy extends EventTarget {
|
|
|
374
378
|
scheduleTask(callback: any, scheduleTime: any): Promise<any>;
|
|
375
379
|
}
|
|
376
380
|
import { OggVorbisDecoderWebWorker } from "@wasm-audio-decoders/ogg-vorbis";
|
|
381
|
+
declare class Channel {
|
|
382
|
+
constructor(audioNodes: any, settings: any);
|
|
383
|
+
isDrum: boolean;
|
|
384
|
+
programNumber: number;
|
|
385
|
+
scheduleIndex: number;
|
|
386
|
+
detune: number;
|
|
387
|
+
bankMSB: number;
|
|
388
|
+
bankLSB: number;
|
|
389
|
+
dataMSB: number;
|
|
390
|
+
dataLSB: number;
|
|
391
|
+
rpnMSB: number;
|
|
392
|
+
rpnLSB: number;
|
|
393
|
+
mono: boolean;
|
|
394
|
+
modulationDepthRange: number;
|
|
395
|
+
fineTuning: number;
|
|
396
|
+
coarseTuning: number;
|
|
397
|
+
scheduledNotes: any[];
|
|
398
|
+
sustainNotes: any[];
|
|
399
|
+
sostenutoNotes: any[];
|
|
400
|
+
controlTable: Int8Array<ArrayBuffer>;
|
|
401
|
+
scaleOctaveTuningTable: Float32Array<ArrayBuffer>;
|
|
402
|
+
channelPressureTable: Int8Array<ArrayBuffer>;
|
|
403
|
+
polyphonicKeyPressureTable: Int8Array<ArrayBuffer>;
|
|
404
|
+
keyBasedTable: Int8Array<ArrayBuffer>;
|
|
405
|
+
keyBasedGainLs: any[];
|
|
406
|
+
keyBasedGainRs: any[];
|
|
407
|
+
currentBufferSource: null;
|
|
408
|
+
state: ControllerState;
|
|
409
|
+
resetSettings(settings: any): void;
|
|
410
|
+
resetTable(channel: any): void;
|
|
411
|
+
}
|
|
377
412
|
declare class Note {
|
|
378
413
|
constructor(noteNumber: any, velocity: any, startTime: any);
|
|
379
414
|
voice: any;
|
|
@@ -401,5 +436,8 @@ declare class Note {
|
|
|
401
436
|
ready: Promise<any>;
|
|
402
437
|
resolveReady: (value: any) => void;
|
|
403
438
|
}
|
|
439
|
+
declare class ControllerState {
|
|
440
|
+
array: Float32Array<ArrayBuffer>;
|
|
441
|
+
}
|
|
404
442
|
export {};
|
|
405
443
|
//# sourceMappingURL=midy.d.ts.map
|
package/script/midy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js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uHyC,iCAAiC;AA4C3E;IA2BE,4CAIC;IA9BD,gBAAe;IACf,sBAAkB;IAClB,sBAAkB;IAClB,eAAW;IACX,gBAAc;IACd,gBAAY;IACZ,gBAAY;IACZ,gBAAY;IACZ,eAAa;IACb,eAAa;IACb,cAAa;IACb,6BAA0B;IAC1B,mBAAe;IACf,qBAAiB;IACjB,sBAAoB;IACpB,oBAAkB;IAClB,sBAAoB;IACpB,qCAAmD;IACnD,kDAA8C;IAC9C,6CAA4D;IAC5D,mDAAkE;IAClE,sCAAkD;IAClD,sBAAgC;IAChC,sBAAgC;IAChC,0BAA2B;IAKzB,uBAAkC;IAGpC,mCAEC;IAED,+BAMC;CACF;AA3ED;IAqBE,4DAOC;IA3BD,WAAM;IACN,iBAAY;IACZ,yBAAyB;IACzB,cAAW;IACX,gBAAe;IACf,kBAAa;IACb,wBAAmB;IACnB,wBAAmB;IACnB,gBAAW;IACX,YAAO;IACP,mBAAc;IACd,sBAAiB;IACjB,oBAAe;IACf,YAAO;IACP,mBAAc;IACd,gBAAW;IACX,gBAAW;IACX,6BAA0B;IAC1B,iBAAa;IAGX,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,oBAEE;IADA,mCAA2B;CAGhC;AAsID;IACE,iCAA8B;CAa/B"}
|
package/script/midy.js
CHANGED
|
@@ -137,6 +137,173 @@ class Note {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
+
class Channel {
|
|
141
|
+
constructor(audioNodes, settings) {
|
|
142
|
+
Object.defineProperty(this, "isDrum", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: false
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(this, "programNumber", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: 0
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(this, "scheduleIndex", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: 0
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(this, "detune", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true,
|
|
164
|
+
value: 0
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(this, "bankMSB", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: 121
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(this, "bankLSB", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: 0
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(this, "dataMSB", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
configurable: true,
|
|
181
|
+
writable: true,
|
|
182
|
+
value: 0
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(this, "dataLSB", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
configurable: true,
|
|
187
|
+
writable: true,
|
|
188
|
+
value: 0
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(this, "rpnMSB", {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
configurable: true,
|
|
193
|
+
writable: true,
|
|
194
|
+
value: 127
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(this, "rpnLSB", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
configurable: true,
|
|
199
|
+
writable: true,
|
|
200
|
+
value: 127
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(this, "mono", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
configurable: true,
|
|
205
|
+
writable: true,
|
|
206
|
+
value: false
|
|
207
|
+
}); // CC#124, CC#125
|
|
208
|
+
Object.defineProperty(this, "modulationDepthRange", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
configurable: true,
|
|
211
|
+
writable: true,
|
|
212
|
+
value: 50
|
|
213
|
+
}); // cent
|
|
214
|
+
Object.defineProperty(this, "fineTuning", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true,
|
|
218
|
+
value: 0
|
|
219
|
+
}); // cent
|
|
220
|
+
Object.defineProperty(this, "coarseTuning", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
configurable: true,
|
|
223
|
+
writable: true,
|
|
224
|
+
value: 0
|
|
225
|
+
}); // cent
|
|
226
|
+
Object.defineProperty(this, "scheduledNotes", {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
configurable: true,
|
|
229
|
+
writable: true,
|
|
230
|
+
value: []
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(this, "sustainNotes", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
configurable: true,
|
|
235
|
+
writable: true,
|
|
236
|
+
value: []
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(this, "sostenutoNotes", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
configurable: true,
|
|
241
|
+
writable: true,
|
|
242
|
+
value: []
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(this, "controlTable", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
configurable: true,
|
|
247
|
+
writable: true,
|
|
248
|
+
value: new Int8Array(defaultControlValues)
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(this, "scaleOctaveTuningTable", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
configurable: true,
|
|
253
|
+
writable: true,
|
|
254
|
+
value: new Float32Array(12)
|
|
255
|
+
}); // [-100, 100] cent
|
|
256
|
+
Object.defineProperty(this, "channelPressureTable", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
configurable: true,
|
|
259
|
+
writable: true,
|
|
260
|
+
value: new Int8Array(defaultPressureValues)
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(this, "polyphonicKeyPressureTable", {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
configurable: true,
|
|
265
|
+
writable: true,
|
|
266
|
+
value: new Int8Array(defaultPressureValues)
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(this, "keyBasedTable", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
configurable: true,
|
|
271
|
+
writable: true,
|
|
272
|
+
value: new Int8Array(128 * 128).fill(-1)
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(this, "keyBasedGainLs", {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
configurable: true,
|
|
277
|
+
writable: true,
|
|
278
|
+
value: new Array(128)
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(this, "keyBasedGainRs", {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
configurable: true,
|
|
283
|
+
writable: true,
|
|
284
|
+
value: new Array(128)
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(this, "currentBufferSource", {
|
|
287
|
+
enumerable: true,
|
|
288
|
+
configurable: true,
|
|
289
|
+
writable: true,
|
|
290
|
+
value: null
|
|
291
|
+
});
|
|
292
|
+
Object.assign(this, audioNodes);
|
|
293
|
+
Object.assign(this, settings);
|
|
294
|
+
this.state = new ControllerState();
|
|
295
|
+
}
|
|
296
|
+
resetSettings(settings) {
|
|
297
|
+
Object.assign(this, settings);
|
|
298
|
+
}
|
|
299
|
+
resetTable(channel) {
|
|
300
|
+
channel.controlTable.set(defaultControlValues);
|
|
301
|
+
channel.scaleOctaveTuningTable.fill(0); // [-100, 100] cent
|
|
302
|
+
channel.channelPressureTable.set(defaultPressureValues);
|
|
303
|
+
channel.polyphonicKeyPressureTable.set(defaultPressureValues);
|
|
304
|
+
channel.keyBasedTable.fill(-1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
140
307
|
const drumExclusiveClassesByKit = new Array(57);
|
|
141
308
|
const drumExclusiveClassCount = 10;
|
|
142
309
|
const standardSet = new Uint8Array(128);
|
|
@@ -700,34 +867,9 @@ class Midy extends EventTarget {
|
|
|
700
867
|
merger,
|
|
701
868
|
};
|
|
702
869
|
}
|
|
703
|
-
resetChannelTable(channel) {
|
|
704
|
-
channel.controlTable.set(defaultControlValues);
|
|
705
|
-
channel.scaleOctaveTuningTable.fill(0); // [-100, 100] cent
|
|
706
|
-
channel.channelPressureTable.set(defaultPressureValues);
|
|
707
|
-
channel.polyphonicKeyPressureTable.set(defaultPressureValues);
|
|
708
|
-
channel.keyBasedTable.fill(-1);
|
|
709
|
-
}
|
|
710
870
|
createChannels(audioContext) {
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
currentBufferSource: null,
|
|
714
|
-
isDrum: false,
|
|
715
|
-
state: new ControllerState(),
|
|
716
|
-
...this.constructor.channelSettings,
|
|
717
|
-
...this.createChannelAudioNodes(audioContext),
|
|
718
|
-
scheduledNotes: [],
|
|
719
|
-
sustainNotes: [],
|
|
720
|
-
sostenutoNotes: [],
|
|
721
|
-
controlTable: new Int8Array(defaultControlValues),
|
|
722
|
-
scaleOctaveTuningTable: new Float32Array(12), // [-100, 100] cent
|
|
723
|
-
channelPressureTable: new Int8Array(defaultPressureValues),
|
|
724
|
-
polyphonicKeyPressureTable: new Int8Array(defaultPressureValues),
|
|
725
|
-
keyBasedTable: new Int8Array(128 * 128).fill(-1),
|
|
726
|
-
keyBasedGainLs: new Array(128),
|
|
727
|
-
keyBasedGainRs: new Array(128),
|
|
728
|
-
};
|
|
729
|
-
});
|
|
730
|
-
return channels;
|
|
871
|
+
const settings = this.constructor.channelSettings;
|
|
872
|
+
return Array.from({ length: this.numChannels }, () => new Channel(this.createChannelAudioNodes(audioContext), settings));
|
|
731
873
|
}
|
|
732
874
|
decodeOggVorbis(sample) {
|
|
733
875
|
const task = decoderQueue.then(async () => {
|
|
@@ -1786,16 +1928,15 @@ class Midy extends EventTarget {
|
|
|
1786
1928
|
}
|
|
1787
1929
|
async noteOn(channelNumber, noteNumber, velocity, startTime) {
|
|
1788
1930
|
if (this.mpeEnabled) {
|
|
1789
|
-
const
|
|
1931
|
+
const channel = this.channels[channelNumber];
|
|
1932
|
+
const noteIndex = channel.scheduledNotes.length;
|
|
1790
1933
|
if (!this.mpeState.channelToNotes.has(channelNumber)) {
|
|
1791
1934
|
this.mpeState.channelToNotes.set(channelNumber, new Set());
|
|
1792
1935
|
}
|
|
1793
|
-
this.mpeState.channelToNotes.get(channelNumber).add(
|
|
1794
|
-
this.mpeState.noteToChannel.set(
|
|
1795
|
-
}
|
|
1796
|
-
else {
|
|
1797
|
-
await this.startNote(channelNumber, noteNumber, velocity, startTime);
|
|
1936
|
+
this.mpeState.channelToNotes.get(channelNumber).add(noteIndex);
|
|
1937
|
+
this.mpeState.noteToChannel.set(noteIndex, channelNumber);
|
|
1798
1938
|
}
|
|
1939
|
+
await this.startNote(channelNumber, noteNumber, velocity, startTime);
|
|
1799
1940
|
}
|
|
1800
1941
|
async startNote(channelNumber, noteNumber, velocity, startTime) {
|
|
1801
1942
|
const channel = this.channels[channelNumber];
|
|
@@ -2027,7 +2168,7 @@ class Midy extends EventTarget {
|
|
|
2027
2168
|
this.processActiveNotes(channel, scheduleTime, (note) => {
|
|
2028
2169
|
if (note.noteNumber === noteNumber) {
|
|
2029
2170
|
note.pressure = pressure;
|
|
2030
|
-
this.
|
|
2171
|
+
this.setPolyphonicKeyPressureEffects(channel, note, scheduleTime);
|
|
2031
2172
|
}
|
|
2032
2173
|
});
|
|
2033
2174
|
this.applyVoiceParams(channel, 10, scheduleTime);
|
|
@@ -2068,7 +2209,7 @@ class Midy extends EventTarget {
|
|
|
2068
2209
|
const next = this.calcChannelPressureEffectValue(channel, 0);
|
|
2069
2210
|
channel.detune += next - prev;
|
|
2070
2211
|
this.processActiveNotes(channel, scheduleTime, (note) => {
|
|
2071
|
-
this.
|
|
2212
|
+
this.setChannelPressureEffects(channel, note, scheduleTime);
|
|
2072
2213
|
});
|
|
2073
2214
|
this.applyVoiceParams(channel, 13, scheduleTime);
|
|
2074
2215
|
}
|
|
@@ -2468,6 +2609,9 @@ class Midy extends EventTarget {
|
|
|
2468
2609
|
const intPart = Math.trunc(value);
|
|
2469
2610
|
state.volumeMSB = intPart / 127;
|
|
2470
2611
|
state.volumeLSB = value - intPart;
|
|
2612
|
+
this.applyVolume(channel, scheduleTime);
|
|
2613
|
+
}
|
|
2614
|
+
applyVolume(channel, scheduleTime) {
|
|
2471
2615
|
if (channel.isDrum) {
|
|
2472
2616
|
for (let i = 0; i < 128; i++) {
|
|
2473
2617
|
this.updateKeyBasedVolume(channel, i, scheduleTime);
|
|
@@ -2966,10 +3110,8 @@ class Midy extends EventTarget {
|
|
|
2966
3110
|
state[key] = defaultValue;
|
|
2967
3111
|
}
|
|
2968
3112
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
}
|
|
2972
|
-
this.resetChannelTable(channel);
|
|
3113
|
+
channel.resetSettings(this.constructor.channelSettings);
|
|
3114
|
+
this.resetTable(channel);
|
|
2973
3115
|
this.mode = "GM2";
|
|
2974
3116
|
this.masterFineTuning = 0; // cent
|
|
2975
3117
|
this.masterCoarseTuning = 0; // cent
|
|
@@ -3132,9 +3274,9 @@ class Midy extends EventTarget {
|
|
|
3132
3274
|
case 9:
|
|
3133
3275
|
switch (data[3]) {
|
|
3134
3276
|
case 1: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
3135
|
-
return this.
|
|
3277
|
+
return this.handleChannelPressureSysEx(data, scheduelTime);
|
|
3136
3278
|
case 2: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
3137
|
-
return this.
|
|
3279
|
+
return this.handlePolyphonicKeyPressureSysEx(data, scheduleTime);
|
|
3138
3280
|
case 3: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
3139
3281
|
return this.handleControlChangeSysEx(data, scheduleTime);
|
|
3140
3282
|
default:
|
|
@@ -3513,7 +3655,7 @@ class Midy extends EventTarget {
|
|
|
3513
3655
|
}
|
|
3514
3656
|
createEffectHandlers() {
|
|
3515
3657
|
const handlers = new Array(6);
|
|
3516
|
-
handlers[0] = (channel, note, scheduleTime) => {
|
|
3658
|
+
handlers[0] = (channel, note, _tableName, scheduleTime) => {
|
|
3517
3659
|
if (this.isPortamento(channel, note)) {
|
|
3518
3660
|
this.setPortamentoDetune(channel, note, scheduleTime);
|
|
3519
3661
|
}
|
|
@@ -3521,7 +3663,7 @@ class Midy extends EventTarget {
|
|
|
3521
3663
|
this.setDetune(channel, note, scheduleTime);
|
|
3522
3664
|
}
|
|
3523
3665
|
};
|
|
3524
|
-
handlers[1] = (channel, note, scheduleTime) => {
|
|
3666
|
+
handlers[1] = (channel, note, _tableName, scheduleTime) => {
|
|
3525
3667
|
if (0.5 <= channel.state.portamento && 0 <= note.portamentoNoteNumber) {
|
|
3526
3668
|
this.setPortamentoFilterEnvelope(channel, note, scheduleTime);
|
|
3527
3669
|
}
|
|
@@ -3529,10 +3671,17 @@ class Midy extends EventTarget {
|
|
|
3529
3671
|
this.setFilterEnvelope(channel, note, scheduleTime);
|
|
3530
3672
|
}
|
|
3531
3673
|
};
|
|
3532
|
-
handlers[2] = (channel, note, scheduleTime) =>
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3674
|
+
handlers[2] = (channel, note, tableName, scheduleTime) => {
|
|
3675
|
+
if (tableName === "polyphonicKeyPressureTable") {
|
|
3676
|
+
this.setVolumeNode(channel, note, scheduleTime);
|
|
3677
|
+
}
|
|
3678
|
+
else {
|
|
3679
|
+
this.applyVolume(channel, scheduleTime);
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
handlers[3] = (channel, note, _tableName, scheduleTime) => this.setModLfoToPitch(channel, note, scheduleTime);
|
|
3683
|
+
handlers[4] = (channel, note, _tableName, scheduleTime) => this.setModLfoToFilterFc(channel, note, scheduleTime);
|
|
3684
|
+
handlers[5] = (channel, note, _tableName, scheduleTime) => this.setModLfoToVolume(channel, note, scheduleTime);
|
|
3536
3685
|
return handlers;
|
|
3537
3686
|
}
|
|
3538
3687
|
setControlChangeEffects(channel, note, scheduleTime) {
|
|
@@ -3542,9 +3691,15 @@ class Midy extends EventTarget {
|
|
|
3542
3691
|
const tableValue = channel.controlTable[i + 6];
|
|
3543
3692
|
if (baseline === tableValue)
|
|
3544
3693
|
continue;
|
|
3545
|
-
handlers[i](channel, note, scheduleTime);
|
|
3694
|
+
handlers[i](channel, note, "controlTable", scheduleTime);
|
|
3546
3695
|
}
|
|
3547
3696
|
}
|
|
3697
|
+
setChannelPressureEffects(channel, note, scheduleTime) {
|
|
3698
|
+
this.setPressureEffects(channel, note, "channelPressureTable", scheduleTime);
|
|
3699
|
+
}
|
|
3700
|
+
setPolyphonicKeyPressureEffects(channel, note, scheduleTime) {
|
|
3701
|
+
this.setPressureEffects(channel, note, "polyphonicKeyPressureTable", scheduleTime);
|
|
3702
|
+
}
|
|
3548
3703
|
setPressureEffects(channel, note, tableName, scheduleTime) {
|
|
3549
3704
|
const handlers = this.effectHandlers;
|
|
3550
3705
|
const table = channel[tableName];
|
|
@@ -3553,9 +3708,15 @@ class Midy extends EventTarget {
|
|
|
3553
3708
|
const tableValue = table[i];
|
|
3554
3709
|
if (baseline === tableValue)
|
|
3555
3710
|
continue;
|
|
3556
|
-
handlers[i](channel, note, scheduleTime);
|
|
3711
|
+
handlers[i](channel, note, tableName, scheduleTime);
|
|
3557
3712
|
}
|
|
3558
3713
|
}
|
|
3714
|
+
handleChannelPressureSysEx(data, scheduleTime) {
|
|
3715
|
+
this.handlePressureSysEx(data, "channelPressureTable", scheduleTime);
|
|
3716
|
+
}
|
|
3717
|
+
handlePolyphonicKeyPressureSysEx(data, scheduleTime) {
|
|
3718
|
+
this.handlePressureSysEx(data, "polyphonicKeyPressureTable", scheduleTime);
|
|
3719
|
+
}
|
|
3559
3720
|
handlePressureSysEx(data, tableName, scheduleTime) {
|
|
3560
3721
|
const channelNumber = data[4];
|
|
3561
3722
|
const channel = this.channels[channelNumber];
|
|
@@ -3569,7 +3730,7 @@ class Midy extends EventTarget {
|
|
|
3569
3730
|
const handler = this.effectHandlers[pp];
|
|
3570
3731
|
this.processActiveNotes(channel, scheduleTime, (note) => {
|
|
3571
3732
|
if (handler)
|
|
3572
|
-
handler(channel, note, scheduleTime);
|
|
3733
|
+
handler(channel, note, tableName, scheduleTime);
|
|
3573
3734
|
});
|
|
3574
3735
|
}
|
|
3575
3736
|
}
|
|
@@ -3589,7 +3750,7 @@ class Midy extends EventTarget {
|
|
|
3589
3750
|
const handler = this.effectHandlers[pp];
|
|
3590
3751
|
this.processActiveNotes(channel, scheduleTime, (note) => {
|
|
3591
3752
|
if (handler)
|
|
3592
|
-
handler(channel, note, scheduleTime);
|
|
3753
|
+
handler(channel, note, "controlTable", scheduleTime);
|
|
3593
3754
|
});
|
|
3594
3755
|
}
|
|
3595
3756
|
}
|