@marmooo/midy 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/esm/midy-GM1.d.ts +25 -2
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +97 -16
- package/esm/midy-GM2.d.ts +39 -3
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +176 -39
- package/esm/midy-GMLite.d.ts +23 -2
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +85 -15
- package/esm/midy.d.ts +41 -3
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +212 -51
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +25 -2
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +97 -16
- package/script/midy-GM2.d.ts +39 -3
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +176 -39
- package/script/midy-GMLite.d.ts +23 -2
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +85 -15
- package/script/midy.d.ts +41 -3
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +212 -51
package/script/midy-GM1.js
CHANGED
|
@@ -95,6 +95,100 @@ class Note {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
class Channel {
|
|
99
|
+
constructor(audioNodes, settings) {
|
|
100
|
+
Object.defineProperty(this, "isDrum", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: false
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(this, "programNumber", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
value: 0
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(this, "scheduleIndex", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
configurable: true,
|
|
115
|
+
writable: true,
|
|
116
|
+
value: 0
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(this, "detune", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
configurable: true,
|
|
121
|
+
writable: true,
|
|
122
|
+
value: 0
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(this, "dataMSB", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
configurable: true,
|
|
127
|
+
writable: true,
|
|
128
|
+
value: 0
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(this, "dataLSB", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: 0
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(this, "rpnMSB", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: 127
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(this, "rpnLSB", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: 127
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(this, "modulationDepthRange", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: 50
|
|
153
|
+
}); // cent
|
|
154
|
+
Object.defineProperty(this, "fineTuning", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: 0
|
|
159
|
+
}); // cent
|
|
160
|
+
Object.defineProperty(this, "coarseTuning", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true,
|
|
164
|
+
value: 0
|
|
165
|
+
}); // cent
|
|
166
|
+
Object.defineProperty(this, "scheduledNotes", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: []
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(this, "sustainNotes", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: []
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(this, "currentBufferSource", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
configurable: true,
|
|
181
|
+
writable: true,
|
|
182
|
+
value: null
|
|
183
|
+
});
|
|
184
|
+
Object.assign(this, audioNodes);
|
|
185
|
+
Object.assign(this, settings);
|
|
186
|
+
this.state = new ControllerState();
|
|
187
|
+
}
|
|
188
|
+
resetSettings(settings) {
|
|
189
|
+
Object.assign(this, settings);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
98
192
|
// normalized to 0-1 for use with the SF2 modulator model
|
|
99
193
|
const defaultControllerState = {
|
|
100
194
|
noteOnVelocity: { type: 2, defaultValue: 0 },
|
|
@@ -485,18 +579,8 @@ class MidyGM1 extends EventTarget {
|
|
|
485
579
|
};
|
|
486
580
|
}
|
|
487
581
|
createChannels(audioContext) {
|
|
488
|
-
const
|
|
489
|
-
|
|
490
|
-
currentBufferSource: null,
|
|
491
|
-
isDrum: false,
|
|
492
|
-
state: new ControllerState(),
|
|
493
|
-
...this.constructor.channelSettings,
|
|
494
|
-
...this.createChannelAudioNodes(audioContext),
|
|
495
|
-
scheduledNotes: [],
|
|
496
|
-
sustainNotes: [],
|
|
497
|
-
};
|
|
498
|
-
});
|
|
499
|
-
return channels;
|
|
582
|
+
const settings = this.constructor.channelSettings;
|
|
583
|
+
return Array.from({ length: this.numChannels }, () => new Channel(this.createChannelAudioNodes(audioContext), settings));
|
|
500
584
|
}
|
|
501
585
|
decodeOggVorbis(sample) {
|
|
502
586
|
const task = decoderQueue.then(async () => {
|
|
@@ -608,7 +692,6 @@ class MidyGM1 extends EventTarget {
|
|
|
608
692
|
}
|
|
609
693
|
resetAllStates() {
|
|
610
694
|
this.exclusiveClassNotes.fill(undefined);
|
|
611
|
-
this.drumExclusiveClassNotes.fill(undefined);
|
|
612
695
|
this.voiceCache.clear();
|
|
613
696
|
this.realtimeVoiceCache.clear();
|
|
614
697
|
const channels = this.channels;
|
|
@@ -1629,9 +1712,7 @@ class MidyGM1 extends EventTarget {
|
|
|
1629
1712
|
state[key] = defaultValue;
|
|
1630
1713
|
}
|
|
1631
1714
|
}
|
|
1632
|
-
|
|
1633
|
-
channel[key] = this.constructor.channelSettings[key];
|
|
1634
|
-
}
|
|
1715
|
+
channel.resetSettings(this.constructor.channelSettings);
|
|
1635
1716
|
this.mode = "GM1";
|
|
1636
1717
|
}
|
|
1637
1718
|
// https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/rp15.pdf
|
package/script/midy-GM2.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
82
82
|
controlChangeHandlers: any[];
|
|
83
83
|
keyBasedControllerHandlers: any[];
|
|
84
84
|
effectHandlers: any[];
|
|
85
|
-
channels:
|
|
85
|
+
channels: Channel[];
|
|
86
86
|
reverbEffect: {
|
|
87
87
|
input: any;
|
|
88
88
|
output: any;
|
|
@@ -107,8 +107,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
107
107
|
gainR: any;
|
|
108
108
|
merger: any;
|
|
109
109
|
};
|
|
110
|
-
|
|
111
|
-
createChannels(audioContext: any): any[];
|
|
110
|
+
createChannels(audioContext: any): Channel[];
|
|
112
111
|
decodeOggVorbis(sample: any): Promise<any>;
|
|
113
112
|
createAudioBuffer(voiceParams: any): Promise<any>;
|
|
114
113
|
isLoopDrum(channel: any, noteNumber: any): boolean;
|
|
@@ -237,6 +236,7 @@ export class MidyGM2 extends EventTarget {
|
|
|
237
236
|
updatePortamento(channel: any, scheduleTime: any): void;
|
|
238
237
|
setPortamentoTime(channelNumber: any, value: any, scheduleTime: any): void;
|
|
239
238
|
setVolume(channelNumber: any, value: any, scheduleTime: any): void;
|
|
239
|
+
applyVolume(channel: any, scheduleTime: any): void;
|
|
240
240
|
panToGain(pan: any): {
|
|
241
241
|
gainLeft: number;
|
|
242
242
|
gainRight: number;
|
|
@@ -320,7 +320,9 @@ export class MidyGM2 extends EventTarget {
|
|
|
320
320
|
getLFOAmplitudeDepth(channel: any): number;
|
|
321
321
|
createEffectHandlers(): any[];
|
|
322
322
|
setControlChangeEffects(channel: any, note: any, scheduleTime: any): void;
|
|
323
|
+
setChannelPressureEffects(channel: any, note: any, scheduleTime: any): void;
|
|
323
324
|
setPressureEffects(channel: any, note: any, tableName: any, scheduleTime: any): void;
|
|
325
|
+
handleChannelPressureSysEx(data: any, scheduleTime: any): void;
|
|
324
326
|
handlePressureSysEx(data: any, tableName: any, scheduleTime: any): void;
|
|
325
327
|
handleControlChangeSysEx(data: any, scheduleTime: any): void;
|
|
326
328
|
getKeyBasedValue(channel: any, keyNumber: any, controllerType: any): any;
|
|
@@ -329,4 +331,38 @@ export class MidyGM2 extends EventTarget {
|
|
|
329
331
|
handleSysEx(data: any, scheduleTime: any): void;
|
|
330
332
|
scheduleTask(callback: any, scheduleTime: any): Promise<any>;
|
|
331
333
|
}
|
|
334
|
+
declare class Channel {
|
|
335
|
+
constructor(audioNodes: any, settings: any);
|
|
336
|
+
isDrum: boolean;
|
|
337
|
+
programNumber: number;
|
|
338
|
+
scheduleIndex: number;
|
|
339
|
+
detune: number;
|
|
340
|
+
bankMSB: number;
|
|
341
|
+
bankLSB: number;
|
|
342
|
+
dataMSB: number;
|
|
343
|
+
dataLSB: number;
|
|
344
|
+
rpnMSB: number;
|
|
345
|
+
rpnLSB: number;
|
|
346
|
+
mono: boolean;
|
|
347
|
+
modulationDepthRange: number;
|
|
348
|
+
fineTuning: number;
|
|
349
|
+
coarseTuning: number;
|
|
350
|
+
scheduledNotes: any[];
|
|
351
|
+
sustainNotes: any[];
|
|
352
|
+
sostenutoNotes: any[];
|
|
353
|
+
controlTable: Int8Array<ArrayBuffer>;
|
|
354
|
+
scaleOctaveTuningTable: Int8Array<ArrayBuffer>;
|
|
355
|
+
channelPressureTable: Int8Array<ArrayBuffer>;
|
|
356
|
+
keyBasedTable: Int8Array<ArrayBuffer>;
|
|
357
|
+
keyBasedGainLs: any[];
|
|
358
|
+
keyBasedGainRs: any[];
|
|
359
|
+
currentBufferSource: null;
|
|
360
|
+
state: ControllerState;
|
|
361
|
+
resetSettings(settings: any): void;
|
|
362
|
+
resetTable(): void;
|
|
363
|
+
}
|
|
364
|
+
declare class ControllerState {
|
|
365
|
+
array: Float32Array<ArrayBuffer>;
|
|
366
|
+
}
|
|
367
|
+
export {};
|
|
332
368
|
//# sourceMappingURL=midy-GM2.d.ts.map
|
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":"
|
|
1
|
+
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"AAoOA;IAwDE;;;;;;;;;;;;;;MAcE;IAEF,+BAsBC;IAzFD,gCAAgC;IAChC,aAAa;IACb,yBAAqB;IACrB,2BAAuB;IACvB;;;;MAIE;IACF;;;;;;MAME;IACF,oBAAiB;IACjB,qBAAmB;IACnB,kBAAc;IACd,0BAAsB;IACtB,+BAA6B;IAC7B,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,0BAAuD;IACvD,4BAAyB;IACzB,0BAAuB;IACvB,kCAA+B;IAC/B,qBAAqC;IACrC,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,iCAEG;IACH,cAAU;IACV,cAAa;IACb,iBAAY;IACZ,gBAAc;IACd,oBAAkB;IAClB,sBAAwB;IACxB,2BAAqC;IACrC,+BAEE;IAoBA,kBAAgC;IAChC,kBAA8C;IAC9C,eAAwD;IACxD,qBAGE;IACF,uBAAmD;IACnD;;;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AKC;IAED,kDAKC;IAED,8CAOC;IAED,gEAMC;IAED;;;;;;;;;;;;MAwDC;IAED,oFAOC;IAED,6EA+BC;IAED,qCA2BC;IAED,+FAeC;IAED,+CAEC;IAED,wDAUC;IAED,4EAMC;IAED,wDAeC;IAED,2EAMC;IAED,mEAKC;IAED,mDAQC;IAED;;;MAMC;IAED,gEAWC;IAED,uEAKC;IAED,+CAEC;IAED,sEAGC;IAED,2DAWC;IAED,4EAoBC;IAED,yEAYC;IAED,+CAEC;IAED,uEAMC;IAED,2EAcC;IAED,oDAEC;IAED,0EAeC;IAED,sFAQC;IAED,sFAQC;IAED,kFAeC;IAED,2DAMC;IAED,uDAuBC;IAED,gDAEC;IAED,gDAEC;IAED,sEAGC;IAED,qEAKC;IAED,2EAWC;IAED,iEAMC;IAED,uEASC;IAED,mEAKC;IAED,yEASC;IAED,2EAKC;IAED,iFAMC;IAED,gFAGC;IAED,6CAsBC;IAGD,8EAoCC;IAED,gFAGC;IAED,iEAEC;IAED,gEAEC;IAED,gEAIC;IAED,gEAIC;IAED,+EAgCC;IAED,qCAaC;IAED,qCAaC;IAED,4EAwCC;IAED,4DAGC;IAED,qDAKC;IAED,gEAIC;IAED,yDAYC;IAED,kEAGC;IAED,2DAYC;IAED,sEAeC;IAED,4CAOC;IAED,+BAIC;IAED,qDAiBC;IAED,gCAGC;IAED,kCAEC;IA6BD,4CAEC;IAED,+DAaC;IAED,kDAiBC;IAED,2GAKC;IAED,sDAIC;IAED,qCAEC;IAED,uDAMC;IAED,sCAEC;IAED,uDASC;IAED,sCAEC;IAED,2DAqBC;IAED,0CAEC;IAED,mCAeC;IAED,2FAgBC;IAED,wDAEC;IAED,+DAGC;IAED,qEASC;IAED,uEAOC;IAED,6CAEC;IAED,iDAEC;IAED,6CAEC;IAED,iDAEC;IAED,uCAEC;IAED,wCAEC;IAED,2CAEC;IAED,8BAyBC;IAED,0EAQC;IAED,4EAOC;IAED,qFASC;IAED,+DAEC;IAED,wEAcC;IAED,6DAiBC;IAED,yEAIC;IAED,0CAmBC;IAED,yEAcC;IAED,gDAYC;IAGD,6DAgBC;CACF;AAhmGD;IA0BE,4CAIC;IA7BD,gBAAe;IACf,sBAAkB;IAClB,sBAAkB;IAClB,eAAW;IACX,gBAAc;IACd,gBAAY;IACZ,gBAAY;IACZ,gBAAY;IACZ,eAAa;IACb,eAAa;IACb,cAAa;IACb,6BAA0B;IAC1B,mBAAe;IACf,qBAAiB;IACjB,sBAAoB;IACpB,oBAAkB;IAClB,sBAAoB;IACpB,qCAAmD;IACnD,+CAA2C;IAC3C,6CAA4D;IAC5D,sCAAkD;IAClD,sBAAgC;IAChC,sBAAgC;IAChC,0BAA2B;IAKzB,uBAAkC;IAGpC,mCAEC;IAED,mBAKC;CACF;AAwED;IACE,iCAA8B;CAa/B"}
|
package/script/midy-GM2.js
CHANGED
|
@@ -125,6 +125,166 @@ class Note {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
class Channel {
|
|
129
|
+
constructor(audioNodes, settings) {
|
|
130
|
+
Object.defineProperty(this, "isDrum", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: false
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(this, "programNumber", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: 0
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(this, "scheduleIndex", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: 0
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(this, "detune", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: 0
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(this, "bankMSB", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: 121
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(this, "bankLSB", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true,
|
|
164
|
+
value: 0
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(this, "dataMSB", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: 0
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(this, "dataLSB", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: 0
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(this, "rpnMSB", {
|
|
179
|
+
enumerable: true,
|
|
180
|
+
configurable: true,
|
|
181
|
+
writable: true,
|
|
182
|
+
value: 127
|
|
183
|
+
});
|
|
184
|
+
Object.defineProperty(this, "rpnLSB", {
|
|
185
|
+
enumerable: true,
|
|
186
|
+
configurable: true,
|
|
187
|
+
writable: true,
|
|
188
|
+
value: 127
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(this, "mono", {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
configurable: true,
|
|
193
|
+
writable: true,
|
|
194
|
+
value: false
|
|
195
|
+
}); // CC#124, CC#125
|
|
196
|
+
Object.defineProperty(this, "modulationDepthRange", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
configurable: true,
|
|
199
|
+
writable: true,
|
|
200
|
+
value: 50
|
|
201
|
+
}); // cent
|
|
202
|
+
Object.defineProperty(this, "fineTuning", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
configurable: true,
|
|
205
|
+
writable: true,
|
|
206
|
+
value: 0
|
|
207
|
+
}); // cent
|
|
208
|
+
Object.defineProperty(this, "coarseTuning", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
configurable: true,
|
|
211
|
+
writable: true,
|
|
212
|
+
value: 0
|
|
213
|
+
}); // cent
|
|
214
|
+
Object.defineProperty(this, "scheduledNotes", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true,
|
|
218
|
+
value: []
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(this, "sustainNotes", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
configurable: true,
|
|
223
|
+
writable: true,
|
|
224
|
+
value: []
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(this, "sostenutoNotes", {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
configurable: true,
|
|
229
|
+
writable: true,
|
|
230
|
+
value: []
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(this, "controlTable", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
configurable: true,
|
|
235
|
+
writable: true,
|
|
236
|
+
value: new Int8Array(defaultControlValues)
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(this, "scaleOctaveTuningTable", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
configurable: true,
|
|
241
|
+
writable: true,
|
|
242
|
+
value: new Int8Array(12)
|
|
243
|
+
}); // [-64, 63] cent
|
|
244
|
+
Object.defineProperty(this, "channelPressureTable", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
configurable: true,
|
|
247
|
+
writable: true,
|
|
248
|
+
value: new Int8Array(defaultPressureValues)
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(this, "keyBasedTable", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
configurable: true,
|
|
253
|
+
writable: true,
|
|
254
|
+
value: new Int8Array(128 * 128).fill(-1)
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(this, "keyBasedGainLs", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
configurable: true,
|
|
259
|
+
writable: true,
|
|
260
|
+
value: new Array(128)
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(this, "keyBasedGainRs", {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
configurable: true,
|
|
265
|
+
writable: true,
|
|
266
|
+
value: new Array(128)
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(this, "currentBufferSource", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
configurable: true,
|
|
271
|
+
writable: true,
|
|
272
|
+
value: null
|
|
273
|
+
});
|
|
274
|
+
Object.assign(this, audioNodes);
|
|
275
|
+
Object.assign(this, settings);
|
|
276
|
+
this.state = new ControllerState();
|
|
277
|
+
}
|
|
278
|
+
resetSettings(settings) {
|
|
279
|
+
Object.assign(this, settings);
|
|
280
|
+
}
|
|
281
|
+
resetTable() {
|
|
282
|
+
this.controlTable.set(defaultControlValues);
|
|
283
|
+
this.scaleOctaveTuningTable.fill(0); // [-100, 100] cent
|
|
284
|
+
this.channelPressureTable.set(defaultPressureValues);
|
|
285
|
+
this.keyBasedTable.fill(-1);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
128
288
|
const drumExclusiveClassesByKit = new Array(57);
|
|
129
289
|
const drumExclusiveClassCount = 10;
|
|
130
290
|
const standardSet = new Uint8Array(128);
|
|
@@ -636,32 +796,9 @@ class MidyGM2 extends EventTarget {
|
|
|
636
796
|
merger,
|
|
637
797
|
};
|
|
638
798
|
}
|
|
639
|
-
resetChannelTable(channel) {
|
|
640
|
-
channel.controlTable.set(defaultControlValues);
|
|
641
|
-
channel.scaleOctaveTuningTable.fill(0); // [-100, 100] cent
|
|
642
|
-
channel.channelPressureTable.set(defaultPressureValues);
|
|
643
|
-
channel.keyBasedTable.fill(-1);
|
|
644
|
-
}
|
|
645
799
|
createChannels(audioContext) {
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
currentBufferSource: null,
|
|
649
|
-
isDrum: false,
|
|
650
|
-
state: new ControllerState(),
|
|
651
|
-
...this.constructor.channelSettings,
|
|
652
|
-
...this.createChannelAudioNodes(audioContext),
|
|
653
|
-
scheduledNotes: [],
|
|
654
|
-
sustainNotes: [],
|
|
655
|
-
sostenutoNotes: [],
|
|
656
|
-
controlTable: new Int8Array(defaultControlValues),
|
|
657
|
-
scaleOctaveTuningTable: new Int8Array(12), // [-64, 63] cent
|
|
658
|
-
channelPressureTable: new Int8Array(defaultPressureValues),
|
|
659
|
-
keyBasedTable: new Int8Array(128 * 128).fill(-1),
|
|
660
|
-
keyBasedGainLs: new Array(128),
|
|
661
|
-
keyBasedGainRs: new Array(128),
|
|
662
|
-
};
|
|
663
|
-
});
|
|
664
|
-
return channels;
|
|
800
|
+
const settings = this.constructor.channelSettings;
|
|
801
|
+
return Array.from({ length: this.numChannels }, () => new Channel(this.createChannelAudioNodes(audioContext), settings));
|
|
665
802
|
}
|
|
666
803
|
decodeOggVorbis(sample) {
|
|
667
804
|
const task = decoderQueue.then(async () => {
|
|
@@ -1860,7 +1997,7 @@ class MidyGM2 extends EventTarget {
|
|
|
1860
1997
|
const next = this.calcChannelPressureEffectValue(channel, 0);
|
|
1861
1998
|
channel.detune += next - prev;
|
|
1862
1999
|
this.processActiveNotes(channel, scheduleTime, (note) => {
|
|
1863
|
-
this.
|
|
2000
|
+
this.setChannelPressureEffects(channel, note, scheduleTime);
|
|
1864
2001
|
});
|
|
1865
2002
|
this.applyVoiceParams(channel, 13, scheduleTime);
|
|
1866
2003
|
}
|
|
@@ -2216,6 +2353,9 @@ class MidyGM2 extends EventTarget {
|
|
|
2216
2353
|
scheduleTime = this.audioContext.currentTime;
|
|
2217
2354
|
const channel = this.channels[channelNumber];
|
|
2218
2355
|
channel.state.volumeMSB = value / 127;
|
|
2356
|
+
this.applyVolume(channel, scheduleTime);
|
|
2357
|
+
}
|
|
2358
|
+
applyVolume(channel, scheduleTime) {
|
|
2219
2359
|
if (channel.isDrum) {
|
|
2220
2360
|
for (let i = 0; i < 128; i++) {
|
|
2221
2361
|
this.updateKeyBasedVolume(channel, i, scheduleTime);
|
|
@@ -2530,10 +2670,8 @@ class MidyGM2 extends EventTarget {
|
|
|
2530
2670
|
state[key] = defaultValue;
|
|
2531
2671
|
}
|
|
2532
2672
|
}
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
}
|
|
2536
|
-
this.resetChannelTable(channel);
|
|
2673
|
+
channel.reset(this.constructor.channelSettings);
|
|
2674
|
+
channel.resetTable();
|
|
2537
2675
|
this.mode = "GM2";
|
|
2538
2676
|
this.masterFineTuning = 0; // cent
|
|
2539
2677
|
this.masterCoarseTuning = 0; // cent
|
|
@@ -2671,7 +2809,7 @@ class MidyGM2 extends EventTarget {
|
|
|
2671
2809
|
case 9:
|
|
2672
2810
|
switch (data[3]) {
|
|
2673
2811
|
case 1: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
2674
|
-
return this.
|
|
2812
|
+
return this.handleChannelPressureSysEx(data, scheduelTime);
|
|
2675
2813
|
case 3: // https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/ca22.pdf
|
|
2676
2814
|
return this.handleControlChangeSysEx(data, scheduleTime);
|
|
2677
2815
|
default:
|
|
@@ -3023,14 +3161,7 @@ class MidyGM2 extends EventTarget {
|
|
|
3023
3161
|
this.setFilterEnvelope(channel, note, scheduleTime);
|
|
3024
3162
|
}
|
|
3025
3163
|
};
|
|
3026
|
-
handlers[2] = (channel, note, scheduleTime) =>
|
|
3027
|
-
if (0.5 <= channel.state.portamemento && 0 <= note.portamentoNoteNumber) {
|
|
3028
|
-
this.setPortamentoVolumeEnvelope(channel, note, scheduleTime);
|
|
3029
|
-
}
|
|
3030
|
-
else {
|
|
3031
|
-
this.setVolumeEnvelope(channel, note, scheduleTime);
|
|
3032
|
-
}
|
|
3033
|
-
};
|
|
3164
|
+
handlers[2] = (channel, note, scheduleTime) => this.applyVolume(channel, note, scheduleTime);
|
|
3034
3165
|
handlers[3] = (channel, note, scheduleTime) => this.setModLfoToPitch(channel, note, scheduleTime);
|
|
3035
3166
|
handlers[4] = (channel, note, scheduleTime) => this.setModLfoToFilterFc(channel, note, scheduleTime);
|
|
3036
3167
|
handlers[5] = (channel, note, scheduleTime) => this.setModLfoToVolume(channel, note, scheduleTime);
|
|
@@ -3046,6 +3177,9 @@ class MidyGM2 extends EventTarget {
|
|
|
3046
3177
|
handlers[i](channel, note, scheduleTime);
|
|
3047
3178
|
}
|
|
3048
3179
|
}
|
|
3180
|
+
setChannelPressureEffects(channel, note, scheduleTime) {
|
|
3181
|
+
this.setPressureEffects(channel, note, "channelPressureTable", scheduleTime);
|
|
3182
|
+
}
|
|
3049
3183
|
setPressureEffects(channel, note, tableName, scheduleTime) {
|
|
3050
3184
|
const handlers = this.effectHandlers;
|
|
3051
3185
|
const table = channel[tableName];
|
|
@@ -3057,6 +3191,9 @@ class MidyGM2 extends EventTarget {
|
|
|
3057
3191
|
handlers[i](channel, note, scheduleTime);
|
|
3058
3192
|
}
|
|
3059
3193
|
}
|
|
3194
|
+
handleChannelPressureSysEx(data, scheduleTime) {
|
|
3195
|
+
this.handlePressureSysEx(data, "channelPressureTable", scheduleTime);
|
|
3196
|
+
}
|
|
3060
3197
|
handlePressureSysEx(data, tableName, scheduleTime) {
|
|
3061
3198
|
const channelNumber = data[4];
|
|
3062
3199
|
const channel = this.channels[channelNumber];
|
package/script/midy-GMLite.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export class MidyGMLite extends EventTarget {
|
|
|
59
59
|
detune: (channel: any, note: any, scheduleTime: any) => void;
|
|
60
60
|
};
|
|
61
61
|
controlChangeHandlers: any[];
|
|
62
|
-
channels:
|
|
62
|
+
channels: Channel[];
|
|
63
63
|
addSoundFont(soundFont: any): void;
|
|
64
64
|
toUint8Array(input: any): Promise<Uint8Array<ArrayBuffer>>;
|
|
65
65
|
loadSoundFont(input: any): Promise<void>;
|
|
@@ -71,7 +71,7 @@ export class MidyGMLite extends EventTarget {
|
|
|
71
71
|
gainR: any;
|
|
72
72
|
merger: any;
|
|
73
73
|
};
|
|
74
|
-
createChannels(audioContext: any):
|
|
74
|
+
createChannels(audioContext: any): Channel[];
|
|
75
75
|
decodeOggVorbis(sample: any): Promise<any>;
|
|
76
76
|
createAudioBuffer(voiceParams: any): Promise<any>;
|
|
77
77
|
createBufferSource(channel: any, voiceParams: any, audioBuffer: any): any;
|
|
@@ -183,4 +183,25 @@ export class MidyGMLite extends EventTarget {
|
|
|
183
183
|
handleSysEx(data: any, scheduleTime: any): void;
|
|
184
184
|
scheduleTask(callback: any, scheduleTime: any): Promise<any>;
|
|
185
185
|
}
|
|
186
|
+
declare class Channel {
|
|
187
|
+
constructor(audioNodes: any, settings: any);
|
|
188
|
+
isDrum: boolean;
|
|
189
|
+
programNumber: number;
|
|
190
|
+
scheduleIndex: number;
|
|
191
|
+
detune: number;
|
|
192
|
+
dataMSB: number;
|
|
193
|
+
dataLSB: number;
|
|
194
|
+
rpnMSB: number;
|
|
195
|
+
rpnLSB: number;
|
|
196
|
+
modulationDepthRange: number;
|
|
197
|
+
scheduledNotes: any[];
|
|
198
|
+
sustainNotes: any[];
|
|
199
|
+
currentBufferSource: null;
|
|
200
|
+
state: ControllerState;
|
|
201
|
+
resetSettings(settings: any): void;
|
|
202
|
+
}
|
|
203
|
+
declare class ControllerState {
|
|
204
|
+
array: Float32Array<ArrayBuffer>;
|
|
205
|
+
}
|
|
206
|
+
export {};
|
|
186
207
|
//# sourceMappingURL=midy-GMLite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GMLite.d.ts","sourceRoot":"","sources":["../src/midy-GMLite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy-GMLite.d.ts","sourceRoot":"","sources":["../src/midy-GMLite.js"],"names":[],"mappings":"AA0JA;IAwCE;;;;;;;;;MASE;IAEF,+BAgBC;IA9DD,gCAAgC;IAChC,aAAa;IACb,oBAAiB;IACjB,qBAAmB;IACnB,kBAAc;IACd,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,0BAAuD;IACvD,4BAAyB;IACzB,0BAAuB;IACvB,kCAA+B;IAC/B,qB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FAYC;IAED,wDAUC;IAED,4EAKC;IAED,mEAKC;IAED;;;MAMC;IAED,gEAKC;IAED,uEAKC;IAED,sEAGC;IAED,2DAUC;IAED,yEAWC;IAED,kFAeC;IAED,uDAcC;IAED,gDAEC;IAED,gDAEC;IAED,sEAGC;IAED,qEAKC;IAED,2EAUC;IAED,gFAGC;IAED,6CAmBC;IAGD,8EAgCC;IAED,gFAGC;IAED,+EAgBC;IAED,qCAUC;IAED,4EAaC;IAED,4DAGC;IAED,qDAKC;IAED,gDAYC;IAGD,6DAgBC;CACF;AA7qDD;IAcE,4CAIC;IAjBD,gBAAe;IACf,sBAAkB;IAClB,sBAAkB;IAClB,eAAW;IACX,gBAAY;IACZ,gBAAY;IACZ,eAAa;IACb,eAAa;IACb,6BAA0B;IAC1B,sBAAoB;IACpB,oBAAkB;IAClB,0BAA2B;IAKzB,uBAAkC;IAGpC,mCAEC;CACF;AAqCD;IACE,iCAA8B;CAa/B"}
|
package/script/midy-GMLite.js
CHANGED
|
@@ -95,6 +95,88 @@ class Note {
|
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
class Channel {
|
|
99
|
+
constructor(audioNodes, settings) {
|
|
100
|
+
Object.defineProperty(this, "isDrum", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
configurable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
value: false
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(this, "programNumber", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
value: 0
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(this, "scheduleIndex", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
configurable: true,
|
|
115
|
+
writable: true,
|
|
116
|
+
value: 0
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(this, "detune", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
configurable: true,
|
|
121
|
+
writable: true,
|
|
122
|
+
value: 0
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(this, "dataMSB", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
configurable: true,
|
|
127
|
+
writable: true,
|
|
128
|
+
value: 0
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(this, "dataLSB", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
configurable: true,
|
|
133
|
+
writable: true,
|
|
134
|
+
value: 0
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(this, "rpnMSB", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: 127
|
|
141
|
+
});
|
|
142
|
+
Object.defineProperty(this, "rpnLSB", {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
configurable: true,
|
|
145
|
+
writable: true,
|
|
146
|
+
value: 127
|
|
147
|
+
});
|
|
148
|
+
Object.defineProperty(this, "modulationDepthRange", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: 50
|
|
153
|
+
}); // cent
|
|
154
|
+
Object.defineProperty(this, "scheduledNotes", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
configurable: true,
|
|
157
|
+
writable: true,
|
|
158
|
+
value: []
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(this, "sustainNotes", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true,
|
|
164
|
+
value: []
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(this, "currentBufferSource", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: null
|
|
171
|
+
});
|
|
172
|
+
Object.assign(this, audioNodes);
|
|
173
|
+
Object.assign(this, settings);
|
|
174
|
+
this.state = new ControllerState();
|
|
175
|
+
}
|
|
176
|
+
resetSettings(settings) {
|
|
177
|
+
Object.assign(this, settings);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
98
180
|
const drumExclusiveClasses = new Uint8Array(128);
|
|
99
181
|
drumExclusiveClasses[42] = 1;
|
|
100
182
|
drumExclusiveClasses[44] = 1;
|
|
@@ -498,18 +580,8 @@ class MidyGMLite extends EventTarget {
|
|
|
498
580
|
};
|
|
499
581
|
}
|
|
500
582
|
createChannels(audioContext) {
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
currentBufferSource: null,
|
|
504
|
-
isDrum: false,
|
|
505
|
-
state: new ControllerState(),
|
|
506
|
-
...this.constructor.channelSettings,
|
|
507
|
-
...this.createChannelAudioNodes(audioContext),
|
|
508
|
-
scheduledNotes: [],
|
|
509
|
-
sustainNotes: [],
|
|
510
|
-
};
|
|
511
|
-
});
|
|
512
|
-
return channels;
|
|
583
|
+
const settings = this.constructor.channelSettings;
|
|
584
|
+
return Array.from({ length: this.numChannels }, () => new Channel(this.createChannelAudioNodes(audioContext), settings));
|
|
513
585
|
}
|
|
514
586
|
decodeOggVorbis(sample) {
|
|
515
587
|
const task = decoderQueue.then(async () => {
|
|
@@ -1615,9 +1687,7 @@ class MidyGMLite extends EventTarget {
|
|
|
1615
1687
|
state[key] = defaultValue;
|
|
1616
1688
|
}
|
|
1617
1689
|
}
|
|
1618
|
-
|
|
1619
|
-
channel[key] = this.constructor.channelSettings[key];
|
|
1620
|
-
}
|
|
1690
|
+
channel.resetSettings(this.constructor.channelSettings);
|
|
1621
1691
|
this.mode = "GM1";
|
|
1622
1692
|
}
|
|
1623
1693
|
// https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/rp15.pdf
|