@marmooo/midy 0.0.7 → 0.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/esm/midy-GM1.d.ts +12 -47
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +70 -53
- package/esm/midy-GM2.d.ts +52 -109
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +187 -95
- package/esm/midy-GMLite.d.ts +8 -41
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +53 -46
- package/esm/midy.d.ts +55 -134
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +191 -100
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +12 -47
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +70 -53
- package/script/midy-GM2.d.ts +52 -109
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +187 -95
- package/script/midy-GMLite.d.ts +8 -41
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +53 -46
- package/script/midy.d.ts +55 -134
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +191 -100
package/script/midy-GM1.d.ts
CHANGED
|
@@ -39,27 +39,7 @@ export class MidyGM1 {
|
|
|
39
39
|
notePromises: any[];
|
|
40
40
|
audioContext: any;
|
|
41
41
|
masterGain: any;
|
|
42
|
-
channels:
|
|
43
|
-
scheduledNotes: Map<any, any>;
|
|
44
|
-
gainL: any;
|
|
45
|
-
gainR: any;
|
|
46
|
-
expression: number;
|
|
47
|
-
modulation: number;
|
|
48
|
-
sustainPedal: boolean;
|
|
49
|
-
rpnMSB: number;
|
|
50
|
-
rpnLSB: number;
|
|
51
|
-
pitchBendRange: number;
|
|
52
|
-
volume: number;
|
|
53
|
-
pan: number;
|
|
54
|
-
bank: number;
|
|
55
|
-
dataMSB: number;
|
|
56
|
-
dataLSB: number;
|
|
57
|
-
program: number;
|
|
58
|
-
pitchBend: number;
|
|
59
|
-
fineTuning: number;
|
|
60
|
-
coarseTuning: number;
|
|
61
|
-
modulationDepthRange: number;
|
|
62
|
-
}[];
|
|
42
|
+
channels: any[];
|
|
63
43
|
initSoundFontTable(): any[];
|
|
64
44
|
addSoundFont(soundFont: any): void;
|
|
65
45
|
loadSoundFont(soundFontUrl: any): Promise<void>;
|
|
@@ -67,28 +47,11 @@ export class MidyGM1 {
|
|
|
67
47
|
setChannelAudioNodes(audioContext: any): {
|
|
68
48
|
gainL: any;
|
|
69
49
|
gainR: any;
|
|
50
|
+
merger: any;
|
|
51
|
+
reverbEffect: any;
|
|
52
|
+
chorusEffect: any;
|
|
70
53
|
};
|
|
71
|
-
createChannels(audioContext: any):
|
|
72
|
-
scheduledNotes: Map<any, any>;
|
|
73
|
-
gainL: any;
|
|
74
|
-
gainR: any;
|
|
75
|
-
expression: number;
|
|
76
|
-
modulation: number;
|
|
77
|
-
sustainPedal: boolean;
|
|
78
|
-
rpnMSB: number;
|
|
79
|
-
rpnLSB: number;
|
|
80
|
-
pitchBendRange: number;
|
|
81
|
-
volume: number;
|
|
82
|
-
pan: number;
|
|
83
|
-
bank: number;
|
|
84
|
-
dataMSB: number;
|
|
85
|
-
dataLSB: number;
|
|
86
|
-
program: number;
|
|
87
|
-
pitchBend: number;
|
|
88
|
-
fineTuning: number;
|
|
89
|
-
coarseTuning: number;
|
|
90
|
-
modulationDepthRange: number;
|
|
91
|
-
}[];
|
|
54
|
+
createChannels(audioContext: any): any[];
|
|
92
55
|
createNoteBuffer(instrumentKey: any, isSF3: any): Promise<any>;
|
|
93
56
|
createNoteBufferNode(instrumentKey: any, isSF3: any): Promise<any>;
|
|
94
57
|
convertToFloat32Array(uint8Array: any): Float32Array;
|
|
@@ -111,7 +74,7 @@ export class MidyGM1 {
|
|
|
111
74
|
currentTime(): number;
|
|
112
75
|
getActiveNotes(channel: any, time: any): Map<any, any>;
|
|
113
76
|
getActiveNote(noteList: any, time: any): any;
|
|
114
|
-
|
|
77
|
+
connectEffects(channel: any, gainNode: any): void;
|
|
115
78
|
cbToRatio(cb: any): number;
|
|
116
79
|
centToHz(cent: any): number;
|
|
117
80
|
calcSemitoneOffset(channel: any): any;
|
|
@@ -130,6 +93,7 @@ export class MidyGM1 {
|
|
|
130
93
|
handlePitchBendMessage(channelNumber: any, lsb: any, msb: any): void;
|
|
131
94
|
setPitchBend(channelNumber: any, pitchBend: any): void;
|
|
132
95
|
handleControlChange(channelNumber: any, controller: any, value: any): void | any[];
|
|
96
|
+
updateModulation(channel: any): void;
|
|
133
97
|
setModulation(channelNumber: any, modulation: any): void;
|
|
134
98
|
setVolume(channelNumber: any, volume: any): void;
|
|
135
99
|
panToGain(pan: any): {
|
|
@@ -138,6 +102,7 @@ export class MidyGM1 {
|
|
|
138
102
|
};
|
|
139
103
|
setPan(channelNumber: any, pan: any): void;
|
|
140
104
|
setExpression(channelNumber: any, expression: any): void;
|
|
105
|
+
dataEntryLSB(channelNumber: any, value: any): void;
|
|
141
106
|
updateChannelGain(channel: any): void;
|
|
142
107
|
setSustainPedal(channelNumber: any, value: any): void;
|
|
143
108
|
limitData(channel: any, minMSB: any, maxMSB: any, minLSB: any, maxLSB: any): void;
|
|
@@ -145,13 +110,13 @@ export class MidyGM1 {
|
|
|
145
110
|
handleRPN(channelNumber: any): void;
|
|
146
111
|
setRPNMSB(channelNumber: any, value: any): void;
|
|
147
112
|
setRPNLSB(channelNumber: any, value: any): void;
|
|
148
|
-
|
|
113
|
+
dataEntryMSB(channelNumber: any, value: any): void;
|
|
149
114
|
updateDetune(channel: any, detuneChange: any): void;
|
|
150
|
-
|
|
115
|
+
handlePitchBendRangeRPN(channelNumber: any): void;
|
|
151
116
|
setPitchBendRange(channelNumber: any, pitchBendRange: any): void;
|
|
152
|
-
|
|
117
|
+
handleFineTuningRPN(channelNumber: any): void;
|
|
153
118
|
setFineTuning(channelNumber: any, fineTuning: any): void;
|
|
154
|
-
|
|
119
|
+
handleCoarseTuningRPN(channelNumber: any): void;
|
|
155
120
|
setCoarseTuning(channelNumber: any, coarseTuning: any): void;
|
|
156
121
|
allSoundOff(channelNumber: any): any[];
|
|
157
122
|
resetAllControllers(channelNumber: any): void;
|
package/script/midy-GM1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"AAqBA;IAmBE;;;;;;;;;;;MAWE;IAEF;;;;;;;MAOE;IAEF,+BAMC;IA9CD,qBAAmB;IACnB,kBAAc;IACd,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,sBAA2C;IAC3C,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,gBAAc;IACd,mBAAiB;IACjB,oBAAkB;IAyBhB,kBAAgC;IAChC,gBAA4C;IAE5C
|
|
1
|
+
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"AAqBA;IAmBE;;;;;;;;;;;MAWE;IAEF;;;;;;;MAOE;IAEF,+BAMC;IA9CD,qBAAmB;IACnB,kBAAc;IACd,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,sBAA2C;IAC3C,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,gBAAc;IACd,mBAAiB;IACjB,oBAAkB;IAyBhB,kBAAgC;IAChC,gBAA4C;IAE5C,gBAAiD;IAInD,4BAMC;IAED,mCASC;IAED,gDAMC;IAED,sCASC;IAED;;;;;;MAkBC;IAED,yCAUC;IAED,+DAyBC;IAED,mEAWC;IAED,qDAOC;IAED,2EA+CC;IAED,mCAOC;IAED,0BA+CC;IAED,uDAEC;IAED,wDAEC;IAED;;;MA8DC;IAED,4BAsBC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,uDASC;IAED,6CAQC;IAED,kDAGC;IAED,2BAEC;IAED,4BAEC;IAED,sCAGC;IAED,mFAGC;IAED,iDAiBC;IAED,iDAiCC;IAED,0DAmBC;IAED,wHA6BC;IAED,kGA6BC;IAED,0EAGC;IAED,sIA8CC;IAED,0FAGC;IAED,kEAeC;IAED,wFAiBC;IAED,4DAGC;IAED,qEAGC;IAED,uDAOC;IAED,mFA+BC;IAED,qCAcC;IAED,yDAIC;IACD,iDAIC;IAED;;;MAMC;IAED,2CAIC;IAED,yDAIC;IAED,mDAGC;IAED,sCAUC;IAED,sDAMC;IAED,kFAeC;IAED,2DAMC;IAED,oCAkBC;IAED,gDAEC;IAED,gDAEC;IAED,mDAGC;IAED,oDAUC;IAED,kDAKC;IAED,iEAOC;IAED,8CAKC;IAED,yDAMC;IAED,gDAKC;IAED,6DAMC;IAED,uCAoBC;IAED,8CAEC;IAED,uCAoBC;IAED,4DAgBC;IAED,oBAQC;IAED,yDAaC;IAED,yCAGC;IAED,mCAQC;IAED,wCAEC;IAED,6BASC;IAED,0DAUC;CACF;AAvjCD;IAOE,gFAKC;IAXD,kBAAa;IACb,cAAS;IACT,gBAAW;IACX,YAAO;IACP,gBAAW;IAGT,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,mBAAkC;CAErC"}
|
package/script/midy-GM1.js
CHANGED
|
@@ -186,23 +186,27 @@ class MidyGM1 {
|
|
|
186
186
|
this.totalTime = this.calcTotalTime();
|
|
187
187
|
}
|
|
188
188
|
setChannelAudioNodes(audioContext) {
|
|
189
|
-
const { gainLeft, gainRight } = this.panToGain(
|
|
189
|
+
const { gainLeft, gainRight } = this.panToGain(this.constructor.channelSettings.pan);
|
|
190
190
|
const gainL = new GainNode(audioContext, { gain: gainLeft });
|
|
191
191
|
const gainR = new GainNode(audioContext, { gain: gainRight });
|
|
192
192
|
const merger = new ChannelMergerNode(audioContext, { numberOfInputs: 2 });
|
|
193
193
|
gainL.connect(merger, 0, 0);
|
|
194
194
|
gainR.connect(merger, 0, 1);
|
|
195
|
-
|
|
195
|
+
const reverbEffect = this.createConvolutionReverb(audioContext);
|
|
196
|
+
const chorusEffect = this.createChorusEffect(audioContext);
|
|
196
197
|
return {
|
|
197
198
|
gainL,
|
|
198
199
|
gainR,
|
|
200
|
+
merger,
|
|
201
|
+
reverbEffect,
|
|
202
|
+
chorusEffect,
|
|
199
203
|
};
|
|
200
204
|
}
|
|
201
205
|
createChannels(audioContext) {
|
|
202
206
|
const channels = Array.from({ length: 16 }, () => {
|
|
203
207
|
return {
|
|
204
|
-
...
|
|
205
|
-
...
|
|
208
|
+
...this.constructor.channelSettings,
|
|
209
|
+
...this.constructor.effectSettings,
|
|
206
210
|
...this.setChannelAudioNodes(audioContext),
|
|
207
211
|
scheduledNotes: new Map(),
|
|
208
212
|
};
|
|
@@ -494,9 +498,9 @@ class MidyGM1 {
|
|
|
494
498
|
}
|
|
495
499
|
return noteList[0];
|
|
496
500
|
}
|
|
497
|
-
|
|
498
|
-
gainNode.connect(channel.
|
|
499
|
-
|
|
501
|
+
connectEffects(channel, gainNode) {
|
|
502
|
+
gainNode.connect(channel.merger);
|
|
503
|
+
merger.connect(this.masterGain);
|
|
500
504
|
}
|
|
501
505
|
cbToRatio(cb) {
|
|
502
506
|
return Math.pow(10, cb / 200);
|
|
@@ -563,7 +567,7 @@ class MidyGM1 {
|
|
|
563
567
|
startModulation(channel, note, time) {
|
|
564
568
|
const { instrumentKey } = note;
|
|
565
569
|
note.modLFOGain = new GainNode(this.audioContext, {
|
|
566
|
-
gain: this.cbToRatio(instrumentKey.modLfoToVolume
|
|
570
|
+
gain: this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation),
|
|
567
571
|
});
|
|
568
572
|
note.modLFO = new OscillatorNode(this.audioContext, {
|
|
569
573
|
frequency: this.centToHz(instrumentKey.freqModLFO),
|
|
@@ -602,7 +606,7 @@ class MidyGM1 {
|
|
|
602
606
|
if (!instrumentKey)
|
|
603
607
|
return;
|
|
604
608
|
const note = await this.createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3);
|
|
605
|
-
this.
|
|
609
|
+
this.connectEffects(channel, note.gainNode);
|
|
606
610
|
const scheduledNotes = channel.scheduledNotes;
|
|
607
611
|
if (scheduledNotes.has(noteNumber)) {
|
|
608
612
|
scheduledNotes.get(noteNumber).push(note);
|
|
@@ -621,39 +625,41 @@ class MidyGM1 {
|
|
|
621
625
|
return;
|
|
622
626
|
if (!channel.scheduledNotes.has(noteNumber))
|
|
623
627
|
return;
|
|
624
|
-
const
|
|
625
|
-
for (let i = 0; i <
|
|
626
|
-
const
|
|
627
|
-
if (!
|
|
628
|
+
const scheduledNotes = channel.scheduledNotes.get(noteNumber);
|
|
629
|
+
for (let i = 0; i < scheduledNotes.length; i++) {
|
|
630
|
+
const note = scheduledNotes[i];
|
|
631
|
+
if (!note)
|
|
628
632
|
continue;
|
|
629
|
-
if (
|
|
633
|
+
if (note.ending)
|
|
630
634
|
continue;
|
|
631
|
-
const { bufferSource, filterNode, gainNode, modLFO, modLFOGain, instrumentKey, } = targetNote;
|
|
632
635
|
const velocityRate = (velocity + 127) / 127;
|
|
633
|
-
const volEndTime = stopTime +
|
|
634
|
-
|
|
635
|
-
gainNode.gain
|
|
636
|
+
const volEndTime = stopTime +
|
|
637
|
+
note.instrumentKey.volRelease * velocityRate;
|
|
638
|
+
note.gainNode.gain
|
|
639
|
+
.cancelScheduledValues(stopTime)
|
|
640
|
+
.linearRampToValueAtTime(0, volEndTime);
|
|
636
641
|
const maxFreq = this.audioContext.sampleRate / 2;
|
|
637
|
-
const baseFreq = this.centToHz(instrumentKey.initialFilterFc);
|
|
642
|
+
const baseFreq = this.centToHz(note.instrumentKey.initialFilterFc);
|
|
638
643
|
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
639
|
-
const modEndTime = stopTime +
|
|
640
|
-
|
|
644
|
+
const modEndTime = stopTime +
|
|
645
|
+
note.instrumentKey.modRelease * velocityRate;
|
|
646
|
+
note.filterNode.frequency
|
|
641
647
|
.cancelScheduledValues(stopTime)
|
|
642
648
|
.linearRampToValueAtTime(adjustedBaseFreq, modEndTime);
|
|
643
|
-
|
|
649
|
+
note.ending = true;
|
|
644
650
|
this.scheduleTask(() => {
|
|
645
|
-
bufferSource.loop = false;
|
|
651
|
+
note.bufferSource.loop = false;
|
|
646
652
|
}, stopTime);
|
|
647
653
|
return new Promise((resolve) => {
|
|
648
|
-
bufferSource.onended = () => {
|
|
649
|
-
|
|
650
|
-
bufferSource.disconnect(
|
|
651
|
-
filterNode.disconnect(
|
|
652
|
-
gainNode.disconnect(
|
|
653
|
-
if (modLFOGain)
|
|
654
|
-
modLFOGain.disconnect(
|
|
655
|
-
if (modLFO)
|
|
656
|
-
modLFO.stop();
|
|
654
|
+
note.bufferSource.onended = () => {
|
|
655
|
+
scheduledNotes[i] = null;
|
|
656
|
+
note.bufferSource.disconnect();
|
|
657
|
+
note.filterNode.disconnect();
|
|
658
|
+
note.gainNode.disconnect();
|
|
659
|
+
if (note.modLFOGain)
|
|
660
|
+
note.modLFOGain.disconnect();
|
|
661
|
+
if (note.modLFO)
|
|
662
|
+
note.modLFO.stop();
|
|
657
663
|
resolve();
|
|
658
664
|
};
|
|
659
665
|
bufferSource.stop(volEndTime);
|
|
@@ -719,7 +725,7 @@ class MidyGM1 {
|
|
|
719
725
|
case 1:
|
|
720
726
|
return this.setModulation(channelNumber, value);
|
|
721
727
|
case 6:
|
|
722
|
-
return this.
|
|
728
|
+
return this.dataEntryMSB(channelNumber, value);
|
|
723
729
|
case 7:
|
|
724
730
|
return this.setVolume(channelNumber, value);
|
|
725
731
|
case 10:
|
|
@@ -727,7 +733,7 @@ class MidyGM1 {
|
|
|
727
733
|
case 11:
|
|
728
734
|
return this.setExpression(channelNumber, value);
|
|
729
735
|
case 38:
|
|
730
|
-
return this.
|
|
736
|
+
return this.dataEntryLSB(channelNumber, value);
|
|
731
737
|
case 64:
|
|
732
738
|
return this.setSustainPedal(channelNumber, value);
|
|
733
739
|
case 100:
|
|
@@ -744,22 +750,24 @@ class MidyGM1 {
|
|
|
744
750
|
console.warn(`Unsupported Control change: controller=${controller} value=${value}`);
|
|
745
751
|
}
|
|
746
752
|
}
|
|
747
|
-
|
|
753
|
+
updateModulation(channel) {
|
|
748
754
|
const now = this.audioContext.currentTime;
|
|
749
|
-
const channel = this.channels[channelNumber];
|
|
750
|
-
channel.modulation = (modulation / 127) *
|
|
751
|
-
(channel.modulationDepthRange * 100);
|
|
752
755
|
const activeNotes = this.getActiveNotes(channel, now);
|
|
753
756
|
activeNotes.forEach((activeNote) => {
|
|
754
757
|
if (activeNote.modLFO) {
|
|
755
|
-
|
|
756
|
-
|
|
758
|
+
const { gainNode, instrumentKey } = activeNote;
|
|
759
|
+
gainNode.gain.setValueAtTime(this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation), now);
|
|
757
760
|
}
|
|
758
761
|
else {
|
|
759
762
|
this.startModulation(channel, activeNote, now);
|
|
760
763
|
}
|
|
761
764
|
});
|
|
762
765
|
}
|
|
766
|
+
setModulation(channelNumber, modulation) {
|
|
767
|
+
const channel = this.channels[channelNumber];
|
|
768
|
+
channel.modulation = (modulation / 127) * channel.modulationDepthRange;
|
|
769
|
+
this.updateModulation(channel);
|
|
770
|
+
}
|
|
763
771
|
setVolume(channelNumber, volume) {
|
|
764
772
|
const channel = this.channels[channelNumber];
|
|
765
773
|
channel.volume = volume / 127;
|
|
@@ -782,6 +790,10 @@ class MidyGM1 {
|
|
|
782
790
|
channel.expression = expression / 127;
|
|
783
791
|
this.updateChannelGain(channel);
|
|
784
792
|
}
|
|
793
|
+
dataEntryLSB(channelNumber, value) {
|
|
794
|
+
this.channels[channelNumber].dataLSB = value;
|
|
795
|
+
this.handleRPN(channelNumber, 0);
|
|
796
|
+
}
|
|
785
797
|
updateChannelGain(channel) {
|
|
786
798
|
const now = this.audioContext.currentTime;
|
|
787
799
|
const volume = channel.volume * channel.expression;
|
|
@@ -831,13 +843,13 @@ class MidyGM1 {
|
|
|
831
843
|
const rpn = channel.rpnMSB * 128 + channel.rpnLSB;
|
|
832
844
|
switch (rpn) {
|
|
833
845
|
case 0:
|
|
834
|
-
this.
|
|
846
|
+
this.handlePitchBendRangeRPN(channelNumber);
|
|
835
847
|
break;
|
|
836
848
|
case 1:
|
|
837
|
-
this.
|
|
849
|
+
this.handleFineTuningRPN(channelNumber);
|
|
838
850
|
break;
|
|
839
851
|
case 2:
|
|
840
|
-
this.
|
|
852
|
+
this.handleCoarseTuningRPN(channelNumber);
|
|
841
853
|
break;
|
|
842
854
|
default:
|
|
843
855
|
console.warn(`Channel ${channelNumber}: Unsupported RPN MSB=${channel.rpnMSB} LSB=${channel.rpnLSB}`);
|
|
@@ -849,9 +861,8 @@ class MidyGM1 {
|
|
|
849
861
|
setRPNLSB(channelNumber, value) {
|
|
850
862
|
this.channels[channelNumber].rpnLSB = value;
|
|
851
863
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
isMSB ? channel.dataMSB = value : channel.dataLSB = value;
|
|
864
|
+
dataEntryMSB(channelNumber, value) {
|
|
865
|
+
this.channels[channelNumber].dataMSB = value;
|
|
855
866
|
this.handleRPN(channelNumber);
|
|
856
867
|
}
|
|
857
868
|
updateDetune(channel, detuneChange) {
|
|
@@ -865,7 +876,7 @@ class MidyGM1 {
|
|
|
865
876
|
.setValueAtTime(detune, now);
|
|
866
877
|
});
|
|
867
878
|
}
|
|
868
|
-
|
|
879
|
+
handlePitchBendRangeRPN(channelNumber) {
|
|
869
880
|
const channel = this.channels[channelNumber];
|
|
870
881
|
this.limitData(channel, 0, 127, 0, 99);
|
|
871
882
|
const pitchBendRange = channel.dataMSB + channel.dataLSB / 100;
|
|
@@ -879,7 +890,7 @@ class MidyGM1 {
|
|
|
879
890
|
channel.pitchBend * 100;
|
|
880
891
|
this.updateDetune(channel, detuneChange);
|
|
881
892
|
}
|
|
882
|
-
|
|
893
|
+
handleFineTuningRPN(channelNumber) {
|
|
883
894
|
const channel = this.channels[channelNumber];
|
|
884
895
|
this.limitData(channel, 0, 127, 0, 127);
|
|
885
896
|
const fineTuning = (channel.dataMSB * 128 + channel.dataLSB - 8192) / 8192;
|
|
@@ -887,9 +898,12 @@ class MidyGM1 {
|
|
|
887
898
|
}
|
|
888
899
|
setFineTuning(channelNumber, fineTuning) {
|
|
889
900
|
const channel = this.channels[channelNumber];
|
|
901
|
+
const prevFineTuning = channel.fineTuning;
|
|
890
902
|
channel.fineTuning = fineTuning;
|
|
903
|
+
const detuneChange = channel.fineTuning - prevFineTuning;
|
|
904
|
+
this.updateDetune(channel, detuneChange);
|
|
891
905
|
}
|
|
892
|
-
|
|
906
|
+
handleCoarseTuningRPN(channelNumber) {
|
|
893
907
|
const channel = this.channels[channelNumber];
|
|
894
908
|
this.limitDataMSB(channel, 0, 127);
|
|
895
909
|
const coarseTuning = channel.dataMSB - 64;
|
|
@@ -897,7 +911,10 @@ class MidyGM1 {
|
|
|
897
911
|
}
|
|
898
912
|
setCoarseTuning(channelNumber, coarseTuning) {
|
|
899
913
|
const channel = this.channels[channelNumber];
|
|
900
|
-
|
|
914
|
+
const prevCoarseTuning = channel.coarseTuning;
|
|
915
|
+
channel.coarseTuning = coarseTuning;
|
|
916
|
+
const detuneChange = channel.coarseTuning - prevCoarseTuning;
|
|
917
|
+
this.updateDetune(channel, detuneChange);
|
|
901
918
|
}
|
|
902
919
|
allSoundOff(channelNumber) {
|
|
903
920
|
const now = this.audioContext.currentTime;
|
|
@@ -1024,9 +1041,9 @@ Object.defineProperty(MidyGM1, "channelSettings", {
|
|
|
1024
1041
|
dataLSB: 0,
|
|
1025
1042
|
program: 0,
|
|
1026
1043
|
pitchBend: 0,
|
|
1027
|
-
fineTuning: 0,
|
|
1028
|
-
coarseTuning: 0,
|
|
1029
|
-
modulationDepthRange: 0.5,
|
|
1044
|
+
fineTuning: 0, // cb
|
|
1045
|
+
coarseTuning: 0, // cb
|
|
1046
|
+
modulationDepthRange: 0.5, // cb
|
|
1030
1047
|
}
|
|
1031
1048
|
});
|
|
1032
1049
|
Object.defineProperty(MidyGM1, "effectSettings", {
|
package/script/midy-GM2.d.ts
CHANGED
|
@@ -37,7 +37,14 @@ export class MidyGM2 {
|
|
|
37
37
|
lfoFilterDepth: number;
|
|
38
38
|
lfoAmplitudeDepth: number;
|
|
39
39
|
};
|
|
40
|
-
constructor(audioContext: any
|
|
40
|
+
constructor(audioContext: any, options?: {
|
|
41
|
+
reverbAlgorithm: (audioContext: any) => {
|
|
42
|
+
input: any;
|
|
43
|
+
output: any;
|
|
44
|
+
dryGain: any;
|
|
45
|
+
wetGain: any;
|
|
46
|
+
};
|
|
47
|
+
});
|
|
41
48
|
ticksPerBeat: number;
|
|
42
49
|
totalTime: number;
|
|
43
50
|
reverbFactor: number;
|
|
@@ -60,58 +67,25 @@ export class MidyGM2 {
|
|
|
60
67
|
timeline: any[];
|
|
61
68
|
instruments: any[];
|
|
62
69
|
notePromises: any[];
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
sostenutoNotes: Map<any, any>;
|
|
68
|
-
channelPressure: {
|
|
69
|
-
pitchControl: number;
|
|
70
|
-
filterCutoffControl: number;
|
|
71
|
-
amplitudeControl: number;
|
|
72
|
-
lfoPitchDepth: number;
|
|
73
|
-
lfoFilterDepth: number;
|
|
74
|
-
lfoAmplitudeDepth: number;
|
|
75
|
-
};
|
|
76
|
-
gainL: any;
|
|
77
|
-
gainR: any;
|
|
78
|
-
reverbEffect: {
|
|
79
|
-
convolverNode: any;
|
|
70
|
+
defaultOptions: {
|
|
71
|
+
reverbAlgorithm: (audioContext: any) => {
|
|
72
|
+
input: any;
|
|
73
|
+
output: any;
|
|
80
74
|
dryGain: any;
|
|
81
75
|
wetGain: any;
|
|
82
76
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
};
|
|
78
|
+
audioContext: any;
|
|
79
|
+
options: {
|
|
80
|
+
reverbAlgorithm: (audioContext: any) => {
|
|
81
|
+
input: any;
|
|
82
|
+
output: any;
|
|
83
|
+
dryGain: any;
|
|
84
|
+
wetGain: any;
|
|
88
85
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
portamento: boolean;
|
|
93
|
-
sostenutoPedal: boolean;
|
|
94
|
-
softPedal: number;
|
|
95
|
-
rpnMSB: number;
|
|
96
|
-
rpnLSB: number;
|
|
97
|
-
pitchBendRange: number;
|
|
98
|
-
currentBufferSource: null;
|
|
99
|
-
volume: number;
|
|
100
|
-
pan: number;
|
|
101
|
-
portamentoTime: number;
|
|
102
|
-
reverb: number;
|
|
103
|
-
chorus: number;
|
|
104
|
-
bank: number;
|
|
105
|
-
bankMSB: number;
|
|
106
|
-
bankLSB: number;
|
|
107
|
-
dataMSB: number;
|
|
108
|
-
dataLSB: number;
|
|
109
|
-
program: number;
|
|
110
|
-
pitchBend: number;
|
|
111
|
-
fineTuning: number;
|
|
112
|
-
coarseTuning: number;
|
|
113
|
-
modulationDepthRange: number;
|
|
114
|
-
}[];
|
|
86
|
+
};
|
|
87
|
+
masterGain: any;
|
|
88
|
+
channels: any[];
|
|
115
89
|
initSoundFontTable(): any[];
|
|
116
90
|
addSoundFont(soundFont: any): void;
|
|
117
91
|
loadSoundFont(soundFontUrl: any): Promise<void>;
|
|
@@ -119,8 +93,10 @@ export class MidyGM2 {
|
|
|
119
93
|
setChannelAudioNodes(audioContext: any): {
|
|
120
94
|
gainL: any;
|
|
121
95
|
gainR: any;
|
|
96
|
+
merger: any;
|
|
122
97
|
reverbEffect: {
|
|
123
|
-
|
|
98
|
+
input: any;
|
|
99
|
+
output: any;
|
|
124
100
|
dryGain: any;
|
|
125
101
|
wetGain: any;
|
|
126
102
|
};
|
|
@@ -129,58 +105,10 @@ export class MidyGM2 {
|
|
|
129
105
|
lfoGain: any;
|
|
130
106
|
delayNodes: any[];
|
|
131
107
|
chorusGains: any[];
|
|
108
|
+
output: any;
|
|
132
109
|
};
|
|
133
110
|
};
|
|
134
|
-
createChannels(audioContext: any):
|
|
135
|
-
scheduledNotes: Map<any, any>;
|
|
136
|
-
sostenutoNotes: Map<any, any>;
|
|
137
|
-
channelPressure: {
|
|
138
|
-
pitchControl: number;
|
|
139
|
-
filterCutoffControl: number;
|
|
140
|
-
amplitudeControl: number;
|
|
141
|
-
lfoPitchDepth: number;
|
|
142
|
-
lfoFilterDepth: number;
|
|
143
|
-
lfoAmplitudeDepth: number;
|
|
144
|
-
};
|
|
145
|
-
gainL: any;
|
|
146
|
-
gainR: any;
|
|
147
|
-
reverbEffect: {
|
|
148
|
-
convolverNode: any;
|
|
149
|
-
dryGain: any;
|
|
150
|
-
wetGain: any;
|
|
151
|
-
};
|
|
152
|
-
chorusEffect: {
|
|
153
|
-
lfo: any;
|
|
154
|
-
lfoGain: any;
|
|
155
|
-
delayNodes: any[];
|
|
156
|
-
chorusGains: any[];
|
|
157
|
-
};
|
|
158
|
-
expression: number;
|
|
159
|
-
modulation: number;
|
|
160
|
-
sustainPedal: boolean;
|
|
161
|
-
portamento: boolean;
|
|
162
|
-
sostenutoPedal: boolean;
|
|
163
|
-
softPedal: number;
|
|
164
|
-
rpnMSB: number;
|
|
165
|
-
rpnLSB: number;
|
|
166
|
-
pitchBendRange: number;
|
|
167
|
-
currentBufferSource: null;
|
|
168
|
-
volume: number;
|
|
169
|
-
pan: number;
|
|
170
|
-
portamentoTime: number;
|
|
171
|
-
reverb: number;
|
|
172
|
-
chorus: number;
|
|
173
|
-
bank: number;
|
|
174
|
-
bankMSB: number;
|
|
175
|
-
bankLSB: number;
|
|
176
|
-
dataMSB: number;
|
|
177
|
-
dataLSB: number;
|
|
178
|
-
program: number;
|
|
179
|
-
pitchBend: number;
|
|
180
|
-
fineTuning: number;
|
|
181
|
-
coarseTuning: number;
|
|
182
|
-
modulationDepthRange: number;
|
|
183
|
-
}[];
|
|
111
|
+
createChannels(audioContext: any): any[];
|
|
184
112
|
createNoteBuffer(instrumentKey: any, isSF3: any): Promise<any>;
|
|
185
113
|
createNoteBufferNode(instrumentKey: any, isSF3: any): Promise<any>;
|
|
186
114
|
convertToFloat32Array(uint8Array: any): Float32Array;
|
|
@@ -203,8 +131,18 @@ export class MidyGM2 {
|
|
|
203
131
|
currentTime(): number;
|
|
204
132
|
getActiveNotes(channel: any, time: any): Map<any, any>;
|
|
205
133
|
getActiveNote(noteList: any, time: any): any;
|
|
206
|
-
|
|
134
|
+
createConvolutionReverb(audioContext: any, options?: {}): {
|
|
135
|
+
input: any;
|
|
136
|
+
output: any;
|
|
137
|
+
dryGain: any;
|
|
138
|
+
wetGain: any;
|
|
207
139
|
convolverNode: any;
|
|
140
|
+
};
|
|
141
|
+
createCombFilter(audioContext: any, input: any, delay: any, feedback: any): any;
|
|
142
|
+
createAllpassFilter(audioContext: any, input: any, delay: any, feedback: any): any;
|
|
143
|
+
createSchroederReverb(audioContext: any, options?: {}): {
|
|
144
|
+
input: any;
|
|
145
|
+
output: any;
|
|
208
146
|
dryGain: any;
|
|
209
147
|
wetGain: any;
|
|
210
148
|
};
|
|
@@ -213,8 +151,9 @@ export class MidyGM2 {
|
|
|
213
151
|
lfoGain: any;
|
|
214
152
|
delayNodes: any[];
|
|
215
153
|
chorusGains: any[];
|
|
154
|
+
output: any;
|
|
216
155
|
};
|
|
217
|
-
|
|
156
|
+
connectEffects(channel: any, gainNode: any): void;
|
|
218
157
|
cbToRatio(cb: any): number;
|
|
219
158
|
centToHz(cent: any): number;
|
|
220
159
|
calcSemitoneOffset(channel: any): any;
|
|
@@ -237,6 +176,7 @@ export class MidyGM2 {
|
|
|
237
176
|
setPitchBend(channelNumber: any, pitchBend: any): void;
|
|
238
177
|
handleControlChange(channelNumber: any, controller: any, value: any): void | any[];
|
|
239
178
|
setBankMSB(channelNumber: any, msb: any): void;
|
|
179
|
+
updateModulation(channel: any): void;
|
|
240
180
|
setModulation(channelNumber: any, modulation: any): void;
|
|
241
181
|
setPortamentoTime(channelNumber: any, portamentoTime: any): void;
|
|
242
182
|
setVolume(channelNumber: any, volume: any): void;
|
|
@@ -247,26 +187,29 @@ export class MidyGM2 {
|
|
|
247
187
|
setPan(channelNumber: any, pan: any): void;
|
|
248
188
|
setExpression(channelNumber: any, expression: any): void;
|
|
249
189
|
setBankLSB(channelNumber: any, lsb: any): void;
|
|
190
|
+
dataEntryLSB(channelNumber: any, value: any): void;
|
|
250
191
|
updateChannelGain(channel: any): void;
|
|
251
192
|
setSustainPedal(channelNumber: any, value: any): void;
|
|
252
193
|
setPortamento(channelNumber: any, value: any): void;
|
|
253
|
-
|
|
254
|
-
|
|
194
|
+
setReverbSendLevel(channelNumber: any, reverb: any): void;
|
|
195
|
+
setChorusSendLevel(channelNumber: any, chorus: any): void;
|
|
255
196
|
setSostenutoPedal(channelNumber: any, value: any): void;
|
|
256
197
|
setSoftPedal(channelNumber: any, softPedal: any): void;
|
|
257
198
|
limitData(channel: any, minMSB: any, maxMSB: any, minLSB: any, maxLSB: any): void;
|
|
258
199
|
limitDataMSB(channel: any, minMSB: any, maxMSB: any): void;
|
|
259
|
-
handleRPN(channelNumber: any
|
|
200
|
+
handleRPN(channelNumber: any): void;
|
|
260
201
|
setRPNMSB(channelNumber: any, value: any): void;
|
|
261
202
|
setRPNLSB(channelNumber: any, value: any): void;
|
|
262
|
-
|
|
203
|
+
dataEntryMSB(channelNumber: any, value: any): void;
|
|
263
204
|
updateDetune(channel: any, detuneChange: any): void;
|
|
264
|
-
|
|
205
|
+
handlePitchBendRangeRPN(channelNumber: any): void;
|
|
265
206
|
setPitchBendRange(channelNumber: any, pitchBendRange: any): void;
|
|
266
|
-
|
|
207
|
+
handleFineTuningRPN(channelNumber: any): void;
|
|
267
208
|
setFineTuning(channelNumber: any, fineTuning: any): void;
|
|
268
|
-
|
|
209
|
+
handleCoarseTuningRPN(channelNumber: any): void;
|
|
269
210
|
setCoarseTuning(channelNumber: any, coarseTuning: any): void;
|
|
211
|
+
handleModulationDepthRangeRPN(channelNumber: any): void;
|
|
212
|
+
setModulationDepthRange(channelNumber: any, modulationDepthRange: any): void;
|
|
270
213
|
allSoundOff(channelNumber: any): any[];
|
|
271
214
|
resetAllControllers(channelNumber: any): void;
|
|
272
215
|
allNotesOff(channelNumber: any): any[];
|
package/script/midy-GM2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"AAuBA;IAwBE;;;;;;;;;;;;;;;;;MAiBE;IAEF;;;;;;;;;;;MAWE;IAEF;;;;;;;MAOE;
|
|
1
|
+
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"AAuBA;IAwBE;;;;;;;;;;;;;;;;;MAiBE;IAEF;;;;;;;;;;;MAWE;IAEF;;;;;;;MAOE;IASF;;;;;;;OAOC;IA9ED,qBAAmB;IACnB,kBAAc;IACd,qBAAmB;IACnB,yBAAqB;IACrB,2BAAuB;IACvB,cAAa;IACb,cAAa;IACb,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,sBAA2C;IAC3C,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,gBAAc;IACd,mBAAiB;IACjB,oBAAkB;IA2ClB;;;;;;;MAKE;IAGA,kBAAgC;IAChC;;;;;;;MAAqD;IACrD,gBAA4C;IAE5C,gBAAiD;IAInD,4BAMC;IAED,mCASC;IAED,gDAMC;IAED,sCASC;IAED;;;;;;;;;;;;;;;;;MAkBC;IAED,yCAcC;IAED,+DAyBC;IAED,mEAWC;IAED,qDAOC;IAED,2EAkDC;IAED,mCAOC;IAED,0BA+CC;IAED,uDAEC;IAED,wDAEC;IAED;;;MAgGC;IAED,4BAsBC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,uDASC;IAED,6CAQC;IAED;;;;;;MA4CC;IAED,gFAUC;IAED,mFAYC;IAID;;;;;MAuCC;IAED;;;;;;MAoCC;IAED,kDAuBC;IAED,2BAEC;IAED,4BAEC;IAED,sCAKC;IAED,mFAGC;IAED,iDAiBC;IAED,iDAiCC;IAED,0DAmBC;IAED,wHAiCC;IAED,gDAQC;IAED,kGAgCC;IAED,0EAGC;IAED,sIAiDC;IAED,0FAGC;IAED,kEAeC;IAED,oEAYC;IAED,wFAmBC;IAED,4DAIC;IAED,+DAcC;IAED,qEAGC;IAED,uDAOC;IAED,mFAuDC;IAED,+CAEC;IAED,qCAcC;IAED,yDAIC;IAED,iEAEC;IAED,iDAIC;IAED;;;MAMC;IAED,2CAIC;IAED,yDAIC;IAED,+CAEC;IAED,mDAGC;IAED,sCAUC;IAED,sDAMC;IAED,oDAEC;IAED,0DASC;IAED,0DAIC;IAED,wDAWC;IAED,uDAGC;IAED,kFAeC;IAED,2DAMC;IAED,oCAqBC;IAED,gDAEC;IAED,gDAEC;IAED,mDAGC;IAED,oDAUC;IAED,kDAKC;IAED,iEAOC;IAED,8CAKC;IAED,yDAMC;IAED,gDAKC;IAED,6DAMC;IAED,wDAKC;IAED,6EAKC;IAED,uCAoBC;IAED,8CAEC;IAED,uCAoBC;IAED,gBAEC;IAED,eAEC;IAED,eAEC;IAED,eAEC;IAED,4DAmBC;IAED,oBAQC;IAED,oBAQC;IAED,yDAgDC;IAED,yCAGC;IAED,mCAQC;IAED,6CAGC;IAED,2CAMC;IAED,+CAGC;IAED,+CAMC;IAED,wCAEC;IAED,6BASC;IAED,0DAUC;CACF;AA7hDD;IASE,gFAKC;IAbD,kBAAa;IACb,cAAS;IACT,gBAAW;IACX,YAAO;IACP,gBAAW;IACX,YAAO;IACP,gBAAW;IAGT,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,mBAAkC;CAErC"}
|