@marmooo/midy 0.2.3 → 0.2.4
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 +2 -1
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +16 -13
- package/esm/midy-GM2.d.ts +12 -19
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +78 -108
- package/esm/midy-GMLite.d.ts +3 -2
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +18 -13
- package/esm/midy.d.ts +14 -18
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +158 -105
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +2 -1
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +16 -13
- package/script/midy-GM2.d.ts +12 -19
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +78 -108
- package/script/midy-GMLite.d.ts +3 -2
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +18 -13
- package/script/midy.d.ts +14 -18
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +158 -105
package/esm/midy-GM1.d.ts
CHANGED
|
@@ -97,7 +97,8 @@ export class MidyGM1 {
|
|
|
97
97
|
centToRate(cent: any): number;
|
|
98
98
|
centToHz(cent: any): number;
|
|
99
99
|
calcChannelDetune(channel: any): any;
|
|
100
|
-
|
|
100
|
+
updateChannelDetune(channel: any): void;
|
|
101
|
+
updateDetune(channel: any, note: any): void;
|
|
101
102
|
setVolumeEnvelope(note: any): void;
|
|
102
103
|
setPitchEnvelope(note: any): void;
|
|
103
104
|
clampCutoffFrequency(frequency: any): number;
|
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":"AAqFA;IAoBE;;;;;;;;;;;;MAYE;IAEF,+BAQC;IAzCD,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;IAClB,iCAA8B;IAiB5B,kBAAgC;IAChC,kBAA8C;IAC9C;;;;;;;;;;;MAA2D;IAC3D;;;;;;;;;;;;;MAA+D;IAC/D,gBAAiD;IAKnD,4BAMC;IAED,mCAWC;IAED,gDAMC;IAED,sCASC;IAED;;;;MAeC;IAED,yCAUC;IAED,6DA2BC;IAED,iEAUC;IAED,2EA+CC;IAED,mCAOC;IAED,0BAkDC;IAED,uDAEC;IAED,wDAEC;IAED;;;MAgEC;IAED,+EAmBC;IAED,qDAKC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,uDASC;IAED,6CAQC;IAED,2BAEC;IAED,8BAEC;IAED,8BAEC;IAED,4BAEC;IAED,qCAMC;IAED,
|
|
1
|
+
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"AAqFA;IAoBE;;;;;;;;;;;;MAYE;IAEF,+BAQC;IAzCD,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;IAClB,iCAA8B;IAiB5B,kBAAgC;IAChC,kBAA8C;IAC9C;;;;;;;;;;;MAA2D;IAC3D;;;;;;;;;;;;;MAA+D;IAC/D,gBAAiD;IAKnD,4BAMC;IAED,mCAWC;IAED,gDAMC;IAED,sCASC;IAED;;;;MAeC;IAED,yCAUC;IAED,6DA2BC;IAED,iEAUC;IAED,2EA+CC;IAED,mCAOC;IAED,0BAkDC;IAED,uDAEC;IAED,wDAEC;IAED;;;MAgEC;IAED,+EAmBC;IAED,qDAKC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,uDASC;IAED,6CAQC;IAED,2BAEC;IAED,8BAEC;IAED,8BAEC;IAED,4BAEC;IAED,qCAMC;IAED,wCAQC;IAED,4CAKC;IAED,mCAgBC;IAED,kCAqBC;IAED,6CAIC;IAED,mCAuBC;IAED,+DAoBC;IAED,gHA2BC;IAED,kGAgDC;IAED,0EAGC;IAED,qFA4BC;IAED,6HAuBC;IAED,0FAGC;IAED,kEAeC;IAED,gFAiBC;IAED,4DAGC;IAED,qEAGC;IAED,mDASC;IAED,gDASC;IAED,gDASC;IAED,qCAMC;IAED,mCAQC;IAED,gCAOC;IAED,+BAMC;IAED;;;;;;;;;;;MA4CC;IAED,oFAMC;IAED,0DA6CC;IAED;;;;;;;;;;;;;MAeC;IAED,+EAWC;IAED,qCAeC;IAED,8DAIC;IACD,iDAIC;IAED;;;MAMC;IAED,2CAIC;IAED,yDAIC;IAED,mDAGC;IAED,wCAWC;IAED,sDAKC;IAED,kFAeC;IAED,2DAMC;IAED,oCAkBC;IAED,gDAEC;IAED,gDAEC;IAED,mDAGC;IAED,kDAKC;IAED,wDASC;IAED,8CAKC;IAED,oDAOC;IAED,gDAKC;IAED,sDAOC;IAED,+CAEC;IAED,8CAqBC;IAED,+CAEC;IAED,4DAgBC;IAED,oBAMC;IAED,yDAaC;IAED,yCAGC;IAED,mCAQC;IAED,wCAEC;IAED,6BASC;IAED,0DAUC;CACF;AArzCD;IAUE,0FAMC;IAfD,kBAAa;IACb,gBAAW;IACX,wBAAmB;IACnB,iBAAY;IACZ,mBAAc;IACd,qBAAgB;IAChB,gBAAW;IACX,kBAAa;IAGX,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,WAAkB;IAClB,iBAA8B;CAEjC"}
|
package/esm/midy-GM1.js
CHANGED
|
@@ -609,19 +609,22 @@ export class MidyGM1 {
|
|
|
609
609
|
const pitch = pitchWheel * pitchWheelSensitivity;
|
|
610
610
|
return tuning + pitch;
|
|
611
611
|
}
|
|
612
|
-
|
|
613
|
-
const now = this.audioContext.currentTime;
|
|
612
|
+
updateChannelDetune(channel) {
|
|
614
613
|
channel.scheduledNotes.forEach((noteList) => {
|
|
615
614
|
for (let i = 0; i < noteList.length; i++) {
|
|
616
615
|
const note = noteList[i];
|
|
617
616
|
if (!note)
|
|
618
617
|
continue;
|
|
619
|
-
note
|
|
620
|
-
.cancelScheduledValues(now)
|
|
621
|
-
.setValueAtTime(channel.detune, now);
|
|
618
|
+
this.updateDetune(channel, note);
|
|
622
619
|
}
|
|
623
620
|
});
|
|
624
621
|
}
|
|
622
|
+
updateDetune(channel, note) {
|
|
623
|
+
const now = this.audioContext.currentTime;
|
|
624
|
+
note.bufferSource.detune
|
|
625
|
+
.cancelScheduledValues(now)
|
|
626
|
+
.setValueAtTime(channel.detune, now);
|
|
627
|
+
}
|
|
625
628
|
setVolumeEnvelope(note) {
|
|
626
629
|
const now = this.audioContext.currentTime;
|
|
627
630
|
const { voiceParams, startTime } = note;
|
|
@@ -874,7 +877,7 @@ export class MidyGM1 {
|
|
|
874
877
|
const next = (value - 8192) / 8192;
|
|
875
878
|
state.pitchWheel = value / 16383;
|
|
876
879
|
channel.detune += (next - prev) * state.pitchWheelSensitivity * 12800;
|
|
877
|
-
this.
|
|
880
|
+
this.updateChannelDetune(channel);
|
|
878
881
|
this.applyVoiceParams(channel, 14);
|
|
879
882
|
}
|
|
880
883
|
setModLfoToPitch(channel, note) {
|
|
@@ -972,7 +975,7 @@ export class MidyGM1 {
|
|
|
972
975
|
const freqVibLFO = note.voiceParams.freqVibLFO;
|
|
973
976
|
note.vibratoLFO.frequency
|
|
974
977
|
.cancelScheduledValues(now)
|
|
975
|
-
.setValueAtTime(freqVibLFO * channel.state.vibratoRate, now);
|
|
978
|
+
.setValueAtTime(freqVibLFO * channel.state.vibratoRate * 2, now);
|
|
976
979
|
}
|
|
977
980
|
},
|
|
978
981
|
};
|
|
@@ -1012,7 +1015,7 @@ export class MidyGM1 {
|
|
|
1012
1015
|
if (key in voiceParams)
|
|
1013
1016
|
noteVoiceParams[key] = voiceParams[key];
|
|
1014
1017
|
}
|
|
1015
|
-
this.setFilterEnvelope(
|
|
1018
|
+
this.setFilterEnvelope(note);
|
|
1016
1019
|
this.setPitchEnvelope(note);
|
|
1017
1020
|
}
|
|
1018
1021
|
else if (volumeEnvelopeKeySet.has(key)) {
|
|
@@ -1052,7 +1055,7 @@ export class MidyGM1 {
|
|
|
1052
1055
|
if (handler) {
|
|
1053
1056
|
handler.call(this, channelNumber, value);
|
|
1054
1057
|
const channel = this.channels[channelNumber];
|
|
1055
|
-
this.applyVoiceParams(channel,
|
|
1058
|
+
this.applyVoiceParams(channel, controllerType + 128);
|
|
1056
1059
|
}
|
|
1057
1060
|
else {
|
|
1058
1061
|
console.warn(`Unsupported Control change: controllerType=${controllerType} value=${value}`);
|
|
@@ -1191,7 +1194,7 @@ export class MidyGM1 {
|
|
|
1191
1194
|
const next = value / 128;
|
|
1192
1195
|
state.pitchWheelSensitivity = next;
|
|
1193
1196
|
channel.detune += (state.pitchWheel * 2 - 1) * (next - prev) * 12800;
|
|
1194
|
-
this.
|
|
1197
|
+
this.updateChannelDetune(channel);
|
|
1195
1198
|
this.applyVoiceParams(channel, 16);
|
|
1196
1199
|
}
|
|
1197
1200
|
handleFineTuningRPN(channelNumber) {
|
|
@@ -1206,7 +1209,7 @@ export class MidyGM1 {
|
|
|
1206
1209
|
const next = (value - 8192) / 8.192; // cent
|
|
1207
1210
|
channel.fineTuning = next;
|
|
1208
1211
|
channel.detune += next - prev;
|
|
1209
|
-
this.
|
|
1212
|
+
this.updateChannelDetune(channel);
|
|
1210
1213
|
}
|
|
1211
1214
|
handleCoarseTuningRPN(channelNumber) {
|
|
1212
1215
|
const channel = this.channels[channelNumber];
|
|
@@ -1220,7 +1223,7 @@ export class MidyGM1 {
|
|
|
1220
1223
|
const next = (value - 64) * 100; // cent
|
|
1221
1224
|
channel.coarseTuning = next;
|
|
1222
1225
|
channel.detune += next - prev;
|
|
1223
|
-
this.
|
|
1226
|
+
this.updateChannelDetune(channel);
|
|
1224
1227
|
}
|
|
1225
1228
|
allSoundOff(channelNumber) {
|
|
1226
1229
|
return this.stopChannelNotes(channelNumber, 0, true);
|
|
@@ -1236,7 +1239,7 @@ export class MidyGM1 {
|
|
|
1236
1239
|
const state = channel.state;
|
|
1237
1240
|
for (let i = 0; i < stateTypes.length; i++) {
|
|
1238
1241
|
const type = stateTypes[i];
|
|
1239
|
-
state[type] = defaultControllerState[type];
|
|
1242
|
+
state[type] = defaultControllerState[type].defaultValue;
|
|
1240
1243
|
}
|
|
1241
1244
|
const settingTypes = [
|
|
1242
1245
|
"rpnMSB",
|
package/esm/midy-GM2.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export class MidyGM2 {
|
|
|
3
3
|
currentBufferSource: null;
|
|
4
4
|
detune: number;
|
|
5
5
|
scaleOctaveTuningTable: any[];
|
|
6
|
-
|
|
6
|
+
channelPressureTable: Uint8Array<ArrayBuffer>;
|
|
7
7
|
keyBasedInstrumentControlTable: Int8Array<ArrayBuffer>;
|
|
8
8
|
program: number;
|
|
9
9
|
bank: number;
|
|
@@ -17,14 +17,6 @@ export class MidyGM2 {
|
|
|
17
17
|
coarseTuning: number;
|
|
18
18
|
modulationDepthRange: number;
|
|
19
19
|
};
|
|
20
|
-
static controllerDestinationSettings: {
|
|
21
|
-
pitchControl: number;
|
|
22
|
-
filterCutoffControl: number;
|
|
23
|
-
amplitudeControl: number;
|
|
24
|
-
lfoPitchDepth: number;
|
|
25
|
-
lfoFilterDepth: number;
|
|
26
|
-
lfoAmplitudeDepth: number;
|
|
27
|
-
};
|
|
28
20
|
constructor(audioContext: any, options?: {
|
|
29
21
|
reverbAlgorithm: (audioContext: any) => {
|
|
30
22
|
input: any;
|
|
@@ -191,14 +183,15 @@ export class MidyGM2 {
|
|
|
191
183
|
centToHz(cent: any): number;
|
|
192
184
|
calcChannelDetune(channel: any): any;
|
|
193
185
|
calcNoteDetune(channel: any, note: any): any;
|
|
194
|
-
|
|
186
|
+
updateChannelDetune(channel: any): void;
|
|
187
|
+
updateDetune(channel: any, note: any, pressure: any): void;
|
|
195
188
|
getPortamentoTime(channel: any): number;
|
|
196
189
|
setPortamentoStartVolumeEnvelope(channel: any, note: any): void;
|
|
197
|
-
setVolumeEnvelope(
|
|
190
|
+
setVolumeEnvelope(note: any, pressure: any): void;
|
|
198
191
|
setPitchEnvelope(note: any): void;
|
|
199
192
|
clampCutoffFrequency(frequency: any): number;
|
|
200
193
|
setPortamentoStartFilterEnvelope(channel: any, note: any): void;
|
|
201
|
-
setFilterEnvelope(channel: any, note: any): void;
|
|
194
|
+
setFilterEnvelope(channel: any, note: any, pressure: any): void;
|
|
202
195
|
startModulation(channel: any, note: any, startTime: any): void;
|
|
203
196
|
startVibrato(channel: any, note: any, startTime: any): void;
|
|
204
197
|
createNote(channel: any, voice: any, noteNumber: any, velocity: any, startTime: any, portamento: any, isSF3: any): Promise<Note>;
|
|
@@ -213,17 +206,17 @@ export class MidyGM2 {
|
|
|
213
206
|
handleMIDIMessage(statusByte: any, data1: any, data2: any): void | Promise<any>;
|
|
214
207
|
handleProgramChange(channelNumber: any, program: any): void;
|
|
215
208
|
handleChannelPressure(channelNumber: any, value: any): void;
|
|
216
|
-
setChannelPressure(channel: any, note: any): void;
|
|
217
209
|
handlePitchBendMessage(channelNumber: any, lsb: any, msb: any): void;
|
|
218
210
|
setPitchBend(channelNumber: any, value: any): void;
|
|
219
|
-
setModLfoToPitch(channel: any, note: any): void;
|
|
211
|
+
setModLfoToPitch(channel: any, note: any, pressure: any): void;
|
|
220
212
|
setVibLfoToPitch(channel: any, note: any): void;
|
|
221
|
-
setModLfoToFilterFc(
|
|
222
|
-
setModLfoToVolume(
|
|
213
|
+
setModLfoToFilterFc(note: any, pressure: any): void;
|
|
214
|
+
setModLfoToVolume(note: any, pressure: any): void;
|
|
223
215
|
setReverbEffectsSend(channel: any, note: any, prevValue: any): void;
|
|
224
216
|
setChorusEffectsSend(channel: any, note: any, prevValue: any): void;
|
|
225
217
|
setDelayModLFO(note: any): void;
|
|
226
218
|
setFreqModLFO(note: any): void;
|
|
219
|
+
setFreqVibLFO(channel: any, note: any): void;
|
|
227
220
|
createVoiceParamsHandlers(): {
|
|
228
221
|
modLfoToPitch: (channel: any, note: any, _prevValue: any) => void;
|
|
229
222
|
vibLfoToPitch: (channel: any, note: any, _prevValue: any) => void;
|
|
@@ -311,7 +304,7 @@ export class MidyGM2 {
|
|
|
311
304
|
handleUniversalNonRealTimeExclusiveMessage(data: any): void;
|
|
312
305
|
GM1SystemOn(): void;
|
|
313
306
|
GM2SystemOn(): void;
|
|
314
|
-
handleUniversalRealTimeExclusiveMessage(data: any):
|
|
307
|
+
handleUniversalRealTimeExclusiveMessage(data: any): any;
|
|
315
308
|
handleMasterVolumeSysEx(data: any): void;
|
|
316
309
|
setMasterVolume(volume: any): void;
|
|
317
310
|
handleMasterFineTuningSysEx(data: any): void;
|
|
@@ -339,14 +332,14 @@ export class MidyGM2 {
|
|
|
339
332
|
getChannelBitmap(data: any): any[];
|
|
340
333
|
handleScaleOctaveTuning1ByteFormatSysEx(data: any): void;
|
|
341
334
|
applyDestinationSettings(channel: any, note: any, table: any): void;
|
|
342
|
-
handleChannelPressureSysEx(data: any): void;
|
|
335
|
+
handleChannelPressureSysEx(data: any, tableName: any): void;
|
|
343
336
|
initControlTable(): Uint8Array<ArrayBuffer>;
|
|
344
337
|
applyControlTable(channel: any, controllerType: any): void;
|
|
345
338
|
handleControlChangeSysEx(data: any): void;
|
|
346
339
|
getKeyBasedInstrumentControlValue(channel: any, keyNumber: any, controllerType: any): number;
|
|
347
340
|
handleKeyBasedInstrumentControlSysEx(data: any): void;
|
|
348
341
|
handleExclusiveMessage(data: any): void;
|
|
349
|
-
handleSysEx(data: any):
|
|
342
|
+
handleSysEx(data: any): any;
|
|
350
343
|
scheduleTask(callback: any, startTime: any): Promise<any>;
|
|
351
344
|
}
|
|
352
345
|
declare class Note {
|
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":"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"}
|
package/esm/midy-GM2.js
CHANGED
|
@@ -97,7 +97,6 @@ class Note {
|
|
|
97
97
|
const defaultControllerState = {
|
|
98
98
|
noteOnVelocity: { type: 2, defaultValue: 0 },
|
|
99
99
|
noteOnKeyNumber: { type: 3, defaultValue: 0 },
|
|
100
|
-
polyPressure: { type: 10, defaultValue: 0 },
|
|
101
100
|
channelPressure: { type: 13, defaultValue: 0 },
|
|
102
101
|
pitchWheel: { type: 14, defaultValue: 8192 / 16383 },
|
|
103
102
|
pitchWheelSensitivity: { type: 16, defaultValue: 2 / 128 },
|
|
@@ -429,9 +428,6 @@ export class MidyGM2 {
|
|
|
429
428
|
...this.setChannelAudioNodes(audioContext),
|
|
430
429
|
scheduledNotes: new Map(),
|
|
431
430
|
sostenutoNotes: new Map(),
|
|
432
|
-
channelPressure: {
|
|
433
|
-
...this.constructor.controllerDestinationSettings,
|
|
434
|
-
},
|
|
435
431
|
};
|
|
436
432
|
});
|
|
437
433
|
return channels;
|
|
@@ -933,28 +929,31 @@ export class MidyGM2 {
|
|
|
933
929
|
const pitchWheel = channel.state.pitchWheel * 2 - 1;
|
|
934
930
|
const pitchWheelSensitivity = channel.state.pitchWheelSensitivity * 12800;
|
|
935
931
|
const pitch = pitchWheel * pitchWheelSensitivity;
|
|
936
|
-
const pressureDepth = (channel.
|
|
932
|
+
const pressureDepth = (channel.channelPressureTable[0] - 64) / 37.5; // 2400 / 64;
|
|
937
933
|
const pressure = pressureDepth * channel.state.channelPressure;
|
|
938
934
|
return tuning + pitch + pressure;
|
|
939
935
|
}
|
|
940
936
|
calcNoteDetune(channel, note) {
|
|
941
937
|
return channel.scaleOctaveTuningTable[note.noteNumber % 12];
|
|
942
938
|
}
|
|
943
|
-
|
|
944
|
-
const now = this.audioContext.currentTime;
|
|
939
|
+
updateChannelDetune(channel) {
|
|
945
940
|
channel.scheduledNotes.forEach((noteList) => {
|
|
946
941
|
for (let i = 0; i < noteList.length; i++) {
|
|
947
942
|
const note = noteList[i];
|
|
948
943
|
if (!note)
|
|
949
944
|
continue;
|
|
950
|
-
|
|
951
|
-
const detune = channel.detune + noteDetune;
|
|
952
|
-
note.bufferSource.detune
|
|
953
|
-
.cancelScheduledValues(now)
|
|
954
|
-
.setValueAtTime(detune, now);
|
|
945
|
+
this.updateDetune(channel, note, 0);
|
|
955
946
|
}
|
|
956
947
|
});
|
|
957
948
|
}
|
|
949
|
+
updateDetune(channel, note, pressure) {
|
|
950
|
+
const now = this.audioContext.currentTime;
|
|
951
|
+
const noteDetune = this.calcNoteDetune(channel, note);
|
|
952
|
+
const detune = channel.detune + noteDetune + pressure;
|
|
953
|
+
note.bufferSource.detune
|
|
954
|
+
.cancelScheduledValues(now)
|
|
955
|
+
.setValueAtTime(detune, now);
|
|
956
|
+
}
|
|
958
957
|
getPortamentoTime(channel) {
|
|
959
958
|
const factor = 5 * Math.log(10) / 127;
|
|
960
959
|
const time = channel.state.portamentoTime;
|
|
@@ -972,14 +971,11 @@ export class MidyGM2 {
|
|
|
972
971
|
.setValueAtTime(0, volDelay)
|
|
973
972
|
.linearRampToValueAtTime(sustainVolume, portamentoTime);
|
|
974
973
|
}
|
|
975
|
-
setVolumeEnvelope(
|
|
974
|
+
setVolumeEnvelope(note, pressure) {
|
|
976
975
|
const now = this.audioContext.currentTime;
|
|
977
|
-
const state = channel.state;
|
|
978
976
|
const { voiceParams, startTime } = note;
|
|
979
|
-
const pressureDepth = channel.pressureTable[2] / 64;
|
|
980
|
-
const pressure = 1 + pressureDepth * channel.state.channelPressure;
|
|
981
977
|
const attackVolume = this.cbToRatio(-voiceParams.initialAttenuation) *
|
|
982
|
-
pressure;
|
|
978
|
+
(1 + pressure);
|
|
983
979
|
const sustainVolume = attackVolume * (1 - voiceParams.volSustain);
|
|
984
980
|
const volDelay = startTime + voiceParams.volDelay;
|
|
985
981
|
const volAttack = volDelay + voiceParams.volAttack;
|
|
@@ -1027,10 +1023,8 @@ export class MidyGM2 {
|
|
|
1027
1023
|
const { voiceParams, noteNumber, startTime } = note;
|
|
1028
1024
|
const softPedalFactor = 1 -
|
|
1029
1025
|
(0.1 + (noteNumber / 127) * 0.2) * state.softPedal;
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1032
|
-
const baseCent = voiceParams.initialFilterFc + pressure;
|
|
1033
|
-
const baseFreq = this.centToHz(baseCent) * softPedalFactor;
|
|
1026
|
+
const baseFreq = this.centToHz(voiceParams.initialFilterFc) *
|
|
1027
|
+
softPedalFactor;
|
|
1034
1028
|
const peekFreq = this.centToHz(voiceParams.initialFilterFc + voiceParams.modEnvToFilterFc) * softPedalFactor;
|
|
1035
1029
|
const sustainFreq = baseFreq +
|
|
1036
1030
|
(peekFreq - baseFreq) * (1 - voiceParams.modSustain);
|
|
@@ -1044,15 +1038,16 @@ export class MidyGM2 {
|
|
|
1044
1038
|
.setValueAtTime(adjustedBaseFreq, modDelay)
|
|
1045
1039
|
.linearRampToValueAtTime(adjustedSustainFreq, portamentoTime);
|
|
1046
1040
|
}
|
|
1047
|
-
setFilterEnvelope(channel, note) {
|
|
1041
|
+
setFilterEnvelope(channel, note, pressure) {
|
|
1048
1042
|
const now = this.audioContext.currentTime;
|
|
1049
1043
|
const state = channel.state;
|
|
1050
1044
|
const { voiceParams, noteNumber, startTime } = note;
|
|
1051
1045
|
const softPedalFactor = 1 -
|
|
1052
1046
|
(0.1 + (noteNumber / 127) * 0.2) * state.softPedal;
|
|
1053
|
-
const
|
|
1047
|
+
const baseCent = voiceParams.initialFilterFc + pressure;
|
|
1048
|
+
const baseFreq = this.centToHz(baseCent) * softPedalFactor;
|
|
1049
|
+
const peekFreq = this.centToHz(baseCent + voiceParams.modEnvToFilterFc) *
|
|
1054
1050
|
softPedalFactor;
|
|
1055
|
-
const peekFreq = this.centToHz(voiceParams.initialFilterFc + voiceParams.modEnvToFilterFc) * softPedalFactor;
|
|
1056
1051
|
const sustainFreq = baseFreq +
|
|
1057
1052
|
(peekFreq - baseFreq) * (1 - voiceParams.modSustain);
|
|
1058
1053
|
const adjustedBaseFreq = this.clampCutoffFrequency(baseFreq);
|
|
@@ -1079,9 +1074,9 @@ export class MidyGM2 {
|
|
|
1079
1074
|
gain: voiceParams.modLfoToFilterFc,
|
|
1080
1075
|
});
|
|
1081
1076
|
note.modulationDepth = new GainNode(this.audioContext);
|
|
1082
|
-
this.setModLfoToPitch(channel, note);
|
|
1077
|
+
this.setModLfoToPitch(channel, note, 0);
|
|
1083
1078
|
note.volumeDepth = new GainNode(this.audioContext);
|
|
1084
|
-
this.setModLfoToVolume(
|
|
1079
|
+
this.setModLfoToVolume(note, 0);
|
|
1085
1080
|
note.modulationLFO.start(startTime + voiceParams.delayModLFO);
|
|
1086
1081
|
note.modulationLFO.connect(note.filterDepth);
|
|
1087
1082
|
note.filterDepth.connect(note.filterNode.frequency);
|
|
@@ -1094,8 +1089,7 @@ export class MidyGM2 {
|
|
|
1094
1089
|
const { voiceParams } = note;
|
|
1095
1090
|
const state = channel.state;
|
|
1096
1091
|
note.vibratoLFO = new OscillatorNode(this.audioContext, {
|
|
1097
|
-
frequency: this.centToHz(voiceParams.freqVibLFO) *
|
|
1098
|
-
state.vibratoRate,
|
|
1092
|
+
frequency: this.centToHz(voiceParams.freqVibLFO) * state.vibratoRate * 2,
|
|
1099
1093
|
});
|
|
1100
1094
|
note.vibratoLFO.start(startTime + voiceParams.delayVibLFO * state.vibratoDelay * 2);
|
|
1101
1095
|
note.vibratoDepth = new GainNode(this.audioContext);
|
|
@@ -1124,8 +1118,8 @@ export class MidyGM2 {
|
|
|
1124
1118
|
}
|
|
1125
1119
|
else {
|
|
1126
1120
|
note.portamento = false;
|
|
1127
|
-
this.setVolumeEnvelope(
|
|
1128
|
-
this.setFilterEnvelope(channel, note);
|
|
1121
|
+
this.setVolumeEnvelope(note, 0);
|
|
1122
|
+
this.setFilterEnvelope(channel, note, 0);
|
|
1129
1123
|
}
|
|
1130
1124
|
if (0 < state.vibratoDepth) {
|
|
1131
1125
|
this.startVibrato(channel, note, startTime);
|
|
@@ -1344,11 +1338,11 @@ export class MidyGM2 {
|
|
|
1344
1338
|
const prev = channel.state.channelPressure;
|
|
1345
1339
|
const next = value / 127;
|
|
1346
1340
|
channel.state.channelPressure = next;
|
|
1347
|
-
if (channel.
|
|
1348
|
-
const pressureDepth = (channel.
|
|
1341
|
+
if (channel.channelPressureTable[0] !== 64) {
|
|
1342
|
+
const pressureDepth = (channel.channelPressureTable[0] - 64) / 37.5; // 2400 / 64;
|
|
1349
1343
|
channel.detune += pressureDepth * (next - prev);
|
|
1350
1344
|
}
|
|
1351
|
-
const table = channel.
|
|
1345
|
+
const table = channel.channelPressureTable;
|
|
1352
1346
|
channel.scheduledNotes.forEach((noteList) => {
|
|
1353
1347
|
for (let i = 0; i < noteList.length; i++) {
|
|
1354
1348
|
const note = noteList[i];
|
|
@@ -1359,28 +1353,6 @@ export class MidyGM2 {
|
|
|
1359
1353
|
});
|
|
1360
1354
|
// this.applyVoiceParams(channel, 13);
|
|
1361
1355
|
}
|
|
1362
|
-
setChannelPressure(channel, note) {
|
|
1363
|
-
if (channel.pressureTable[0] !== 64) {
|
|
1364
|
-
this.updateDetune(channel);
|
|
1365
|
-
}
|
|
1366
|
-
if (!note.portamento) {
|
|
1367
|
-
if (channel.pressureTable[1] !== 64) {
|
|
1368
|
-
this.setFilterEnvelope(channel, note);
|
|
1369
|
-
}
|
|
1370
|
-
if (channel.pressureTable[2] !== 64) {
|
|
1371
|
-
this.setVolumeEnvelope(channel, note);
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
if (channel.pressureTable[3] !== 0) {
|
|
1375
|
-
this.setModLfoToPitch(channel, note);
|
|
1376
|
-
}
|
|
1377
|
-
if (channel.pressureTable[4] !== 0) {
|
|
1378
|
-
this.setModLfoToFilterFc(channel, note);
|
|
1379
|
-
}
|
|
1380
|
-
if (channel.pressureTable[5] !== 0) {
|
|
1381
|
-
this.setModLfoToVolume(channel, note);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
1356
|
handlePitchBendMessage(channelNumber, lsb, msb) {
|
|
1385
1357
|
const pitchBend = msb * 128 + lsb;
|
|
1386
1358
|
this.setPitchBend(channelNumber, pitchBend);
|
|
@@ -1392,16 +1364,13 @@ export class MidyGM2 {
|
|
|
1392
1364
|
const next = (value - 8192) / 8192;
|
|
1393
1365
|
state.pitchWheel = value / 16383;
|
|
1394
1366
|
channel.detune += (next - prev) * state.pitchWheelSensitivity * 12800;
|
|
1395
|
-
this.
|
|
1367
|
+
this.updateChannelDetune(channel);
|
|
1396
1368
|
this.applyVoiceParams(channel, 14);
|
|
1397
1369
|
}
|
|
1398
|
-
setModLfoToPitch(channel, note) {
|
|
1370
|
+
setModLfoToPitch(channel, note, pressure) {
|
|
1399
1371
|
const now = this.audioContext.currentTime;
|
|
1400
|
-
const pressureDepth = channel.pressureTable[3] / 127 * 600;
|
|
1401
|
-
const pressure = pressureDepth * channel.state.channelPressure;
|
|
1402
1372
|
const modLfoToPitch = note.voiceParams.modLfoToPitch + pressure;
|
|
1403
|
-
const baseDepth = Math.abs(modLfoToPitch) +
|
|
1404
|
-
channel.state.modulationDepth;
|
|
1373
|
+
const baseDepth = Math.abs(modLfoToPitch) + channel.state.modulationDepth;
|
|
1405
1374
|
const modulationDepth = baseDepth * Math.sign(modLfoToPitch);
|
|
1406
1375
|
note.modulationDepth.gain
|
|
1407
1376
|
.cancelScheduledValues(now)
|
|
@@ -1417,22 +1386,18 @@ export class MidyGM2 {
|
|
|
1417
1386
|
.cancelScheduledValues(now)
|
|
1418
1387
|
.setValueAtTime(vibratoDepth * vibratoDepthSign, now);
|
|
1419
1388
|
}
|
|
1420
|
-
setModLfoToFilterFc(
|
|
1389
|
+
setModLfoToFilterFc(note, pressure) {
|
|
1421
1390
|
const now = this.audioContext.currentTime;
|
|
1422
|
-
const pressureDepth = channel.pressureTable[4] / 127 * 2400;
|
|
1423
|
-
const pressure = pressureDepth * channel.state.channelPressure;
|
|
1424
1391
|
const modLfoToFilterFc = note.voiceParams.modLfoToFilterFc + pressure;
|
|
1425
1392
|
note.filterDepth.gain
|
|
1426
1393
|
.cancelScheduledValues(now)
|
|
1427
1394
|
.setValueAtTime(modLfoToFilterFc, now);
|
|
1428
1395
|
}
|
|
1429
|
-
setModLfoToVolume(
|
|
1396
|
+
setModLfoToVolume(note, pressure) {
|
|
1430
1397
|
const now = this.audioContext.currentTime;
|
|
1431
1398
|
const modLfoToVolume = note.voiceParams.modLfoToVolume;
|
|
1432
1399
|
const baseDepth = this.cbToRatio(Math.abs(modLfoToVolume)) - 1;
|
|
1433
|
-
const
|
|
1434
|
-
const pressure = 1 + pressureDepth * channel.state.channelPressure;
|
|
1435
|
-
const volumeDepth = baseDepth * Math.sign(modLfoToVolume) * pressure;
|
|
1400
|
+
const volumeDepth = baseDepth * Math.sign(modLfoToVolume) * (1 + pressure);
|
|
1436
1401
|
note.volumeDepth.gain
|
|
1437
1402
|
.cancelScheduledValues(now)
|
|
1438
1403
|
.setValueAtTime(volumeDepth, now);
|
|
@@ -1505,11 +1470,18 @@ export class MidyGM2 {
|
|
|
1505
1470
|
.cancelScheduledValues(now)
|
|
1506
1471
|
.setValueAtTime(freqModLFO, now);
|
|
1507
1472
|
}
|
|
1473
|
+
setFreqVibLFO(channel, note) {
|
|
1474
|
+
const now = this.audioContext.currentTime;
|
|
1475
|
+
const freqVibLFO = note.voiceParams.freqVibLFO;
|
|
1476
|
+
note.vibratoLFO.frequency
|
|
1477
|
+
.cancelScheduledValues(now)
|
|
1478
|
+
.setValueAtTime(freqVibLFO * channel.state.vibratoRate * 2, now);
|
|
1479
|
+
}
|
|
1508
1480
|
createVoiceParamsHandlers() {
|
|
1509
1481
|
return {
|
|
1510
1482
|
modLfoToPitch: (channel, note, _prevValue) => {
|
|
1511
1483
|
if (0 < channel.state.modulationDepth) {
|
|
1512
|
-
this.setModLfoToPitch(channel, note);
|
|
1484
|
+
this.setModLfoToPitch(channel, note, 0);
|
|
1513
1485
|
}
|
|
1514
1486
|
},
|
|
1515
1487
|
vibLfoToPitch: (channel, note, _prevValue) => {
|
|
@@ -1519,12 +1491,12 @@ export class MidyGM2 {
|
|
|
1519
1491
|
},
|
|
1520
1492
|
modLfoToFilterFc: (channel, note, _prevValue) => {
|
|
1521
1493
|
if (0 < channel.state.modulationDepth) {
|
|
1522
|
-
this.setModLfoToFilterFc(
|
|
1494
|
+
this.setModLfoToFilterFc(note, 0);
|
|
1523
1495
|
}
|
|
1524
1496
|
},
|
|
1525
1497
|
modLfoToVolume: (channel, note, _prevValue) => {
|
|
1526
1498
|
if (0 < channel.state.modulationDepth) {
|
|
1527
|
-
this.setModLfoToVolume(
|
|
1499
|
+
this.setModLfoToVolume(note, 0);
|
|
1528
1500
|
}
|
|
1529
1501
|
},
|
|
1530
1502
|
chorusEffectsSend: (channel, note, prevValue) => {
|
|
@@ -1550,11 +1522,7 @@ export class MidyGM2 {
|
|
|
1550
1522
|
},
|
|
1551
1523
|
freqVibLFO: (channel, note, _prevValue) => {
|
|
1552
1524
|
if (0 < channel.state.vibratoDepth) {
|
|
1553
|
-
|
|
1554
|
-
const freqVibLFO = note.voiceParams.freqVibLFO;
|
|
1555
|
-
note.vibratoLFO.frequency
|
|
1556
|
-
.cancelScheduledValues(now)
|
|
1557
|
-
.setValueAtTime(freqVibLFO * channel.state.vibratoRate, now);
|
|
1525
|
+
this.setFreqVibLFO(channel, note);
|
|
1558
1526
|
}
|
|
1559
1527
|
},
|
|
1560
1528
|
};
|
|
@@ -1598,7 +1566,7 @@ export class MidyGM2 {
|
|
|
1598
1566
|
this.setPortamentoStartFilterEnvelope(channel, note);
|
|
1599
1567
|
}
|
|
1600
1568
|
else {
|
|
1601
|
-
this.setFilterEnvelope(channel, note);
|
|
1569
|
+
this.setFilterEnvelope(channel, note, 0);
|
|
1602
1570
|
}
|
|
1603
1571
|
this.setPitchEnvelope(note);
|
|
1604
1572
|
}
|
|
@@ -1612,7 +1580,7 @@ export class MidyGM2 {
|
|
|
1612
1580
|
if (key in voiceParams)
|
|
1613
1581
|
noteVoiceParams[key] = voiceParams[key];
|
|
1614
1582
|
}
|
|
1615
|
-
this.setVolumeEnvelope(
|
|
1583
|
+
this.setVolumeEnvelope(note, 0);
|
|
1616
1584
|
}
|
|
1617
1585
|
}
|
|
1618
1586
|
}
|
|
@@ -1651,7 +1619,7 @@ export class MidyGM2 {
|
|
|
1651
1619
|
if (handler) {
|
|
1652
1620
|
handler.call(this, channelNumber, value);
|
|
1653
1621
|
const channel = this.channels[channelNumber];
|
|
1654
|
-
this.applyVoiceParams(channel,
|
|
1622
|
+
this.applyVoiceParams(channel, controllerType + 128);
|
|
1655
1623
|
this.applyControlTable(channel, controllerType);
|
|
1656
1624
|
}
|
|
1657
1625
|
else {
|
|
@@ -1944,7 +1912,7 @@ export class MidyGM2 {
|
|
|
1944
1912
|
const next = value / 128;
|
|
1945
1913
|
state.pitchWheelSensitivity = next;
|
|
1946
1914
|
channel.detune += (state.pitchWheel * 2 - 1) * (next - prev) * 12800;
|
|
1947
|
-
this.
|
|
1915
|
+
this.updateChannelDetune(channel);
|
|
1948
1916
|
this.applyVoiceParams(channel, 16);
|
|
1949
1917
|
}
|
|
1950
1918
|
handleFineTuningRPN(channelNumber) {
|
|
@@ -1959,7 +1927,7 @@ export class MidyGM2 {
|
|
|
1959
1927
|
const next = (value - 8192) / 8.192; // cent
|
|
1960
1928
|
channel.fineTuning = next;
|
|
1961
1929
|
channel.detune += next - prev;
|
|
1962
|
-
this.
|
|
1930
|
+
this.updateChannelDetune(channel);
|
|
1963
1931
|
}
|
|
1964
1932
|
handleCoarseTuningRPN(channelNumber) {
|
|
1965
1933
|
const channel = this.channels[channelNumber];
|
|
@@ -1973,7 +1941,7 @@ export class MidyGM2 {
|
|
|
1973
1941
|
const next = (value - 64) * 100; // cent
|
|
1974
1942
|
channel.coarseTuning = next;
|
|
1975
1943
|
channel.detune += next - prev;
|
|
1976
|
-
this.
|
|
1944
|
+
this.updateChannelDetune(channel);
|
|
1977
1945
|
}
|
|
1978
1946
|
handleModulationDepthRangeRPN(channelNumber) {
|
|
1979
1947
|
const channel = this.channels[channelNumber];
|
|
@@ -2004,7 +1972,7 @@ export class MidyGM2 {
|
|
|
2004
1972
|
const state = channel.state;
|
|
2005
1973
|
for (let i = 0; i < stateTypes.length; i++) {
|
|
2006
1974
|
const type = stateTypes[i];
|
|
2007
|
-
state[type] = defaultControllerState[type];
|
|
1975
|
+
state[type] = defaultControllerState[type].defaultValue;
|
|
2008
1976
|
}
|
|
2009
1977
|
const settingTypes = [
|
|
2010
1978
|
"rpnMSB",
|
|
@@ -2098,7 +2066,7 @@ export class MidyGM2 {
|
|
|
2098
2066
|
case 9:
|
|
2099
2067
|
switch (data[3]) {
|
|
2100
2068
|
case 1: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
2101
|
-
return this.
|
|
2069
|
+
return this.handlePressureSysEx(data, "channelPressureTable");
|
|
2102
2070
|
case 3: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
2103
2071
|
return this.handleControlChangeSysEx(data);
|
|
2104
2072
|
default:
|
|
@@ -2140,7 +2108,7 @@ export class MidyGM2 {
|
|
|
2140
2108
|
const next = (value - 8192) / 8.192; // cent
|
|
2141
2109
|
this.masterFineTuning = next;
|
|
2142
2110
|
channel.detune += next - prev;
|
|
2143
|
-
this.
|
|
2111
|
+
this.updateChannelDetune(channel);
|
|
2144
2112
|
}
|
|
2145
2113
|
handleMasterCoarseTuningSysEx(data) {
|
|
2146
2114
|
const coarseTuning = data[4];
|
|
@@ -2151,7 +2119,7 @@ export class MidyGM2 {
|
|
|
2151
2119
|
const next = (value - 64) * 100; // cent
|
|
2152
2120
|
this.masterCoarseTuning = next;
|
|
2153
2121
|
channel.detune += next - prev;
|
|
2154
|
-
this.
|
|
2122
|
+
this.updateChannelDetune(channel);
|
|
2155
2123
|
}
|
|
2156
2124
|
handleGlobalParameterControlSysEx(data) {
|
|
2157
2125
|
if (data[7] === 1) {
|
|
@@ -2375,29 +2343,44 @@ export class MidyGM2 {
|
|
|
2375
2343
|
}
|
|
2376
2344
|
applyDestinationSettings(channel, note, table) {
|
|
2377
2345
|
if (table[0] !== 64) {
|
|
2378
|
-
this.updateDetune(channel);
|
|
2346
|
+
this.updateDetune(channel, note, 0);
|
|
2379
2347
|
}
|
|
2380
2348
|
if (!note.portamento) {
|
|
2381
2349
|
if (table[1] !== 64) {
|
|
2382
|
-
|
|
2350
|
+
const channelPressure = channel.channelPressureTable[1] *
|
|
2351
|
+
channel.state.channelPressure;
|
|
2352
|
+
const pressure = (channelPressure - 64) * 15;
|
|
2353
|
+
this.setFilterEnvelope(channel, note, pressure);
|
|
2383
2354
|
}
|
|
2384
2355
|
if (table[2] !== 64) {
|
|
2385
|
-
|
|
2356
|
+
const channelPressure = channel.channelPressureTable[2] *
|
|
2357
|
+
channel.state.channelPressure;
|
|
2358
|
+
const pressure = channelPressure / 64;
|
|
2359
|
+
this.setVolumeEnvelope(note, pressure);
|
|
2386
2360
|
}
|
|
2387
2361
|
}
|
|
2388
2362
|
if (table[3] !== 0) {
|
|
2389
|
-
|
|
2363
|
+
const channelPressure = channel.channelPressureTable[3] *
|
|
2364
|
+
channel.state.channelPressure;
|
|
2365
|
+
const pressure = channelPressure / 127 * 600;
|
|
2366
|
+
this.setModLfoToPitch(channel, note, pressure);
|
|
2390
2367
|
}
|
|
2391
2368
|
if (table[4] !== 0) {
|
|
2392
|
-
|
|
2369
|
+
const channelPressure = channel.channelPressureTable[4] *
|
|
2370
|
+
channel.state.channelPressure;
|
|
2371
|
+
const pressure = channelPressure / 127 * 2400;
|
|
2372
|
+
this.setModLfoToFilterFc(note, pressure);
|
|
2393
2373
|
}
|
|
2394
2374
|
if (table[5] !== 0) {
|
|
2395
|
-
|
|
2375
|
+
const channelPressure = channel.channelPressureTable[5] *
|
|
2376
|
+
channel.state.channelPressure;
|
|
2377
|
+
const pressure = channelPressure / 127;
|
|
2378
|
+
this.setModLfoToVolume(note, pressure);
|
|
2396
2379
|
}
|
|
2397
2380
|
}
|
|
2398
|
-
handleChannelPressureSysEx(data) {
|
|
2381
|
+
handleChannelPressureSysEx(data, tableName) {
|
|
2399
2382
|
const channelNumber = data[4];
|
|
2400
|
-
const table = this.channels[channelNumber]
|
|
2383
|
+
const table = this.channels[channelNumber][tableName];
|
|
2401
2384
|
for (let i = 5; i < data.length - 1; i += 2) {
|
|
2402
2385
|
const pp = data[i];
|
|
2403
2386
|
const rr = data[i + 1];
|
|
@@ -2488,7 +2471,7 @@ Object.defineProperty(MidyGM2, "channelSettings", {
|
|
|
2488
2471
|
currentBufferSource: null,
|
|
2489
2472
|
detune: 0,
|
|
2490
2473
|
scaleOctaveTuningTable: new Array(12).fill(0), // cent
|
|
2491
|
-
|
|
2474
|
+
channelPressureTable: new Uint8Array([64, 64, 64, 0, 0, 0]),
|
|
2492
2475
|
keyBasedInstrumentControlTable: new Int8Array(128 * 128), // [-64, 63]
|
|
2493
2476
|
program: 0,
|
|
2494
2477
|
bank: 121 * 128,
|
|
@@ -2503,16 +2486,3 @@ Object.defineProperty(MidyGM2, "channelSettings", {
|
|
|
2503
2486
|
modulationDepthRange: 50, // cent
|
|
2504
2487
|
}
|
|
2505
2488
|
});
|
|
2506
|
-
Object.defineProperty(MidyGM2, "controllerDestinationSettings", {
|
|
2507
|
-
enumerable: true,
|
|
2508
|
-
configurable: true,
|
|
2509
|
-
writable: true,
|
|
2510
|
-
value: {
|
|
2511
|
-
pitchControl: 0,
|
|
2512
|
-
filterCutoffControl: 0,
|
|
2513
|
-
amplitudeControl: 1,
|
|
2514
|
-
lfoPitchDepth: 0,
|
|
2515
|
-
lfoFilterDepth: 0,
|
|
2516
|
-
lfoAmplitudeDepth: 0,
|
|
2517
|
-
}
|
|
2518
|
-
});
|