@marmooo/midy 0.3.6 → 0.3.7
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 +7 -9
- package/esm/midy-GM1.d.ts +27 -24
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +121 -89
- package/esm/midy-GM2.d.ts +30 -26
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +196 -144
- package/esm/midy-GMLite.d.ts +27 -24
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +114 -84
- package/esm/midy.d.ts +32 -27
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +294 -164
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +27 -24
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +121 -89
- package/script/midy-GM2.d.ts +30 -26
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +196 -144
- package/script/midy-GMLite.d.ts +27 -24
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +114 -84
- package/script/midy.d.ts +32 -27
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +294 -164
package/README.md
CHANGED
|
@@ -18,6 +18,11 @@ This library provides several files depending on the implementation level.
|
|
|
18
18
|
[ja v1.0](https://amei.or.jp/midistandardcommittee/Recommended_Practice/GM2_japanese.pdf))
|
|
19
19
|
- midy.js: full implementation (in progress)
|
|
20
20
|
|
|
21
|
+
## Demo
|
|
22
|
+
|
|
23
|
+
- [@marmooo/midi-player](https://marmooo.github.io/midi-player/) - GUI library
|
|
24
|
+
- [Humidy](https://marmooo.github.io/humidy/) - GM2 MIDI mixer app
|
|
25
|
+
|
|
21
26
|
## Usage
|
|
22
27
|
|
|
23
28
|
### Initialization
|
|
@@ -39,8 +44,8 @@ await midy.start();
|
|
|
39
44
|
|
|
40
45
|
```js
|
|
41
46
|
await midy.start();
|
|
42
|
-
midy.stop();
|
|
43
|
-
midy.pause();
|
|
47
|
+
await midy.stop();
|
|
48
|
+
await midy.pause();
|
|
44
49
|
await midy.resume();
|
|
45
50
|
midy.seekTo(second);
|
|
46
51
|
```
|
|
@@ -118,13 +123,6 @@ await midy.loadSoundFont(paths);
|
|
|
118
123
|
deno task build
|
|
119
124
|
```
|
|
120
125
|
|
|
121
|
-
## Test
|
|
122
|
-
|
|
123
|
-
WebAudio only works on web browsers currently, so we are testing this library
|
|
124
|
-
using the following GUI libraries.
|
|
125
|
-
|
|
126
|
-
- [@marmooo/midi-player](https://github.com/marmooo/midi-player)
|
|
127
|
-
|
|
128
126
|
## License
|
|
129
127
|
|
|
130
128
|
Apache-2.0
|
package/esm/midy-GM1.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export class MidyGM1 {
|
|
|
30
30
|
isPaused: boolean;
|
|
31
31
|
isStopping: boolean;
|
|
32
32
|
isSeeking: boolean;
|
|
33
|
+
playPromise: any;
|
|
33
34
|
timeline: any[];
|
|
34
35
|
notePromises: any[];
|
|
35
36
|
instruments: Set<any>;
|
|
@@ -39,16 +40,16 @@ export class MidyGM1 {
|
|
|
39
40
|
scheduler: any;
|
|
40
41
|
schedulerBuffer: any;
|
|
41
42
|
voiceParamsHandlers: {
|
|
42
|
-
modLfoToPitch: (channel: any, note: any,
|
|
43
|
-
vibLfoToPitch: (_channel: any, _note: any,
|
|
44
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
45
|
-
modLfoToVolume: (channel: any, note: any,
|
|
46
|
-
chorusEffectsSend: (_channel: any, _note: any,
|
|
47
|
-
reverbEffectsSend: (_channel: any, _note: any,
|
|
48
|
-
delayModLFO: (_channel: any, note: any,
|
|
49
|
-
freqModLFO: (_channel: any, note: any,
|
|
50
|
-
delayVibLFO: (_channel: any, _note: any,
|
|
51
|
-
freqVibLFO: (_channel: any, _note: any,
|
|
43
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
44
|
+
vibLfoToPitch: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
45
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
46
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
47
|
+
chorusEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
48
|
+
reverbEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
49
|
+
delayModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
50
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
51
|
+
delayVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
52
|
+
freqVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
52
53
|
};
|
|
53
54
|
controlChangeHandlers: any[];
|
|
54
55
|
channels: any[];
|
|
@@ -69,7 +70,9 @@ export class MidyGM1 {
|
|
|
69
70
|
createBufferSource(voiceParams: any, audioBuffer: any): any;
|
|
70
71
|
scheduleTimelineEvents(t: any, resumeTime: any, queueIndex: any): Promise<any>;
|
|
71
72
|
getQueueIndex(second: any): number;
|
|
72
|
-
|
|
73
|
+
resetAllStates(): void;
|
|
74
|
+
updateStates(queueIndex: any, nextQueueIndex: any): void;
|
|
75
|
+
playNotes(): Promise<void>;
|
|
73
76
|
ticksToSecond(ticks: any, secondsPerBeat: any): number;
|
|
74
77
|
secondToTicks(second: any, secondsPerBeat: any): number;
|
|
75
78
|
extractMidiData(midi: any): {
|
|
@@ -80,8 +83,8 @@ export class MidyGM1 {
|
|
|
80
83
|
stopChannelNotes(channelNumber: any, velocity: any, force: any, scheduleTime: any): Promise<any[]>;
|
|
81
84
|
stopNotes(velocity: any, force: any, scheduleTime: any): Promise<any[]>;
|
|
82
85
|
start(): Promise<void>;
|
|
83
|
-
stop(): void
|
|
84
|
-
pause(): void
|
|
86
|
+
stop(): Promise<void>;
|
|
87
|
+
pause(): Promise<void>;
|
|
85
88
|
resume(): Promise<void>;
|
|
86
89
|
seekTo(second: any): void;
|
|
87
90
|
calcTotalTime(): number;
|
|
@@ -122,16 +125,16 @@ export class MidyGM1 {
|
|
|
122
125
|
setDelayModLFO(note: any, scheduleTime: any): void;
|
|
123
126
|
setFreqModLFO(note: any, scheduleTime: any): void;
|
|
124
127
|
createVoiceParamsHandlers(): {
|
|
125
|
-
modLfoToPitch: (channel: any, note: any,
|
|
126
|
-
vibLfoToPitch: (_channel: any, _note: any,
|
|
127
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
128
|
-
modLfoToVolume: (channel: any, note: any,
|
|
129
|
-
chorusEffectsSend: (_channel: any, _note: any,
|
|
130
|
-
reverbEffectsSend: (_channel: any, _note: any,
|
|
131
|
-
delayModLFO: (_channel: any, note: any,
|
|
132
|
-
freqModLFO: (_channel: any, note: any,
|
|
133
|
-
delayVibLFO: (_channel: any, _note: any,
|
|
134
|
-
freqVibLFO: (_channel: any, _note: any,
|
|
128
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
129
|
+
vibLfoToPitch: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
130
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
131
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
132
|
+
chorusEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
133
|
+
reverbEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
134
|
+
delayModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
135
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
136
|
+
delayVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
137
|
+
freqVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
135
138
|
};
|
|
136
139
|
getControllerState(channel: any, noteNumber: any, velocity: any): Float32Array<any>;
|
|
137
140
|
applyVoiceParams(channel: any, controllerType: any, scheduleTime: any): void;
|
|
@@ -162,7 +165,7 @@ export class MidyGM1 {
|
|
|
162
165
|
handleCoarseTuningRPN(channelNumber: any, scheduleTime: any): void;
|
|
163
166
|
setCoarseTuning(channelNumber: any, value: any, scheduleTime: any): void;
|
|
164
167
|
allSoundOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
165
|
-
|
|
168
|
+
resetChannelStates(channelNumber: any): void;
|
|
166
169
|
resetAllControllers(channelNumber: any, _value: any, scheduleTime: any): void;
|
|
167
170
|
allNotesOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
168
171
|
handleUniversalNonRealTimeExclusiveMessage(data: any, scheduleTime: 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":"AA4FA;
|
|
1
|
+
{"version":3,"file":"midy-GM1.d.ts","sourceRoot":"","sources":["../src/midy-GM1.js"],"names":[],"mappings":"AA4FA;IAyBE;;;;;;;;;;;MAWE;IAEF,+BAcC;IAnDD,aAAa;IACb,oBAAiB;IACjB,qBAAmB;IACnB,kBAAc;IACd,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,sBAA2C;IAC3C,4BAAyB;IACzB,0BAAuB;IACvB,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,iBAAY;IACZ,gBAAc;IACd,oBAAkB;IAClB,sBAAwB;IACxB,2BAAqC;IAgBnC,kBAAgC;IAChC,kBAA8C;IAC9C,eAAwD;IACxD,qBAGE;IACF;;;;;;;;;;;MAA2D;IAC3D,6BAA+D;IAC/D,gBAAiD;IAMnD,4BAMC;IAED,mCASC;IAED,2DAYC;IAED,yCAmBC;IAED,oCASC;IAED,sBAoCC;IAED,8DAcC;IAED;;;;MAeC;IAED,yCAaC;IAED,kDAUC;IA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iBAAY;IACZ,mBAAc;IACd,qBAAgB;IAGd,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,WAAkB;IAClB,iBAA8B;CAEjC"}
|
package/esm/midy-GM1.js
CHANGED
|
@@ -244,6 +244,12 @@ export class MidyGM1 {
|
|
|
244
244
|
writable: true,
|
|
245
245
|
value: false
|
|
246
246
|
});
|
|
247
|
+
Object.defineProperty(this, "playPromise", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
configurable: true,
|
|
250
|
+
writable: true,
|
|
251
|
+
value: void 0
|
|
252
|
+
});
|
|
247
253
|
Object.defineProperty(this, "timeline", {
|
|
248
254
|
enumerable: true,
|
|
249
255
|
configurable: true,
|
|
@@ -470,69 +476,80 @@ export class MidyGM1 {
|
|
|
470
476
|
}
|
|
471
477
|
return 0;
|
|
472
478
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
479
|
+
resetAllStates() {
|
|
480
|
+
this.exclusiveClassNotes.fill(undefined);
|
|
481
|
+
this.drumExclusiveClassNotes.fill(undefined);
|
|
482
|
+
this.voiceCache.clear();
|
|
483
|
+
for (let i = 0; i < this.channels.length; i++) {
|
|
484
|
+
this.channels[i].scheduledNotes = [];
|
|
485
|
+
this.resetChannelStates(i);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
updateStates(queueIndex, nextQueueIndex) {
|
|
489
|
+
if (nextQueueIndex < queueIndex)
|
|
490
|
+
queueIndex = 0;
|
|
491
|
+
for (let i = queueIndex; i < nextQueueIndex; i++) {
|
|
492
|
+
const event = this.timeline[i];
|
|
493
|
+
switch (event.type) {
|
|
494
|
+
case "controller":
|
|
495
|
+
this.setControlChange(event.channel, event.controllerType, event.value, 0);
|
|
496
|
+
break;
|
|
497
|
+
case "programChange":
|
|
498
|
+
this.setProgramChange(event.channel, event.programNumber, 0);
|
|
499
|
+
break;
|
|
500
|
+
case "pitchBend":
|
|
501
|
+
this.setPitchBend(event.channel, event.value + 8192, 0);
|
|
502
|
+
break;
|
|
503
|
+
case "sysEx":
|
|
504
|
+
this.handleSysEx(event.data, 0);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
async playNotes() {
|
|
509
|
+
if (this.audioContext.state === "suspended") {
|
|
510
|
+
await this.audioContext.resume();
|
|
511
|
+
}
|
|
512
|
+
this.isPlaying = true;
|
|
513
|
+
this.isPaused = false;
|
|
514
|
+
this.startTime = this.audioContext.currentTime;
|
|
515
|
+
let queueIndex = this.getQueueIndex(this.resumeTime);
|
|
516
|
+
let resumeTime = this.resumeTime - this.startTime;
|
|
517
|
+
let finished = false;
|
|
518
|
+
this.notePromises = [];
|
|
519
|
+
while (queueIndex < this.timeline.length) {
|
|
520
|
+
const now = this.audioContext.currentTime;
|
|
521
|
+
const t = now + resumeTime;
|
|
522
|
+
queueIndex = await this.scheduleTimelineEvents(t, resumeTime, queueIndex);
|
|
523
|
+
if (this.isPausing) {
|
|
524
|
+
await this.stopNotes(0, true, now);
|
|
525
|
+
await this.audioContext.suspend();
|
|
526
|
+
this.notePromises = [];
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
else if (this.isStopping) {
|
|
530
|
+
await this.stopNotes(0, true, now);
|
|
531
|
+
await this.audioContext.suspend();
|
|
532
|
+
finished = true;
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
else if (this.isSeeking) {
|
|
536
|
+
await this.stopNotes(0, true, now);
|
|
537
|
+
this.startTime = this.audioContext.currentTime;
|
|
538
|
+
const nextQueueIndex = this.getQueueIndex(this.resumeTime);
|
|
539
|
+
this.updateStates(queueIndex, nextQueueIndex);
|
|
540
|
+
queueIndex = nextQueueIndex;
|
|
541
|
+
resumeTime = this.resumeTime - this.startTime;
|
|
542
|
+
this.isSeeking = false;
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
const waitTime = now + this.noteCheckInterval;
|
|
546
|
+
await this.scheduleTask(() => { }, waitTime);
|
|
547
|
+
}
|
|
548
|
+
if (finished) {
|
|
480
549
|
this.notePromises = [];
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
this.notePromises = [];
|
|
485
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
486
|
-
this.voiceCache.clear();
|
|
487
|
-
for (let i = 0; i < this.channels.length; i++) {
|
|
488
|
-
this.channels[i].scheduledNotes = [];
|
|
489
|
-
this.resetAllStates(i);
|
|
490
|
-
}
|
|
491
|
-
resolve();
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
const now = this.audioContext.currentTime;
|
|
495
|
-
const t = now + resumeTime;
|
|
496
|
-
queueIndex = await this.scheduleTimelineEvents(t, resumeTime, queueIndex);
|
|
497
|
-
if (this.isPausing) {
|
|
498
|
-
await this.stopNotes(0, true, now);
|
|
499
|
-
this.notePromises = [];
|
|
500
|
-
this.isPausing = false;
|
|
501
|
-
this.isPaused = true;
|
|
502
|
-
resolve();
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
else if (this.isStopping) {
|
|
506
|
-
await this.stopNotes(0, true, now);
|
|
507
|
-
this.notePromises = [];
|
|
508
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
509
|
-
this.voiceCache.clear();
|
|
510
|
-
for (let i = 0; i < this.channels.length; i++) {
|
|
511
|
-
this.channels[i].scheduledNotes = [];
|
|
512
|
-
this.resetAllStates(i);
|
|
513
|
-
}
|
|
514
|
-
this.isStopping = false;
|
|
515
|
-
this.isPaused = false;
|
|
516
|
-
resolve();
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
else if (this.isSeeking) {
|
|
520
|
-
this.stopNotes(0, true, now);
|
|
521
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
522
|
-
this.startTime = this.audioContext.currentTime;
|
|
523
|
-
queueIndex = this.getQueueIndex(this.resumeTime);
|
|
524
|
-
resumeTime = this.resumeTime - this.startTime;
|
|
525
|
-
this.isSeeking = false;
|
|
526
|
-
await schedulePlayback();
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
const waitTime = now + this.noteCheckInterval;
|
|
530
|
-
await this.scheduleTask(() => { }, waitTime);
|
|
531
|
-
await schedulePlayback();
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
schedulePlayback();
|
|
535
|
-
});
|
|
550
|
+
this.resetAllStates();
|
|
551
|
+
}
|
|
552
|
+
this.isPlaying = false;
|
|
536
553
|
}
|
|
537
554
|
ticksToSecond(ticks, secondsPerBeat) {
|
|
538
555
|
return ticks * secondsPerBeat / this.ticksPerBeat;
|
|
@@ -633,26 +650,32 @@ export class MidyGM1 {
|
|
|
633
650
|
this.resumeTime = 0;
|
|
634
651
|
if (this.voiceCounter.size === 0)
|
|
635
652
|
this.cacheVoiceIds();
|
|
636
|
-
|
|
637
|
-
this.
|
|
653
|
+
this.playPromise = this.playNotes();
|
|
654
|
+
await this.playPromise;
|
|
638
655
|
}
|
|
639
|
-
stop() {
|
|
656
|
+
async stop() {
|
|
640
657
|
if (!this.isPlaying)
|
|
641
658
|
return;
|
|
642
659
|
this.isStopping = true;
|
|
660
|
+
await this.playPromise;
|
|
661
|
+
this.isStopping = false;
|
|
643
662
|
}
|
|
644
|
-
pause() {
|
|
663
|
+
async pause() {
|
|
645
664
|
if (!this.isPlaying || this.isPaused)
|
|
646
665
|
return;
|
|
647
666
|
const now = this.audioContext.currentTime;
|
|
648
667
|
this.resumeTime += now - this.startTime - this.startDelay;
|
|
649
668
|
this.isPausing = true;
|
|
669
|
+
await this.playPromise;
|
|
670
|
+
this.isPausing = false;
|
|
671
|
+
this.isPaused = true;
|
|
650
672
|
}
|
|
651
673
|
async resume() {
|
|
652
674
|
if (!this.isPaused)
|
|
653
675
|
return;
|
|
654
|
-
|
|
655
|
-
this.
|
|
676
|
+
this.playPromise = this.playNotes();
|
|
677
|
+
await this.playPromise;
|
|
678
|
+
this.isPaused = false;
|
|
656
679
|
}
|
|
657
680
|
seekTo(second) {
|
|
658
681
|
this.resumeTime = second;
|
|
@@ -1057,28 +1080,36 @@ export class MidyGM1 {
|
|
|
1057
1080
|
}
|
|
1058
1081
|
createVoiceParamsHandlers() {
|
|
1059
1082
|
return {
|
|
1060
|
-
modLfoToPitch: (channel, note,
|
|
1083
|
+
modLfoToPitch: (channel, note, scheduleTime) => {
|
|
1061
1084
|
if (0 < channel.state.modulationDepth) {
|
|
1062
1085
|
this.setModLfoToPitch(channel, note, scheduleTime);
|
|
1063
1086
|
}
|
|
1064
1087
|
},
|
|
1065
|
-
vibLfoToPitch: (_channel, _note,
|
|
1066
|
-
modLfoToFilterFc: (channel, note,
|
|
1088
|
+
vibLfoToPitch: (_channel, _note, _scheduleTime) => { },
|
|
1089
|
+
modLfoToFilterFc: (channel, note, scheduleTime) => {
|
|
1067
1090
|
if (0 < channel.state.modulationDepth) {
|
|
1068
1091
|
this.setModLfoToFilterFc(note, scheduleTime);
|
|
1069
1092
|
}
|
|
1070
1093
|
},
|
|
1071
|
-
modLfoToVolume: (channel, note,
|
|
1094
|
+
modLfoToVolume: (channel, note, scheduleTime) => {
|
|
1072
1095
|
if (0 < channel.state.modulationDepth) {
|
|
1073
1096
|
this.setModLfoToVolume(note, scheduleTime);
|
|
1074
1097
|
}
|
|
1075
1098
|
},
|
|
1076
|
-
chorusEffectsSend: (_channel, _note,
|
|
1077
|
-
reverbEffectsSend: (_channel, _note,
|
|
1078
|
-
delayModLFO: (_channel, note,
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1099
|
+
chorusEffectsSend: (_channel, _note, _scheduleTime) => { },
|
|
1100
|
+
reverbEffectsSend: (_channel, _note, _scheduleTime) => { },
|
|
1101
|
+
delayModLFO: (_channel, note, scheduleTime) => {
|
|
1102
|
+
if (0 < channel.state.modulationDepth) {
|
|
1103
|
+
this.setDelayModLFO(note, scheduleTime);
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
freqModLFO: (_channel, note, scheduleTime) => {
|
|
1107
|
+
if (0 < channel.state.modulationDepth) {
|
|
1108
|
+
this.setFreqModLFO(note, scheduleTime);
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
delayVibLFO: (_channel, _note, _scheduleTime) => { },
|
|
1112
|
+
freqVibLFO: (_channel, _note, _scheduleTime) => { },
|
|
1082
1113
|
};
|
|
1083
1114
|
}
|
|
1084
1115
|
getControllerState(channel, noteNumber, velocity) {
|
|
@@ -1101,7 +1132,7 @@ export class MidyGM1 {
|
|
|
1101
1132
|
continue;
|
|
1102
1133
|
note.voiceParams[key] = value;
|
|
1103
1134
|
if (key in this.voiceParamsHandlers) {
|
|
1104
|
-
this.voiceParamsHandlers[key](channel, note,
|
|
1135
|
+
this.voiceParamsHandlers[key](channel, note, scheduleTime);
|
|
1105
1136
|
}
|
|
1106
1137
|
else {
|
|
1107
1138
|
if (volumeEnvelopeKeySet.has(key))
|
|
@@ -1272,8 +1303,8 @@ export class MidyGM1 {
|
|
|
1272
1303
|
}
|
|
1273
1304
|
handlePitchBendRangeRPN(channelNumber, scheduleTime) {
|
|
1274
1305
|
const channel = this.channels[channelNumber];
|
|
1275
|
-
this.limitData(channel, 0, 127, 0,
|
|
1276
|
-
const pitchBendRange = channel.dataMSB + channel.dataLSB / 100;
|
|
1306
|
+
this.limitData(channel, 0, 127, 0, 127);
|
|
1307
|
+
const pitchBendRange = (channel.dataMSB + channel.dataLSB / 128) * 100;
|
|
1277
1308
|
this.setPitchBendRange(channelNumber, pitchBendRange, scheduleTime);
|
|
1278
1309
|
}
|
|
1279
1310
|
setPitchBendRange(channelNumber, value, scheduleTime) {
|
|
@@ -1281,7 +1312,7 @@ export class MidyGM1 {
|
|
|
1281
1312
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1282
1313
|
const state = channel.state;
|
|
1283
1314
|
const prev = state.pitchWheelSensitivity;
|
|
1284
|
-
const next = value /
|
|
1315
|
+
const next = value / 12800;
|
|
1285
1316
|
state.pitchWheelSensitivity = next;
|
|
1286
1317
|
channel.detune += (state.pitchWheel * 2 - 1) * (next - prev) * 12800;
|
|
1287
1318
|
this.updateChannelDetune(channel, scheduleTime);
|
|
@@ -1290,14 +1321,15 @@ export class MidyGM1 {
|
|
|
1290
1321
|
handleFineTuningRPN(channelNumber, scheduleTime) {
|
|
1291
1322
|
const channel = this.channels[channelNumber];
|
|
1292
1323
|
this.limitData(channel, 0, 127, 0, 127);
|
|
1293
|
-
const
|
|
1324
|
+
const value = channel.dataMSB * 128 + channel.dataLSB;
|
|
1325
|
+
const fineTuning = (value - 8192) / 8192 * 100;
|
|
1294
1326
|
this.setFineTuning(channelNumber, fineTuning, scheduleTime);
|
|
1295
1327
|
}
|
|
1296
1328
|
setFineTuning(channelNumber, value, scheduleTime) {
|
|
1297
1329
|
const channel = this.channels[channelNumber];
|
|
1298
1330
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1299
1331
|
const prev = channel.fineTuning;
|
|
1300
|
-
const next =
|
|
1332
|
+
const next = value;
|
|
1301
1333
|
channel.fineTuning = next;
|
|
1302
1334
|
channel.detune += next - prev;
|
|
1303
1335
|
this.updateChannelDetune(channel, scheduleTime);
|
|
@@ -1305,14 +1337,14 @@ export class MidyGM1 {
|
|
|
1305
1337
|
handleCoarseTuningRPN(channelNumber, scheduleTime) {
|
|
1306
1338
|
const channel = this.channels[channelNumber];
|
|
1307
1339
|
this.limitDataMSB(channel, 0, 127);
|
|
1308
|
-
const coarseTuning = channel.dataMSB;
|
|
1340
|
+
const coarseTuning = (channel.dataMSB - 64) * 100;
|
|
1309
1341
|
this.setCoarseTuning(channelNumber, coarseTuning, scheduleTime);
|
|
1310
1342
|
}
|
|
1311
1343
|
setCoarseTuning(channelNumber, value, scheduleTime) {
|
|
1312
1344
|
const channel = this.channels[channelNumber];
|
|
1313
1345
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1314
1346
|
const prev = channel.coarseTuning;
|
|
1315
|
-
const next =
|
|
1347
|
+
const next = value;
|
|
1316
1348
|
channel.coarseTuning = next;
|
|
1317
1349
|
channel.detune += next - prev;
|
|
1318
1350
|
this.updateChannelDetune(channel, scheduleTime);
|
|
@@ -1321,7 +1353,7 @@ export class MidyGM1 {
|
|
|
1321
1353
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1322
1354
|
return this.stopActiveNotes(channelNumber, 0, true, scheduleTime);
|
|
1323
1355
|
}
|
|
1324
|
-
|
|
1356
|
+
resetChannelStates(channelNumber) {
|
|
1325
1357
|
const scheduleTime = this.audioContext.currentTime;
|
|
1326
1358
|
const channel = this.channels[channelNumber];
|
|
1327
1359
|
const state = channel.state;
|
|
@@ -1474,7 +1506,7 @@ Object.defineProperty(MidyGM1, "channelSettings", {
|
|
|
1474
1506
|
rpnMSB: 127,
|
|
1475
1507
|
rpnLSB: 127,
|
|
1476
1508
|
modulationDepthRange: 50, // cent
|
|
1477
|
-
fineTuning: 0, //
|
|
1478
|
-
coarseTuning: 0, //
|
|
1509
|
+
fineTuning: 0, // cent
|
|
1510
|
+
coarseTuning: 0, // cent
|
|
1479
1511
|
}
|
|
1480
1512
|
});
|
package/esm/midy-GM2.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export class MidyGM2 {
|
|
|
48
48
|
isPaused: boolean;
|
|
49
49
|
isStopping: boolean;
|
|
50
50
|
isSeeking: boolean;
|
|
51
|
+
playPromise: any;
|
|
51
52
|
timeline: any[];
|
|
52
53
|
notePromises: any[];
|
|
53
54
|
instruments: Set<any>;
|
|
@@ -58,16 +59,16 @@ export class MidyGM2 {
|
|
|
58
59
|
scheduler: any;
|
|
59
60
|
schedulerBuffer: any;
|
|
60
61
|
voiceParamsHandlers: {
|
|
61
|
-
modLfoToPitch: (channel: any, note: any,
|
|
62
|
-
vibLfoToPitch: (channel: any, note: any,
|
|
63
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
64
|
-
modLfoToVolume: (channel: any, note: any,
|
|
65
|
-
chorusEffectsSend: (channel: any, note: any,
|
|
66
|
-
reverbEffectsSend: (channel: any, note: any,
|
|
67
|
-
delayModLFO: (_channel: any, note: any,
|
|
68
|
-
freqModLFO: (_channel: any, note: any,
|
|
69
|
-
delayVibLFO: (channel: any, note: any,
|
|
70
|
-
freqVibLFO: (channel: any, note: any,
|
|
62
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
63
|
+
vibLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
64
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
65
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
66
|
+
chorusEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
67
|
+
reverbEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
68
|
+
delayModLFO: (_channel: any, note: any, _scheduleTime: any) => void;
|
|
69
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
70
|
+
delayVibLFO: (channel: any, note: any, _scheduleTime: any) => void;
|
|
71
|
+
freqVibLFO: (channel: any, note: any, scheduleTime: any) => void;
|
|
71
72
|
};
|
|
72
73
|
controlChangeHandlers: any[];
|
|
73
74
|
channels: any[];
|
|
@@ -103,7 +104,9 @@ export class MidyGM2 {
|
|
|
103
104
|
createBufferSource(channel: any, noteNumber: any, voiceParams: any, audioBuffer: any): any;
|
|
104
105
|
scheduleTimelineEvents(t: any, resumeTime: any, queueIndex: any): Promise<any>;
|
|
105
106
|
getQueueIndex(second: any): number;
|
|
106
|
-
|
|
107
|
+
resetAllStates(): void;
|
|
108
|
+
updateStates(queueIndex: any, nextQueueIndex: any): void;
|
|
109
|
+
playNotes(): Promise<void>;
|
|
107
110
|
ticksToSecond(ticks: any, secondsPerBeat: any): number;
|
|
108
111
|
secondToTicks(second: any, secondsPerBeat: any): number;
|
|
109
112
|
extractMidiData(midi: any): {
|
|
@@ -114,8 +117,8 @@ export class MidyGM2 {
|
|
|
114
117
|
stopChannelNotes(channelNumber: any, velocity: any, force: any, scheduleTime: any): Promise<any[]>;
|
|
115
118
|
stopNotes(velocity: any, force: any, scheduleTime: any): Promise<any[]>;
|
|
116
119
|
start(): Promise<void>;
|
|
117
|
-
stop(): void
|
|
118
|
-
pause(): void
|
|
120
|
+
stop(): Promise<void>;
|
|
121
|
+
pause(): Promise<void>;
|
|
119
122
|
resume(): Promise<void>;
|
|
120
123
|
seekTo(second: any): void;
|
|
121
124
|
calcTotalTime(): number;
|
|
@@ -193,20 +196,21 @@ export class MidyGM2 {
|
|
|
193
196
|
setModLfoToVolume(channel: any, note: any, scheduleTime: any): void;
|
|
194
197
|
setReverbSend(channel: any, note: any, scheduleTime: any): void;
|
|
195
198
|
setChorusSend(channel: any, note: any, scheduleTime: any): void;
|
|
196
|
-
setDelayModLFO(note: any
|
|
199
|
+
setDelayModLFO(note: any): void;
|
|
197
200
|
setFreqModLFO(note: any, scheduleTime: any): void;
|
|
198
201
|
setFreqVibLFO(channel: any, note: any, scheduleTime: any): void;
|
|
202
|
+
setDelayVibLFO(channel: any, note: any): void;
|
|
199
203
|
createVoiceParamsHandlers(): {
|
|
200
|
-
modLfoToPitch: (channel: any, note: any,
|
|
201
|
-
vibLfoToPitch: (channel: any, note: any,
|
|
202
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
203
|
-
modLfoToVolume: (channel: any, note: any,
|
|
204
|
-
chorusEffectsSend: (channel: any, note: any,
|
|
205
|
-
reverbEffectsSend: (channel: any, note: any,
|
|
206
|
-
delayModLFO: (_channel: any, note: any,
|
|
207
|
-
freqModLFO: (_channel: any, note: any,
|
|
208
|
-
delayVibLFO: (channel: any, note: any,
|
|
209
|
-
freqVibLFO: (channel: any, note: any,
|
|
204
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
205
|
+
vibLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
206
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
207
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
208
|
+
chorusEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
209
|
+
reverbEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
210
|
+
delayModLFO: (_channel: any, note: any, _scheduleTime: any) => void;
|
|
211
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
212
|
+
delayVibLFO: (channel: any, note: any, _scheduleTime: any) => void;
|
|
213
|
+
freqVibLFO: (channel: any, note: any, scheduleTime: any) => void;
|
|
210
214
|
};
|
|
211
215
|
getControllerState(channel: any, noteNumber: any, velocity: any): Float32Array<any>;
|
|
212
216
|
applyVoiceParams(channel: any, controllerType: any, scheduleTime: any): void;
|
|
@@ -248,9 +252,9 @@ export class MidyGM2 {
|
|
|
248
252
|
handleCoarseTuningRPN(channelNumber: any, scheduleTime: any): void;
|
|
249
253
|
setCoarseTuning(channelNumber: any, value: any, scheduleTime: any): void;
|
|
250
254
|
handleModulationDepthRangeRPN(channelNumber: any, scheduleTime: any): void;
|
|
251
|
-
setModulationDepthRange(channelNumber: any,
|
|
255
|
+
setModulationDepthRange(channelNumber: any, value: any, scheduleTime: any): void;
|
|
252
256
|
allSoundOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
253
|
-
|
|
257
|
+
resetChannelStates(channelNumber: any): void;
|
|
254
258
|
resetAllControllers(channelNumber: any, _value: any, scheduleTime: any): void;
|
|
255
259
|
allNotesOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
256
260
|
omniOff(channelNumber: any, value: any, scheduleTime: any): void;
|
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":"AAkJA;
|
|
1
|
+
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"AAkJA;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IAED,8EAWC;IAED,oEAgBC;IAED,+DAKC;IAED,qDAoBC;IAED,6CAIC;IAED,8EAoBC;IAED,oEAwBC;IAED,kEAoBC;IAED,+DAeC;IAED,6FAyBC;IAED,oGAiEC;IAED,4BAYC;IAED,0EAiBC;IAED,8EAoBC;IAED,kGAiDC;IAED,6FASC;IAED,gCAmBC;IAED,iEAoBC;IAED,qGAuBC;IAED,6CAUC;IAED,qDAUC;IAED,qFASC;IAED,sFAeC;IAED,wFAkBC;IAED,oGA6BC;IAED,mFAeC;IAED,4EAgBC;IAED,wFAGC;IAED,sEAWC;IAED,mEAYC;IAED,mEAYC;IAED,sEAMC;IAED,oEAQC;IAED,gEAyBC;IAED,gEAyBC;IAED,gCAKC;IAED,kDAKC;IAED,gEAMC;IAED,8CAOC;IAED;;;;;;;;;;;MAiDC;IAED,oFAOC;IAED,6EA+BC;IAED,qCA2BC;IAED,+FAYC;IAED,+CAEC;IAED,wDASC;IAED,iFAMC;IAED,wDAkBC;IAED,oFAMC;IAED,oEAWC;IAED;;;MAMC;IAED,8DAWC;IAED,4EAKC;IAED,+CAEC;IAED,sEAGC;IAED,2DAUC;IAED,4EAoBC;IAED,yEAYC;IAED,uEAMC;IAED,2EAcC;IAED,oDAEC;IAED,0EAeC;IAED,sFAQC;IAED,sFAQC;IAED,kFAeC;IAED,2DAMC;IAED,uDAqBC;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,6CAwBC;IAGD,8EAoCC;IAED,gFAGC;IAED,iEAEC;IAED,gEAEC;IAED,gEAIC;IAED,gEAIC;IAED,+EAgCC;IAED,qCAcC;IAED,qCAcC;IAED,4EA4CC;IAED,4DAGC;IAED,sDASC;IAED,gEAIC;IAED,yDAWC;IAED,kEAGC;IAED,2DAWC;IAED,sEAeC;IAED,4CAOC;IAED,+BAIC;I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