@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/esm/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/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":"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/esm/midy-GM1.js
CHANGED
|
@@ -183,23 +183,27 @@ export class MidyGM1 {
|
|
|
183
183
|
this.totalTime = this.calcTotalTime();
|
|
184
184
|
}
|
|
185
185
|
setChannelAudioNodes(audioContext) {
|
|
186
|
-
const { gainLeft, gainRight } = this.panToGain(
|
|
186
|
+
const { gainLeft, gainRight } = this.panToGain(this.constructor.channelSettings.pan);
|
|
187
187
|
const gainL = new GainNode(audioContext, { gain: gainLeft });
|
|
188
188
|
const gainR = new GainNode(audioContext, { gain: gainRight });
|
|
189
189
|
const merger = new ChannelMergerNode(audioContext, { numberOfInputs: 2 });
|
|
190
190
|
gainL.connect(merger, 0, 0);
|
|
191
191
|
gainR.connect(merger, 0, 1);
|
|
192
|
-
|
|
192
|
+
const reverbEffect = this.createConvolutionReverb(audioContext);
|
|
193
|
+
const chorusEffect = this.createChorusEffect(audioContext);
|
|
193
194
|
return {
|
|
194
195
|
gainL,
|
|
195
196
|
gainR,
|
|
197
|
+
merger,
|
|
198
|
+
reverbEffect,
|
|
199
|
+
chorusEffect,
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
202
|
createChannels(audioContext) {
|
|
199
203
|
const channels = Array.from({ length: 16 }, () => {
|
|
200
204
|
return {
|
|
201
|
-
...
|
|
202
|
-
...
|
|
205
|
+
...this.constructor.channelSettings,
|
|
206
|
+
...this.constructor.effectSettings,
|
|
203
207
|
...this.setChannelAudioNodes(audioContext),
|
|
204
208
|
scheduledNotes: new Map(),
|
|
205
209
|
};
|
|
@@ -491,9 +495,9 @@ export class MidyGM1 {
|
|
|
491
495
|
}
|
|
492
496
|
return noteList[0];
|
|
493
497
|
}
|
|
494
|
-
|
|
495
|
-
gainNode.connect(channel.
|
|
496
|
-
|
|
498
|
+
connectEffects(channel, gainNode) {
|
|
499
|
+
gainNode.connect(channel.merger);
|
|
500
|
+
merger.connect(this.masterGain);
|
|
497
501
|
}
|
|
498
502
|
cbToRatio(cb) {
|
|
499
503
|
return Math.pow(10, cb / 200);
|
|
@@ -560,7 +564,7 @@ export class MidyGM1 {
|
|
|
560
564
|
startModulation(channel, note, time) {
|
|
561
565
|
const { instrumentKey } = note;
|
|
562
566
|
note.modLFOGain = new GainNode(this.audioContext, {
|
|
563
|
-
gain: this.cbToRatio(instrumentKey.modLfoToVolume
|
|
567
|
+
gain: this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation),
|
|
564
568
|
});
|
|
565
569
|
note.modLFO = new OscillatorNode(this.audioContext, {
|
|
566
570
|
frequency: this.centToHz(instrumentKey.freqModLFO),
|
|
@@ -599,7 +603,7 @@ export class MidyGM1 {
|
|
|
599
603
|
if (!instrumentKey)
|
|
600
604
|
return;
|
|
601
605
|
const note = await this.createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3);
|
|
602
|
-
this.
|
|
606
|
+
this.connectEffects(channel, note.gainNode);
|
|
603
607
|
const scheduledNotes = channel.scheduledNotes;
|
|
604
608
|
if (scheduledNotes.has(noteNumber)) {
|
|
605
609
|
scheduledNotes.get(noteNumber).push(note);
|
|
@@ -618,39 +622,41 @@ export class MidyGM1 {
|
|
|
618
622
|
return;
|
|
619
623
|
if (!channel.scheduledNotes.has(noteNumber))
|
|
620
624
|
return;
|
|
621
|
-
const
|
|
622
|
-
for (let i = 0; i <
|
|
623
|
-
const
|
|
624
|
-
if (!
|
|
625
|
+
const scheduledNotes = channel.scheduledNotes.get(noteNumber);
|
|
626
|
+
for (let i = 0; i < scheduledNotes.length; i++) {
|
|
627
|
+
const note = scheduledNotes[i];
|
|
628
|
+
if (!note)
|
|
625
629
|
continue;
|
|
626
|
-
if (
|
|
630
|
+
if (note.ending)
|
|
627
631
|
continue;
|
|
628
|
-
const { bufferSource, filterNode, gainNode, modLFO, modLFOGain, instrumentKey, } = targetNote;
|
|
629
632
|
const velocityRate = (velocity + 127) / 127;
|
|
630
|
-
const volEndTime = stopTime +
|
|
631
|
-
|
|
632
|
-
gainNode.gain
|
|
633
|
+
const volEndTime = stopTime +
|
|
634
|
+
note.instrumentKey.volRelease * velocityRate;
|
|
635
|
+
note.gainNode.gain
|
|
636
|
+
.cancelScheduledValues(stopTime)
|
|
637
|
+
.linearRampToValueAtTime(0, volEndTime);
|
|
633
638
|
const maxFreq = this.audioContext.sampleRate / 2;
|
|
634
|
-
const baseFreq = this.centToHz(instrumentKey.initialFilterFc);
|
|
639
|
+
const baseFreq = this.centToHz(note.instrumentKey.initialFilterFc);
|
|
635
640
|
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
636
|
-
const modEndTime = stopTime +
|
|
637
|
-
|
|
641
|
+
const modEndTime = stopTime +
|
|
642
|
+
note.instrumentKey.modRelease * velocityRate;
|
|
643
|
+
note.filterNode.frequency
|
|
638
644
|
.cancelScheduledValues(stopTime)
|
|
639
645
|
.linearRampToValueAtTime(adjustedBaseFreq, modEndTime);
|
|
640
|
-
|
|
646
|
+
note.ending = true;
|
|
641
647
|
this.scheduleTask(() => {
|
|
642
|
-
bufferSource.loop = false;
|
|
648
|
+
note.bufferSource.loop = false;
|
|
643
649
|
}, stopTime);
|
|
644
650
|
return new Promise((resolve) => {
|
|
645
|
-
bufferSource.onended = () => {
|
|
646
|
-
|
|
647
|
-
bufferSource.disconnect(
|
|
648
|
-
filterNode.disconnect(
|
|
649
|
-
gainNode.disconnect(
|
|
650
|
-
if (modLFOGain)
|
|
651
|
-
modLFOGain.disconnect(
|
|
652
|
-
if (modLFO)
|
|
653
|
-
modLFO.stop();
|
|
651
|
+
note.bufferSource.onended = () => {
|
|
652
|
+
scheduledNotes[i] = null;
|
|
653
|
+
note.bufferSource.disconnect();
|
|
654
|
+
note.filterNode.disconnect();
|
|
655
|
+
note.gainNode.disconnect();
|
|
656
|
+
if (note.modLFOGain)
|
|
657
|
+
note.modLFOGain.disconnect();
|
|
658
|
+
if (note.modLFO)
|
|
659
|
+
note.modLFO.stop();
|
|
654
660
|
resolve();
|
|
655
661
|
};
|
|
656
662
|
bufferSource.stop(volEndTime);
|
|
@@ -716,7 +722,7 @@ export class MidyGM1 {
|
|
|
716
722
|
case 1:
|
|
717
723
|
return this.setModulation(channelNumber, value);
|
|
718
724
|
case 6:
|
|
719
|
-
return this.
|
|
725
|
+
return this.dataEntryMSB(channelNumber, value);
|
|
720
726
|
case 7:
|
|
721
727
|
return this.setVolume(channelNumber, value);
|
|
722
728
|
case 10:
|
|
@@ -724,7 +730,7 @@ export class MidyGM1 {
|
|
|
724
730
|
case 11:
|
|
725
731
|
return this.setExpression(channelNumber, value);
|
|
726
732
|
case 38:
|
|
727
|
-
return this.
|
|
733
|
+
return this.dataEntryLSB(channelNumber, value);
|
|
728
734
|
case 64:
|
|
729
735
|
return this.setSustainPedal(channelNumber, value);
|
|
730
736
|
case 100:
|
|
@@ -741,22 +747,24 @@ export class MidyGM1 {
|
|
|
741
747
|
console.warn(`Unsupported Control change: controller=${controller} value=${value}`);
|
|
742
748
|
}
|
|
743
749
|
}
|
|
744
|
-
|
|
750
|
+
updateModulation(channel) {
|
|
745
751
|
const now = this.audioContext.currentTime;
|
|
746
|
-
const channel = this.channels[channelNumber];
|
|
747
|
-
channel.modulation = (modulation / 127) *
|
|
748
|
-
(channel.modulationDepthRange * 100);
|
|
749
752
|
const activeNotes = this.getActiveNotes(channel, now);
|
|
750
753
|
activeNotes.forEach((activeNote) => {
|
|
751
754
|
if (activeNote.modLFO) {
|
|
752
|
-
|
|
753
|
-
|
|
755
|
+
const { gainNode, instrumentKey } = activeNote;
|
|
756
|
+
gainNode.gain.setValueAtTime(this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation), now);
|
|
754
757
|
}
|
|
755
758
|
else {
|
|
756
759
|
this.startModulation(channel, activeNote, now);
|
|
757
760
|
}
|
|
758
761
|
});
|
|
759
762
|
}
|
|
763
|
+
setModulation(channelNumber, modulation) {
|
|
764
|
+
const channel = this.channels[channelNumber];
|
|
765
|
+
channel.modulation = (modulation / 127) * channel.modulationDepthRange;
|
|
766
|
+
this.updateModulation(channel);
|
|
767
|
+
}
|
|
760
768
|
setVolume(channelNumber, volume) {
|
|
761
769
|
const channel = this.channels[channelNumber];
|
|
762
770
|
channel.volume = volume / 127;
|
|
@@ -779,6 +787,10 @@ export class MidyGM1 {
|
|
|
779
787
|
channel.expression = expression / 127;
|
|
780
788
|
this.updateChannelGain(channel);
|
|
781
789
|
}
|
|
790
|
+
dataEntryLSB(channelNumber, value) {
|
|
791
|
+
this.channels[channelNumber].dataLSB = value;
|
|
792
|
+
this.handleRPN(channelNumber, 0);
|
|
793
|
+
}
|
|
782
794
|
updateChannelGain(channel) {
|
|
783
795
|
const now = this.audioContext.currentTime;
|
|
784
796
|
const volume = channel.volume * channel.expression;
|
|
@@ -828,13 +840,13 @@ export class MidyGM1 {
|
|
|
828
840
|
const rpn = channel.rpnMSB * 128 + channel.rpnLSB;
|
|
829
841
|
switch (rpn) {
|
|
830
842
|
case 0:
|
|
831
|
-
this.
|
|
843
|
+
this.handlePitchBendRangeRPN(channelNumber);
|
|
832
844
|
break;
|
|
833
845
|
case 1:
|
|
834
|
-
this.
|
|
846
|
+
this.handleFineTuningRPN(channelNumber);
|
|
835
847
|
break;
|
|
836
848
|
case 2:
|
|
837
|
-
this.
|
|
849
|
+
this.handleCoarseTuningRPN(channelNumber);
|
|
838
850
|
break;
|
|
839
851
|
default:
|
|
840
852
|
console.warn(`Channel ${channelNumber}: Unsupported RPN MSB=${channel.rpnMSB} LSB=${channel.rpnLSB}`);
|
|
@@ -846,9 +858,8 @@ export class MidyGM1 {
|
|
|
846
858
|
setRPNLSB(channelNumber, value) {
|
|
847
859
|
this.channels[channelNumber].rpnLSB = value;
|
|
848
860
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
isMSB ? channel.dataMSB = value : channel.dataLSB = value;
|
|
861
|
+
dataEntryMSB(channelNumber, value) {
|
|
862
|
+
this.channels[channelNumber].dataMSB = value;
|
|
852
863
|
this.handleRPN(channelNumber);
|
|
853
864
|
}
|
|
854
865
|
updateDetune(channel, detuneChange) {
|
|
@@ -862,7 +873,7 @@ export class MidyGM1 {
|
|
|
862
873
|
.setValueAtTime(detune, now);
|
|
863
874
|
});
|
|
864
875
|
}
|
|
865
|
-
|
|
876
|
+
handlePitchBendRangeRPN(channelNumber) {
|
|
866
877
|
const channel = this.channels[channelNumber];
|
|
867
878
|
this.limitData(channel, 0, 127, 0, 99);
|
|
868
879
|
const pitchBendRange = channel.dataMSB + channel.dataLSB / 100;
|
|
@@ -876,7 +887,7 @@ export class MidyGM1 {
|
|
|
876
887
|
channel.pitchBend * 100;
|
|
877
888
|
this.updateDetune(channel, detuneChange);
|
|
878
889
|
}
|
|
879
|
-
|
|
890
|
+
handleFineTuningRPN(channelNumber) {
|
|
880
891
|
const channel = this.channels[channelNumber];
|
|
881
892
|
this.limitData(channel, 0, 127, 0, 127);
|
|
882
893
|
const fineTuning = (channel.dataMSB * 128 + channel.dataLSB - 8192) / 8192;
|
|
@@ -884,9 +895,12 @@ export class MidyGM1 {
|
|
|
884
895
|
}
|
|
885
896
|
setFineTuning(channelNumber, fineTuning) {
|
|
886
897
|
const channel = this.channels[channelNumber];
|
|
898
|
+
const prevFineTuning = channel.fineTuning;
|
|
887
899
|
channel.fineTuning = fineTuning;
|
|
900
|
+
const detuneChange = channel.fineTuning - prevFineTuning;
|
|
901
|
+
this.updateDetune(channel, detuneChange);
|
|
888
902
|
}
|
|
889
|
-
|
|
903
|
+
handleCoarseTuningRPN(channelNumber) {
|
|
890
904
|
const channel = this.channels[channelNumber];
|
|
891
905
|
this.limitDataMSB(channel, 0, 127);
|
|
892
906
|
const coarseTuning = channel.dataMSB - 64;
|
|
@@ -894,7 +908,10 @@ export class MidyGM1 {
|
|
|
894
908
|
}
|
|
895
909
|
setCoarseTuning(channelNumber, coarseTuning) {
|
|
896
910
|
const channel = this.channels[channelNumber];
|
|
897
|
-
|
|
911
|
+
const prevCoarseTuning = channel.coarseTuning;
|
|
912
|
+
channel.coarseTuning = coarseTuning;
|
|
913
|
+
const detuneChange = channel.coarseTuning - prevCoarseTuning;
|
|
914
|
+
this.updateDetune(channel, detuneChange);
|
|
898
915
|
}
|
|
899
916
|
allSoundOff(channelNumber) {
|
|
900
917
|
const now = this.audioContext.currentTime;
|
|
@@ -1020,9 +1037,9 @@ Object.defineProperty(MidyGM1, "channelSettings", {
|
|
|
1020
1037
|
dataLSB: 0,
|
|
1021
1038
|
program: 0,
|
|
1022
1039
|
pitchBend: 0,
|
|
1023
|
-
fineTuning: 0,
|
|
1024
|
-
coarseTuning: 0,
|
|
1025
|
-
modulationDepthRange: 0.5,
|
|
1040
|
+
fineTuning: 0, // cb
|
|
1041
|
+
coarseTuning: 0, // cb
|
|
1042
|
+
modulationDepthRange: 0.5, // cb
|
|
1026
1043
|
}
|
|
1027
1044
|
});
|
|
1028
1045
|
Object.defineProperty(MidyGM1, "effectSettings", {
|
package/esm/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/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":"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"}
|