@marmooo/midy 0.4.6 → 0.4.8
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/esm/midy-GM1.d.ts +3 -0
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +115 -53
- package/esm/midy-GM2.d.ts +16 -4
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +255 -159
- package/esm/midy-GMLite.d.ts +2 -0
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +109 -53
- package/esm/midy.d.ts +34 -11
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +352 -223
- package/package.json +3 -2
- package/script/midy-GM1.d.ts +3 -0
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +115 -53
- package/script/midy-GM2.d.ts +16 -4
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +255 -159
- package/script/midy-GMLite.d.ts +2 -0
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +109 -53
- package/script/midy.d.ts +34 -11
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +352 -223
package/esm/midy-GM1.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export class MidyGM1 extends EventTarget {
|
|
|
27
27
|
voiceCounter: Map<any, any>;
|
|
28
28
|
voiceCache: Map<any, any>;
|
|
29
29
|
realtimeVoiceCache: Map<any, any>;
|
|
30
|
+
decodeMethod: string;
|
|
31
|
+
decoderQueue: Promise<void>;
|
|
30
32
|
isPlaying: boolean;
|
|
31
33
|
isPausing: boolean;
|
|
32
34
|
isPaused: boolean;
|
|
@@ -72,6 +74,7 @@ export class MidyGM1 extends EventTarget {
|
|
|
72
74
|
merger: any;
|
|
73
75
|
};
|
|
74
76
|
createChannels(audioContext: any): any[];
|
|
77
|
+
decodeOggVorbis(sample: any): Promise<any>;
|
|
75
78
|
createAudioBuffer(voiceParams: any): Promise<any>;
|
|
76
79
|
createBufferSource(voiceParams: any, audioBuffer: any): any;
|
|
77
80
|
scheduleTimelineEvents(scheduleTime: any, queueIndex: any): any;
|
package/esm/midy-GM1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"AAmHA;IAsCE;;;;;;;;;;;MAWE;IAEF,+BAgBC;IA9DD,gCAAgC;IAChC,aAAa;IACb,oBAAiB;IACjB,qBAAmB;IACnB,kBAAc;IACd,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,0BAAuD;IACvD,4BAAyB;IACzB,0BAAuB;IACvB,kCAA+B;IAC/B,qBAAqC;IACrC,4BAAiC;IACjC,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,iCAEG;IACH,cAAU;IACV,cAAa;IACb,iBAAY;IACZ,gBAAc;IACd,oBAAkB;IAClB,sBAAwB;IACxB,2BAAqC;IAiBnC,kBAAgC;IAChC,kBAA8C;IAC9C,eAAwD;IACxD,qBAGE;IACF,uBAAmD;IACnD;;;;;;;;;;;;MAA2D;IAC3D,6BAA+D;IAC/D,gBAAiD;IAMnD,mCASC;IAED,2DAYC;IAED,yCAmBC;IAED,oCASC;IAED,sBA6BC;IAED,8DAeC;IAED;;;;MAeC;IAED,yCAaC;IAED,2CAsBC;IAED,kDA6BC;IAED,4DASC;IAED,gEAsDC;IAED,mCASC;IAED,uBAUC;IAED,yDAqCC;IAED,2BA0EC;IAED,uDAEC;IAED,wDAEC;IAED,qCAKC;IAED;;;MAwDC;IAED,kGAeC;IAED,mGAeC;IAED,wEAQC;IAED,uBAMC;IAED,sBAIC;IAED,uBAMC;IAED,wBAIC;IAED,0BAKC;IAED,8BAMC;IAED,wBAYC;IAED,sBAIC;IAED,kEAWC;IAED,kFAYC;IAED,8BAEC;IAED,8BAEC;IAED,4BAEC;IAED,qCAMC;IAED,2DAIC;IAED,6CAEC;IAED,sDAeC;IAED,4DASC;IAED,qDAkBC;IAED,6CAIC;IAED,sDA6BC;IAED,kEAqBC;IAED,4GAkCC;IAED,uEAyCC;IAED,0EAiBC;IAED,oEASC;IAED,0FAwBC;IAED,gCASC;IAED,iEAwBC;IAED,4FAmBC;IAED,6CAUC;IAED,qDAUC;IAED,qFAeC;IAED,+BAmBC;IAED,kDAOC;IAED,sFA2BC;IAED,mFAGC;IAED,wFAGC;IAED,sEAUC;IAED,mEAYC;IAED,wDAKC;IAED,sDAOC;IAED,mDAMC;IAED,kDAKC;IAED;;;;;;;;;;;;MAoCC;IAED,oFAMC;IAED,6EA2BC;IAED,qCAeC;IAED,+FAYC;IAED,wDAUC;IAED,4EAKC;IAED,mEAKC;IAED;;;MAMC;IAED,gEAKC;IAED,uEAKC;IAED,sEAGC;IAED,2DAUC;IAED,yEAWC;IAED,kFAeC;IAED,2DAMC;IAED,uDAoBC;IAED,gDAEC;IAED,gDAEC;IAED,sEAGC;IAED,qEAKC;IAED,2EAUC;IAED,iEAMC;IAED,uEAQC;IAED,mEAKC;IAED,yEAQC;IAED,gFAGC;IAED,6CAqBC;IAGD,8EAgCC;IAED,gFAGC;IAED,+EAgBC;IAED,qCAUC;IAED,4EAaC;IAED,4DAGC;IAED,qDAKC;IAED,gDAYC;IAGD,6DAgBC;CACF"}
|
package/esm/midy-GM1.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { parseMidi } from "midi-file";
|
|
2
2
|
import { parse, SoundFont } from "@marmooo/soundfont-parser";
|
|
3
|
+
import { OggVorbisDecoderWebWorker } from "@wasm-audio-decoders/ogg-vorbis";
|
|
4
|
+
let decoderPromise = null;
|
|
5
|
+
let decoderQueue = Promise.resolve();
|
|
6
|
+
function initDecoder() {
|
|
7
|
+
if (!decoderPromise) {
|
|
8
|
+
const instance = new OggVorbisDecoderWebWorker();
|
|
9
|
+
decoderPromise = instance.ready.then(() => instance);
|
|
10
|
+
}
|
|
11
|
+
return decoderPromise;
|
|
12
|
+
}
|
|
3
13
|
class Note {
|
|
4
14
|
constructor(noteNumber, velocity, startTime) {
|
|
5
15
|
Object.defineProperty(this, "voice", {
|
|
@@ -38,37 +48,37 @@ class Note {
|
|
|
38
48
|
writable: true,
|
|
39
49
|
value: void 0
|
|
40
50
|
});
|
|
41
|
-
Object.defineProperty(this, "
|
|
51
|
+
Object.defineProperty(this, "filterEnvelopeNode", {
|
|
42
52
|
enumerable: true,
|
|
43
53
|
configurable: true,
|
|
44
54
|
writable: true,
|
|
45
55
|
value: void 0
|
|
46
56
|
});
|
|
47
|
-
Object.defineProperty(this, "
|
|
57
|
+
Object.defineProperty(this, "volumeEnvelopeNode", {
|
|
48
58
|
enumerable: true,
|
|
49
59
|
configurable: true,
|
|
50
60
|
writable: true,
|
|
51
61
|
value: void 0
|
|
52
62
|
});
|
|
53
|
-
Object.defineProperty(this, "
|
|
63
|
+
Object.defineProperty(this, "modLfo", {
|
|
54
64
|
enumerable: true,
|
|
55
65
|
configurable: true,
|
|
56
66
|
writable: true,
|
|
57
67
|
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "
|
|
68
|
+
}); // CC#1 modulation LFO
|
|
69
|
+
Object.defineProperty(this, "modLfoToPitch", {
|
|
60
70
|
enumerable: true,
|
|
61
71
|
configurable: true,
|
|
62
72
|
writable: true,
|
|
63
73
|
value: void 0
|
|
64
74
|
});
|
|
65
|
-
Object.defineProperty(this, "
|
|
75
|
+
Object.defineProperty(this, "modLfoToFilterFc", {
|
|
66
76
|
enumerable: true,
|
|
67
77
|
configurable: true,
|
|
68
78
|
writable: true,
|
|
69
79
|
value: void 0
|
|
70
80
|
});
|
|
71
|
-
Object.defineProperty(this, "
|
|
81
|
+
Object.defineProperty(this, "modLfoToVolume", {
|
|
72
82
|
enumerable: true,
|
|
73
83
|
configurable: true,
|
|
74
84
|
writable: true,
|
|
@@ -255,6 +265,18 @@ export class MidyGM1 extends EventTarget {
|
|
|
255
265
|
writable: true,
|
|
256
266
|
value: new Map()
|
|
257
267
|
});
|
|
268
|
+
Object.defineProperty(this, "decodeMethod", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
configurable: true,
|
|
271
|
+
writable: true,
|
|
272
|
+
value: "wasm-audio-decoders"
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(this, "decoderQueue", {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
configurable: true,
|
|
277
|
+
writable: true,
|
|
278
|
+
value: Promise.resolve()
|
|
279
|
+
});
|
|
258
280
|
Object.defineProperty(this, "isPlaying", {
|
|
259
281
|
enumerable: true,
|
|
260
282
|
configurable: true,
|
|
@@ -416,14 +438,6 @@ export class MidyGM1 extends EventTarget {
|
|
|
416
438
|
voiceCounter.set(audioBufferId, (voiceCounter.get(audioBufferId) ?? 0) + 1);
|
|
417
439
|
break;
|
|
418
440
|
}
|
|
419
|
-
case "controller":
|
|
420
|
-
if (event.controllerType === 0) {
|
|
421
|
-
this.setBankMSB(event.channel, event.value);
|
|
422
|
-
}
|
|
423
|
-
else if (event.controllerType === 32) {
|
|
424
|
-
this.setBankLSB(event.channel, event.value);
|
|
425
|
-
}
|
|
426
|
-
break;
|
|
427
441
|
case "programChange":
|
|
428
442
|
this.setProgramChange(event.channel, event.programNumber, event.startTime);
|
|
429
443
|
}
|
|
@@ -481,11 +495,57 @@ export class MidyGM1 extends EventTarget {
|
|
|
481
495
|
});
|
|
482
496
|
return channels;
|
|
483
497
|
}
|
|
498
|
+
decodeOggVorbis(sample) {
|
|
499
|
+
const task = decoderQueue.then(async () => {
|
|
500
|
+
const decoder = await initDecoder();
|
|
501
|
+
const slice = sample.data.slice();
|
|
502
|
+
const { channelData, sampleRate, errors } = await decoder.decodeFile(slice);
|
|
503
|
+
if (0 < errors.length) {
|
|
504
|
+
throw new Error(errors.join(", "));
|
|
505
|
+
}
|
|
506
|
+
const audioBuffer = new AudioBuffer({
|
|
507
|
+
numberOfChannels: channelData.length,
|
|
508
|
+
length: channelData[0].length,
|
|
509
|
+
sampleRate,
|
|
510
|
+
});
|
|
511
|
+
for (let ch = 0; ch < channelData.length; ch++) {
|
|
512
|
+
audioBuffer.getChannelData(ch).set(channelData[ch]);
|
|
513
|
+
}
|
|
514
|
+
return audioBuffer;
|
|
515
|
+
});
|
|
516
|
+
decoderQueue = task.catch(() => { });
|
|
517
|
+
return task;
|
|
518
|
+
}
|
|
484
519
|
async createAudioBuffer(voiceParams) {
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
520
|
+
const sample = voiceParams.sample;
|
|
521
|
+
if (sample.type === "compressed") {
|
|
522
|
+
switch (this.decodeMethod) {
|
|
523
|
+
case "decodeAudioData": {
|
|
524
|
+
// https://jakearchibald.com/2016/sounds-fun/
|
|
525
|
+
// https://github.com/WebAudio/web-audio-api/issues/1091
|
|
526
|
+
// decodeAudioData() has priming issues on Safari
|
|
527
|
+
const arrayBuffer = sample.data.slice().buffer;
|
|
528
|
+
return await this.audioContext.decodeAudioData(arrayBuffer);
|
|
529
|
+
}
|
|
530
|
+
case "wasm-audio-decoders":
|
|
531
|
+
return await this.decodeOggVorbis(sample);
|
|
532
|
+
default:
|
|
533
|
+
throw new Error(`Unknown decodeMethod: ${this.decodeMethod}`);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
const data = sample.data;
|
|
538
|
+
const end = data.length + voiceParams.end;
|
|
539
|
+
const subarray = data.subarray(voiceParams.start, end);
|
|
540
|
+
const pcm = sample.decodePCM(subarray);
|
|
541
|
+
const audioBuffer = new AudioBuffer({
|
|
542
|
+
numberOfChannels: 1,
|
|
543
|
+
length: pcm.length,
|
|
544
|
+
sampleRate: sample.sampleHeader.sampleRate,
|
|
545
|
+
});
|
|
546
|
+
audioBuffer.getChannelData(0).set(pcm);
|
|
547
|
+
return audioBuffer;
|
|
548
|
+
}
|
|
489
549
|
}
|
|
490
550
|
createBufferSource(voiceParams, audioBuffer) {
|
|
491
551
|
const bufferSource = new AudioBufferSourceNode(this.audioContext);
|
|
@@ -551,7 +611,7 @@ export class MidyGM1 extends EventTarget {
|
|
|
551
611
|
const channels = this.channels;
|
|
552
612
|
for (let ch = 0; ch < channels.length; ch++) {
|
|
553
613
|
channels[ch].scheduledNotes = [];
|
|
554
|
-
this.resetChannelStates(
|
|
614
|
+
this.resetChannelStates(ch);
|
|
555
615
|
}
|
|
556
616
|
}
|
|
557
617
|
updateStates(queueIndex, nextQueueIndex) {
|
|
@@ -934,7 +994,7 @@ export class MidyGM1 extends EventTarget {
|
|
|
934
994
|
const modHold = modAttack + voiceParams.modHold;
|
|
935
995
|
const decayDuration = voiceParams.modDecay;
|
|
936
996
|
note.adjustedBaseFreq = adjustedBaseFreq;
|
|
937
|
-
note.
|
|
997
|
+
note.filterEnvelopeNode.frequency
|
|
938
998
|
.cancelScheduledValues(scheduleTime)
|
|
939
999
|
.setValueAtTime(adjustedBaseFreq, startTime)
|
|
940
1000
|
.setValueAtTime(adjustedBaseFreq, modDelay)
|
|
@@ -945,23 +1005,23 @@ export class MidyGM1 extends EventTarget {
|
|
|
945
1005
|
startModulation(channel, note, scheduleTime) {
|
|
946
1006
|
const audioContext = this.audioContext;
|
|
947
1007
|
const { voiceParams } = note;
|
|
948
|
-
note.
|
|
1008
|
+
note.modLfo = new OscillatorNode(audioContext, {
|
|
949
1009
|
frequency: this.centToHz(voiceParams.freqModLFO),
|
|
950
1010
|
});
|
|
951
|
-
note.
|
|
1011
|
+
note.modLfoToFilterFc = new GainNode(audioContext, {
|
|
952
1012
|
gain: voiceParams.modLfoToFilterFc,
|
|
953
1013
|
});
|
|
954
|
-
note.
|
|
1014
|
+
note.modLfoToPitch = new GainNode(audioContext);
|
|
955
1015
|
this.setModLfoToPitch(channel, note, scheduleTime);
|
|
956
|
-
note.
|
|
1016
|
+
note.modLfoToVolume = new GainNode(audioContext);
|
|
957
1017
|
this.setModLfoToVolume(note, scheduleTime);
|
|
958
|
-
note.
|
|
959
|
-
note.
|
|
960
|
-
note.
|
|
961
|
-
note.
|
|
962
|
-
note.
|
|
963
|
-
note.
|
|
964
|
-
note.
|
|
1018
|
+
note.modLfo.start(note.startTime + voiceParams.delayModLFO);
|
|
1019
|
+
note.modLfo.connect(note.modLfoToFilterFc);
|
|
1020
|
+
note.modLfoToFilterFc.connect(note.filterEnvelopeNode.frequency);
|
|
1021
|
+
note.modLfo.connect(note.modLfoToPitch);
|
|
1022
|
+
note.modLfoToPitch.connect(note.bufferSource.detune);
|
|
1023
|
+
note.modLfo.connect(note.modLfoToVolume);
|
|
1024
|
+
note.modLfoToVolume.connect(note.volumeEnvelopeNode.gain);
|
|
965
1025
|
}
|
|
966
1026
|
async getAudioBuffer(channel, noteNumber, velocity, voiceParams, realtime) {
|
|
967
1027
|
const audioBufferId = this.getVoiceId(channel, noteNumber, velocity);
|
|
@@ -1002,7 +1062,7 @@ export class MidyGM1 extends EventTarget {
|
|
|
1002
1062
|
const audioBuffer = await this.getAudioBuffer(channel, noteNumber, velocity, voiceParams, realtime);
|
|
1003
1063
|
note.bufferSource = this.createBufferSource(voiceParams, audioBuffer);
|
|
1004
1064
|
note.volumeEnvelopeNode = new GainNode(audioContext);
|
|
1005
|
-
note.
|
|
1065
|
+
note.filterEnvelopeNode = new BiquadFilterNode(audioContext, {
|
|
1006
1066
|
type: "lowpass",
|
|
1007
1067
|
Q: voiceParams.initialFilterQ / 10, // dB
|
|
1008
1068
|
});
|
|
@@ -1013,8 +1073,8 @@ export class MidyGM1 extends EventTarget {
|
|
|
1013
1073
|
if (0 < state.modulationDepthMSB) {
|
|
1014
1074
|
this.startModulation(channel, note, now);
|
|
1015
1075
|
}
|
|
1016
|
-
note.bufferSource.connect(note.
|
|
1017
|
-
note.
|
|
1076
|
+
note.bufferSource.connect(note.filterEnvelopeNode);
|
|
1077
|
+
note.filterEnvelopeNode.connect(note.volumeEnvelopeNode);
|
|
1018
1078
|
if (voiceParams.sample.type === "compressed") {
|
|
1019
1079
|
const offset = voiceParams.start / audioBuffer.sampleRate;
|
|
1020
1080
|
note.bufferSource.start(startTime, offset);
|
|
@@ -1080,19 +1140,19 @@ export class MidyGM1 extends EventTarget {
|
|
|
1080
1140
|
}
|
|
1081
1141
|
disconnectNote(note) {
|
|
1082
1142
|
note.bufferSource.disconnect();
|
|
1083
|
-
note.
|
|
1143
|
+
note.filterEnvelopeNode.disconnect();
|
|
1084
1144
|
note.volumeEnvelopeNode.disconnect();
|
|
1085
|
-
if (note.
|
|
1086
|
-
note.
|
|
1087
|
-
note.
|
|
1088
|
-
note.
|
|
1145
|
+
if (note.modLfoToPitch) {
|
|
1146
|
+
note.modLfoToVolume.disconnect();
|
|
1147
|
+
note.modLfoToPitch.disconnect();
|
|
1148
|
+
note.modLfo.stop();
|
|
1089
1149
|
}
|
|
1090
1150
|
}
|
|
1091
1151
|
releaseNote(channel, note, endTime) {
|
|
1092
1152
|
endTime ??= this.audioContext.currentTime;
|
|
1093
1153
|
const volDuration = note.voiceParams.volRelease;
|
|
1094
1154
|
const volRelease = endTime + volDuration;
|
|
1095
|
-
note.
|
|
1155
|
+
note.filterEnvelopeNode.frequency
|
|
1096
1156
|
.cancelScheduledValues(endTime)
|
|
1097
1157
|
.setTargetAtTime(note.adjustedBaseFreq, endTime, note.voiceParams.modRelease * releaseCurve);
|
|
1098
1158
|
note.volumeEnvelopeNode.gain
|
|
@@ -1220,12 +1280,12 @@ export class MidyGM1 extends EventTarget {
|
|
|
1220
1280
|
this.applyVoiceParams(channel, 14, scheduleTime);
|
|
1221
1281
|
}
|
|
1222
1282
|
setModLfoToPitch(channel, note, scheduleTime) {
|
|
1223
|
-
if (note.
|
|
1283
|
+
if (note.modLfoToPitch) {
|
|
1224
1284
|
const modLfoToPitch = note.voiceParams.modLfoToPitch;
|
|
1225
1285
|
const baseDepth = Math.abs(modLfoToPitch) +
|
|
1226
1286
|
channel.state.modulationDepthMSB;
|
|
1227
1287
|
const depth = baseDepth * Math.sign(modLfoToPitch);
|
|
1228
|
-
note.
|
|
1288
|
+
note.modLfoToPitch.gain
|
|
1229
1289
|
.cancelScheduledValues(scheduleTime)
|
|
1230
1290
|
.setValueAtTime(depth, scheduleTime);
|
|
1231
1291
|
}
|
|
@@ -1235,29 +1295,29 @@ export class MidyGM1 extends EventTarget {
|
|
|
1235
1295
|
}
|
|
1236
1296
|
setModLfoToFilterFc(note, scheduleTime) {
|
|
1237
1297
|
const modLfoToFilterFc = note.voiceParams.modLfoToFilterFc;
|
|
1238
|
-
note.
|
|
1298
|
+
note.modLfoToFilterFc.gain
|
|
1239
1299
|
.cancelScheduledValues(scheduleTime)
|
|
1240
1300
|
.setValueAtTime(modLfoToFilterFc, scheduleTime);
|
|
1241
1301
|
}
|
|
1242
1302
|
setModLfoToVolume(note, scheduleTime) {
|
|
1243
1303
|
const modLfoToVolume = note.voiceParams.modLfoToVolume;
|
|
1244
1304
|
const baseDepth = cbToRatio(Math.abs(modLfoToVolume)) - 1;
|
|
1245
|
-
const
|
|
1246
|
-
note.
|
|
1305
|
+
const depth = baseDepth * Math.sign(modLfoToVolume);
|
|
1306
|
+
note.modLfoToVolume.gain
|
|
1247
1307
|
.cancelScheduledValues(scheduleTime)
|
|
1248
|
-
.setValueAtTime(
|
|
1308
|
+
.setValueAtTime(depth, scheduleTime);
|
|
1249
1309
|
}
|
|
1250
1310
|
setDelayModLFO(note, scheduleTime) {
|
|
1251
1311
|
const startTime = note.startTime;
|
|
1252
1312
|
if (startTime < scheduleTime)
|
|
1253
1313
|
return;
|
|
1254
|
-
note.
|
|
1255
|
-
note.
|
|
1256
|
-
note.
|
|
1314
|
+
note.modLfo.stop(scheduleTime);
|
|
1315
|
+
note.modLfo.start(startTime + note.voiceParams.delayModLFO);
|
|
1316
|
+
note.modLfo.connect(note.modLfoToFilterFc);
|
|
1257
1317
|
}
|
|
1258
1318
|
setFreqModLFO(note, scheduleTime) {
|
|
1259
1319
|
const freqModLFO = note.voiceParams.freqModLFO;
|
|
1260
|
-
note.
|
|
1320
|
+
note.modLfo.frequency
|
|
1261
1321
|
.cancelScheduledValues(scheduleTime)
|
|
1262
1322
|
.setValueAtTime(freqModLFO, scheduleTime);
|
|
1263
1323
|
}
|
|
@@ -1354,6 +1414,8 @@ export class MidyGM1 extends EventTarget {
|
|
|
1354
1414
|
return handlers;
|
|
1355
1415
|
}
|
|
1356
1416
|
setControlChange(channelNumber, controllerType, value, scheduleTime) {
|
|
1417
|
+
if (!(0 <= scheduleTime))
|
|
1418
|
+
scheduleTime = this.audioContext.currentTime;
|
|
1357
1419
|
const handler = this.controlChangeHandlers[controllerType];
|
|
1358
1420
|
if (handler) {
|
|
1359
1421
|
handler.call(this, channelNumber, value, scheduleTime);
|
|
@@ -1368,8 +1430,8 @@ export class MidyGM1 extends EventTarget {
|
|
|
1368
1430
|
const depth = channel.state.modulationDepthMSB *
|
|
1369
1431
|
channel.modulationDepthRange;
|
|
1370
1432
|
this.processScheduledNotes(channel, (note) => {
|
|
1371
|
-
if (note.
|
|
1372
|
-
note.
|
|
1433
|
+
if (note.modLfoToPitch) {
|
|
1434
|
+
note.modLfoToPitch.gain.setValueAtTime(depth, scheduleTime);
|
|
1373
1435
|
}
|
|
1374
1436
|
else {
|
|
1375
1437
|
this.startModulation(channel, note, scheduleTime);
|
package/esm/midy-GM2.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
46
46
|
voiceCounter: Map<any, any>;
|
|
47
47
|
voiceCache: Map<any, any>;
|
|
48
48
|
realtimeVoiceCache: Map<any, any>;
|
|
49
|
+
decodeMethod: string;
|
|
49
50
|
isPlaying: boolean;
|
|
50
51
|
isPausing: boolean;
|
|
51
52
|
isPaused: boolean;
|
|
@@ -80,6 +81,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
80
81
|
};
|
|
81
82
|
controlChangeHandlers: any[];
|
|
82
83
|
keyBasedControllerHandlers: any[];
|
|
84
|
+
effectHandlers: any[];
|
|
83
85
|
channels: any[];
|
|
84
86
|
reverbEffect: {
|
|
85
87
|
input: any;
|
|
@@ -107,6 +109,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
107
109
|
};
|
|
108
110
|
resetChannelTable(channel: any): void;
|
|
109
111
|
createChannels(audioContext: any): any[];
|
|
112
|
+
decodeOggVorbis(sample: any): Promise<any>;
|
|
110
113
|
createAudioBuffer(voiceParams: any): Promise<any>;
|
|
111
114
|
isLoopDrum(channel: any, noteNumber: any): boolean;
|
|
112
115
|
createBufferSource(channel: any, noteNumber: any, voiceParams: any, audioBuffer: any): any;
|
|
@@ -234,6 +237,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
234
237
|
updatePortamento(channel: any, scheduleTime: any): void;
|
|
235
238
|
setPortamentoTime(channelNumber: any, value: any, scheduleTime: any): void;
|
|
236
239
|
setVolume(channelNumber: any, value: any, scheduleTime: any): void;
|
|
240
|
+
applyVolume(channel: any, scheduleTime: any): void;
|
|
237
241
|
panToGain(pan: any): {
|
|
238
242
|
gainLeft: number;
|
|
239
243
|
gainRight: number;
|
|
@@ -304,15 +308,23 @@ export class MidyGM2 extends EventTarget {
|
|
|
304
308
|
getChorusSendToReverb(value: any): number;
|
|
305
309
|
getChannelBitmap(data: any): any[];
|
|
306
310
|
handleScaleOctaveTuning1ByteFormatSysEx(data: any, realtime: any, scheduleTime: any): void;
|
|
311
|
+
calcEffectValue(channel: any, destination: any): number;
|
|
312
|
+
calcChannelEffectValue(channel: any, destination: any): number;
|
|
313
|
+
calcControlChangeEffectValue(channel: any, destination: any): number;
|
|
314
|
+
calcChannelPressureEffectValue(channel: any, destination: any): number;
|
|
315
|
+
getChannelPitchControl(channel: any): number;
|
|
316
|
+
getPitchControl(channel: any, note: any): number;
|
|
307
317
|
getFilterCutoffControl(channel: any): number;
|
|
308
|
-
|
|
318
|
+
getChannelAmplitudeControl(channel: any): number;
|
|
309
319
|
getLFOPitchDepth(channel: any): number;
|
|
310
320
|
getLFOFilterDepth(channel: any): number;
|
|
311
321
|
getLFOAmplitudeDepth(channel: any): number;
|
|
312
|
-
|
|
322
|
+
createEffectHandlers(): any[];
|
|
323
|
+
setControlChangeEffects(channel: any, note: any, scheduleTime: any): void;
|
|
324
|
+
setChannelPressureEffects(channel: any, note: any, scheduleTime: any): void;
|
|
325
|
+
setPressureEffects(channel: any, note: any, tableName: any, scheduleTime: any): void;
|
|
326
|
+
handleChannelPressureSysEx(data: any, scheduleTime: any): void;
|
|
313
327
|
handlePressureSysEx(data: any, tableName: any, scheduleTime: any): void;
|
|
314
|
-
initControlTable(): Int8Array<ArrayBuffer>;
|
|
315
|
-
setControlChangeEffects(channel: any, controllerType: any, scheduleTime: any): void;
|
|
316
328
|
handleControlChangeSysEx(data: any, scheduleTime: any): void;
|
|
317
329
|
getKeyBasedValue(channel: any, keyNumber: any, controllerType: any): any;
|
|
318
330
|
createKeyBasedControllerHandlers(): any[];
|
package/esm/midy-GM2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"AAwLA;IAwDE;;;;;;;;;;;;;;MAcE;IAEF,+BAsBC;IAzFD,gCAAgC;IAChC,aAAa;IACb,yBAAqB;IACrB,2BAAuB;IACvB;;;;MAIE;IACF;;;;;;MAME;IACF,oBAAiB;IACjB,qBAAmB;IACnB,kBAAc;IACd,0BAAsB;IACtB,+BAA6B;IAC7B,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,0BAAuD;IACvD,4BAAyB;IACzB,0BAAuB;IACvB,kCAA+B;IA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,sCAEC;IAED,uDASC;IAED,sCAEC;IAED,2DAqBC;IAED,0CAEC;IAED,mCAeC;IAED,2FAgBC;IAED,wDAEC;IAED,+DAGC;IAED,qEASC;IAED,uEAOC;IAED,6CAEC;IAED,iDAEC;IAED,6CAEC;IAED,iDAEC;IAED,uCAEC;IAED,wCAEC;IAED,2CAEC;IAED,8BAyBC;IAED,0EAQC;IAED,4EAOC;IAED,qFASC;IAED,+DAEC;IAED,wEAcC;IAED,6DAiBC;IAED,yEAIC;IAED,0CAmBC;IAED,yEAcC;IAED,gDAYC;IAGD,6DAgBC;CACF"}
|