@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/esm/midy-GMLite.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export class MidyGMLite {
|
|
|
29
29
|
isPaused: boolean;
|
|
30
30
|
isStopping: boolean;
|
|
31
31
|
isSeeking: boolean;
|
|
32
|
+
playPromise: any;
|
|
32
33
|
timeline: any[];
|
|
33
34
|
notePromises: any[];
|
|
34
35
|
instruments: Set<any>;
|
|
@@ -39,16 +40,16 @@ export class MidyGMLite {
|
|
|
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 MidyGMLite {
|
|
|
69
70
|
createBufferSource(channel: any, 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 MidyGMLite {
|
|
|
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;
|
|
@@ -123,16 +126,16 @@ export class MidyGMLite {
|
|
|
123
126
|
setDelayModLFO(note: any, scheduleTime: any): void;
|
|
124
127
|
setFreqModLFO(note: any, scheduleTime: any): void;
|
|
125
128
|
createVoiceParamsHandlers(): {
|
|
126
|
-
modLfoToPitch: (channel: any, note: any,
|
|
127
|
-
vibLfoToPitch: (_channel: any, _note: any,
|
|
128
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
129
|
-
modLfoToVolume: (channel: any, note: any,
|
|
130
|
-
chorusEffectsSend: (_channel: any, _note: any,
|
|
131
|
-
reverbEffectsSend: (_channel: any, _note: any,
|
|
132
|
-
delayModLFO: (_channel: any, note: any,
|
|
133
|
-
freqModLFO: (_channel: any, note: any,
|
|
134
|
-
delayVibLFO: (_channel: any, _note: any,
|
|
135
|
-
freqVibLFO: (_channel: any, _note: any,
|
|
129
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
130
|
+
vibLfoToPitch: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
131
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
132
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
133
|
+
chorusEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
134
|
+
reverbEffectsSend: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
135
|
+
delayModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
136
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
137
|
+
delayVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
138
|
+
freqVibLFO: (_channel: any, _note: any, _scheduleTime: any) => void;
|
|
136
139
|
};
|
|
137
140
|
getControllerState(channel: any, noteNumber: any, velocity: any): Float32Array<any>;
|
|
138
141
|
applyVoiceParams(channel: any, controllerType: any, scheduleTime: any): void;
|
|
@@ -158,7 +161,7 @@ export class MidyGMLite {
|
|
|
158
161
|
handlePitchBendRangeRPN(channelNumber: any, scheduleTime: any): void;
|
|
159
162
|
setPitchBendRange(channelNumber: any, value: any, scheduleTime: any): void;
|
|
160
163
|
allSoundOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
161
|
-
|
|
164
|
+
resetChannelStates(channelNumber: any): void;
|
|
162
165
|
resetAllControllers(channelNumber: any, _value: any, scheduleTime: any): void;
|
|
163
166
|
allNotesOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
164
167
|
handleUniversalNonRealTimeExclusiveMessage(data: any, scheduleTime: any): void;
|
package/esm/midy-GMLite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GMLite.d.ts","sourceRoot":"","sources":["../src/midy-GMLite.js"],"names":[],"mappings":"AA0GA;
|
|
1
|
+
{"version":3,"file":"midy-GMLite.d.ts","sourceRoot":"","sources":["../src/midy-GMLite.js"],"names":[],"mappings":"AA0GA;IA4BE;;;;;;;;;;MAUE;IAEF,+BAcC;IArDD,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,o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C;IAED,gDAEC;IAED,sEAGC;IAED,qEAKC;IAED,2EAUC;IAED,gFAGC;IAED,6CAqBC;IAGD,8EAgCC;IAED,gFAGC;IAED,+EAgBC;IAED,qCAWC;IAED,4EAaC;IAED,4DAGC;IAED,sDASC;IAED,gDAYC;IAGD,6DAgBC;CACF;AArhDD;IAWE,0FAMC;IAhBD,cAAW;IACX,gBAAe;IACf,kBAAa;IACb,gBAAW;IACX,iBAAY;IACZ,wBAAmB;IACnB,iBAAY;IACZ,mBAAc;IACd,qBAAgB;IAGd,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,WAAkB;IAClB,iBAA8B;CAEjC"}
|
package/esm/midy-GMLite.js
CHANGED
|
@@ -257,6 +257,12 @@ export class MidyGMLite {
|
|
|
257
257
|
writable: true,
|
|
258
258
|
value: false
|
|
259
259
|
});
|
|
260
|
+
Object.defineProperty(this, "playPromise", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
configurable: true,
|
|
263
|
+
writable: true,
|
|
264
|
+
value: void 0
|
|
265
|
+
});
|
|
260
266
|
Object.defineProperty(this, "timeline", {
|
|
261
267
|
enumerable: true,
|
|
262
268
|
configurable: true,
|
|
@@ -491,70 +497,80 @@ export class MidyGMLite {
|
|
|
491
497
|
}
|
|
492
498
|
return 0;
|
|
493
499
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
500
|
+
resetAllStates() {
|
|
501
|
+
this.exclusiveClassNotes.fill(undefined);
|
|
502
|
+
this.drumExclusiveClassNotes.fill(undefined);
|
|
503
|
+
this.voiceCache.clear();
|
|
504
|
+
for (let i = 0; i < this.channels.length; i++) {
|
|
505
|
+
this.channels[i].scheduledNotes = [];
|
|
506
|
+
this.resetChannelStates(i);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
updateStates(queueIndex, nextQueueIndex) {
|
|
510
|
+
if (nextQueueIndex < queueIndex)
|
|
511
|
+
queueIndex = 0;
|
|
512
|
+
for (let i = queueIndex; i < nextQueueIndex; i++) {
|
|
513
|
+
const event = this.timeline[i];
|
|
514
|
+
switch (event.type) {
|
|
515
|
+
case "controller":
|
|
516
|
+
this.setControlChange(event.channel, event.controllerType, event.value, 0);
|
|
517
|
+
break;
|
|
518
|
+
case "programChange":
|
|
519
|
+
this.setProgramChange(event.channel, event.programNumber, 0);
|
|
520
|
+
break;
|
|
521
|
+
case "pitchBend":
|
|
522
|
+
this.setPitchBend(event.channel, event.value + 8192, 0);
|
|
523
|
+
break;
|
|
524
|
+
case "sysEx":
|
|
525
|
+
this.handleSysEx(event.data, 0);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
async playNotes() {
|
|
530
|
+
if (this.audioContext.state === "suspended") {
|
|
531
|
+
await this.audioContext.resume();
|
|
532
|
+
}
|
|
533
|
+
this.isPlaying = true;
|
|
534
|
+
this.isPaused = false;
|
|
535
|
+
this.startTime = this.audioContext.currentTime;
|
|
536
|
+
let queueIndex = this.getQueueIndex(this.resumeTime);
|
|
537
|
+
let resumeTime = this.resumeTime - this.startTime;
|
|
538
|
+
let finished = false;
|
|
539
|
+
this.notePromises = [];
|
|
540
|
+
while (queueIndex < this.timeline.length) {
|
|
541
|
+
const now = this.audioContext.currentTime;
|
|
542
|
+
const t = now + resumeTime;
|
|
543
|
+
queueIndex = await this.scheduleTimelineEvents(t, resumeTime, queueIndex);
|
|
544
|
+
if (this.isPausing) {
|
|
545
|
+
await this.stopNotes(0, true, now);
|
|
546
|
+
await this.audioContext.suspend();
|
|
547
|
+
this.notePromises = [];
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
else if (this.isStopping) {
|
|
551
|
+
await this.stopNotes(0, true, now);
|
|
552
|
+
await this.audioContext.suspend();
|
|
553
|
+
finished = true;
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
else if (this.isSeeking) {
|
|
557
|
+
await this.stopNotes(0, true, now);
|
|
558
|
+
this.startTime = this.audioContext.currentTime;
|
|
559
|
+
const nextQueueIndex = this.getQueueIndex(this.resumeTime);
|
|
560
|
+
this.updateStates(queueIndex, nextQueueIndex);
|
|
561
|
+
queueIndex = nextQueueIndex;
|
|
562
|
+
resumeTime = this.resumeTime - this.startTime;
|
|
563
|
+
this.isSeeking = false;
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const waitTime = now + this.noteCheckInterval;
|
|
567
|
+
await this.scheduleTask(() => { }, waitTime);
|
|
568
|
+
}
|
|
569
|
+
if (finished) {
|
|
501
570
|
this.notePromises = [];
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
this.notePromises = [];
|
|
506
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
507
|
-
this.drumExclusiveClassNotes.fill(undefined);
|
|
508
|
-
this.voiceCache.clear();
|
|
509
|
-
for (let i = 0; i < this.channels.length; i++) {
|
|
510
|
-
this.resetAllStates(i);
|
|
511
|
-
}
|
|
512
|
-
resolve();
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
const now = this.audioContext.currentTime;
|
|
516
|
-
const t = now + resumeTime;
|
|
517
|
-
queueIndex = await this.scheduleTimelineEvents(t, resumeTime, queueIndex);
|
|
518
|
-
if (this.isPausing) {
|
|
519
|
-
await this.stopNotes(0, true, now);
|
|
520
|
-
this.notePromises = [];
|
|
521
|
-
this.isPausing = false;
|
|
522
|
-
this.isPaused = true;
|
|
523
|
-
resolve();
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
else if (this.isStopping) {
|
|
527
|
-
await this.stopNotes(0, true, now);
|
|
528
|
-
this.notePromises = [];
|
|
529
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
530
|
-
this.drumExclusiveClassNotes.fill(undefined);
|
|
531
|
-
this.voiceCache.clear();
|
|
532
|
-
for (let i = 0; i < this.channels.length; i++) {
|
|
533
|
-
this.resetAllStates(i);
|
|
534
|
-
}
|
|
535
|
-
this.isStopping = false;
|
|
536
|
-
this.isPaused = false;
|
|
537
|
-
resolve();
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
else if (this.isSeeking) {
|
|
541
|
-
this.stopNotes(0, true, now);
|
|
542
|
-
this.exclusiveClassNotes.fill(undefined);
|
|
543
|
-
this.drumExclusiveClassNotes.fill(undefined);
|
|
544
|
-
this.startTime = this.audioContext.currentTime;
|
|
545
|
-
queueIndex = this.getQueueIndex(this.resumeTime);
|
|
546
|
-
resumeTime = this.resumeTime - this.startTime;
|
|
547
|
-
this.isSeeking = false;
|
|
548
|
-
await schedulePlayback();
|
|
549
|
-
}
|
|
550
|
-
else {
|
|
551
|
-
const waitTime = now + this.noteCheckInterval;
|
|
552
|
-
await this.scheduleTask(() => { }, waitTime);
|
|
553
|
-
await schedulePlayback();
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
schedulePlayback();
|
|
557
|
-
});
|
|
571
|
+
this.resetAllStates();
|
|
572
|
+
}
|
|
573
|
+
this.isPlaying = false;
|
|
558
574
|
}
|
|
559
575
|
ticksToSecond(ticks, secondsPerBeat) {
|
|
560
576
|
return ticks * secondsPerBeat / this.ticksPerBeat;
|
|
@@ -655,26 +671,32 @@ export class MidyGMLite {
|
|
|
655
671
|
this.resumeTime = 0;
|
|
656
672
|
if (this.voiceCounter.size === 0)
|
|
657
673
|
this.cacheVoiceIds();
|
|
658
|
-
|
|
659
|
-
this.
|
|
674
|
+
this.playPromise = this.playNotes();
|
|
675
|
+
await this.playPromise;
|
|
660
676
|
}
|
|
661
|
-
stop() {
|
|
677
|
+
async stop() {
|
|
662
678
|
if (!this.isPlaying)
|
|
663
679
|
return;
|
|
664
680
|
this.isStopping = true;
|
|
681
|
+
await this.playPromise;
|
|
682
|
+
this.isStopping = false;
|
|
665
683
|
}
|
|
666
|
-
pause() {
|
|
684
|
+
async pause() {
|
|
667
685
|
if (!this.isPlaying || this.isPaused)
|
|
668
686
|
return;
|
|
669
687
|
const now = this.audioContext.currentTime;
|
|
670
688
|
this.resumeTime += now - this.startTime - this.startDelay;
|
|
671
689
|
this.isPausing = true;
|
|
690
|
+
await this.playPromise;
|
|
691
|
+
this.isPausing = false;
|
|
692
|
+
this.isPaused = true;
|
|
672
693
|
}
|
|
673
694
|
async resume() {
|
|
674
695
|
if (!this.isPaused)
|
|
675
696
|
return;
|
|
676
|
-
|
|
677
|
-
this.
|
|
697
|
+
this.playPromise = this.playNotes();
|
|
698
|
+
await this.playPromise;
|
|
699
|
+
this.isPaused = false;
|
|
678
700
|
}
|
|
679
701
|
seekTo(second) {
|
|
680
702
|
this.resumeTime = second;
|
|
@@ -1097,28 +1119,36 @@ export class MidyGMLite {
|
|
|
1097
1119
|
}
|
|
1098
1120
|
createVoiceParamsHandlers() {
|
|
1099
1121
|
return {
|
|
1100
|
-
modLfoToPitch: (channel, note,
|
|
1122
|
+
modLfoToPitch: (channel, note, scheduleTime) => {
|
|
1101
1123
|
if (0 < channel.state.modulationDepth) {
|
|
1102
1124
|
this.setModLfoToPitch(channel, note, scheduleTime);
|
|
1103
1125
|
}
|
|
1104
1126
|
},
|
|
1105
|
-
vibLfoToPitch: (_channel, _note,
|
|
1106
|
-
modLfoToFilterFc: (channel, note,
|
|
1127
|
+
vibLfoToPitch: (_channel, _note, _scheduleTime) => { },
|
|
1128
|
+
modLfoToFilterFc: (channel, note, scheduleTime) => {
|
|
1107
1129
|
if (0 < channel.state.modulationDepth) {
|
|
1108
1130
|
this.setModLfoToFilterFc(note, scheduleTime);
|
|
1109
1131
|
}
|
|
1110
1132
|
},
|
|
1111
|
-
modLfoToVolume: (channel, note,
|
|
1133
|
+
modLfoToVolume: (channel, note, scheduleTime) => {
|
|
1112
1134
|
if (0 < channel.state.modulationDepth) {
|
|
1113
1135
|
this.setModLfoToVolume(note, scheduleTime);
|
|
1114
1136
|
}
|
|
1115
1137
|
},
|
|
1116
|
-
chorusEffectsSend: (_channel, _note,
|
|
1117
|
-
reverbEffectsSend: (_channel, _note,
|
|
1118
|
-
delayModLFO: (_channel, note,
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1138
|
+
chorusEffectsSend: (_channel, _note, _scheduleTime) => { },
|
|
1139
|
+
reverbEffectsSend: (_channel, _note, _scheduleTime) => { },
|
|
1140
|
+
delayModLFO: (_channel, note, scheduleTime) => {
|
|
1141
|
+
if (0 < channel.state.modulationDepth) {
|
|
1142
|
+
this.setDelayModLFO(note, scheduleTime);
|
|
1143
|
+
}
|
|
1144
|
+
},
|
|
1145
|
+
freqModLFO: (_channel, note, scheduleTime) => {
|
|
1146
|
+
if (0 < channel.state.modulationDepth) {
|
|
1147
|
+
this.setFreqModLFO(note, scheduleTime);
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
delayVibLFO: (_channel, _note, _scheduleTime) => { },
|
|
1151
|
+
freqVibLFO: (_channel, _note, _scheduleTime) => { },
|
|
1122
1152
|
};
|
|
1123
1153
|
}
|
|
1124
1154
|
getControllerState(channel, noteNumber, velocity) {
|
|
@@ -1141,7 +1171,7 @@ export class MidyGMLite {
|
|
|
1141
1171
|
continue;
|
|
1142
1172
|
note.voiceParams[key] = value;
|
|
1143
1173
|
if (key in this.voiceParamsHandlers) {
|
|
1144
|
-
this.voiceParamsHandlers[key](channel, note,
|
|
1174
|
+
this.voiceParamsHandlers[key](channel, note, scheduleTime);
|
|
1145
1175
|
}
|
|
1146
1176
|
else {
|
|
1147
1177
|
if (volumeEnvelopeKeySet.has(key))
|
|
@@ -1298,8 +1328,8 @@ export class MidyGMLite {
|
|
|
1298
1328
|
}
|
|
1299
1329
|
handlePitchBendRangeRPN(channelNumber, scheduleTime) {
|
|
1300
1330
|
const channel = this.channels[channelNumber];
|
|
1301
|
-
this.limitData(channel, 0, 127, 0,
|
|
1302
|
-
const pitchBendRange = channel.dataMSB + channel.dataLSB / 100;
|
|
1331
|
+
this.limitData(channel, 0, 127, 0, 127);
|
|
1332
|
+
const pitchBendRange = (channel.dataMSB + channel.dataLSB / 128) * 100;
|
|
1303
1333
|
this.setPitchBendRange(channelNumber, pitchBendRange, scheduleTime);
|
|
1304
1334
|
}
|
|
1305
1335
|
setPitchBendRange(channelNumber, value, scheduleTime) {
|
|
@@ -1307,7 +1337,7 @@ export class MidyGMLite {
|
|
|
1307
1337
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1308
1338
|
const state = channel.state;
|
|
1309
1339
|
const prev = state.pitchWheelSensitivity;
|
|
1310
|
-
const next = value /
|
|
1340
|
+
const next = value / 12800;
|
|
1311
1341
|
state.pitchWheelSensitivity = next;
|
|
1312
1342
|
channel.detune += (state.pitchWheel * 2 - 1) * (next - prev) * 12800;
|
|
1313
1343
|
this.updateChannelDetune(channel, scheduleTime);
|
|
@@ -1317,7 +1347,7 @@ export class MidyGMLite {
|
|
|
1317
1347
|
scheduleTime ??= this.audioContext.currentTime;
|
|
1318
1348
|
return this.stopActiveNotes(channelNumber, 0, true, scheduleTime);
|
|
1319
1349
|
}
|
|
1320
|
-
|
|
1350
|
+
resetChannelStates(channelNumber) {
|
|
1321
1351
|
const scheduleTime = this.audioContext.currentTime;
|
|
1322
1352
|
const channel = this.channels[channelNumber];
|
|
1323
1353
|
const state = channel.state;
|
package/esm/midy.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export class Midy {
|
|
|
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 Midy {
|
|
|
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 Midy {
|
|
|
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 Midy {
|
|
|
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;
|
|
@@ -194,20 +197,21 @@ export class Midy {
|
|
|
194
197
|
setModLfoToVolume(channel: any, note: any, scheduleTime: any): void;
|
|
195
198
|
setReverbSend(channel: any, note: any, scheduleTime: any): void;
|
|
196
199
|
setChorusSend(channel: any, note: any, scheduleTime: any): void;
|
|
197
|
-
setDelayModLFO(note: any
|
|
200
|
+
setDelayModLFO(note: any): void;
|
|
198
201
|
setFreqModLFO(note: any, scheduleTime: any): void;
|
|
199
202
|
setFreqVibLFO(channel: any, note: any, scheduleTime: any): void;
|
|
203
|
+
setDelayVibLFO(channel: any, note: any): void;
|
|
200
204
|
createVoiceParamsHandlers(): {
|
|
201
|
-
modLfoToPitch: (channel: any, note: any,
|
|
202
|
-
vibLfoToPitch: (channel: any, note: any,
|
|
203
|
-
modLfoToFilterFc: (channel: any, note: any,
|
|
204
|
-
modLfoToVolume: (channel: any, note: any,
|
|
205
|
-
chorusEffectsSend: (channel: any, note: any,
|
|
206
|
-
reverbEffectsSend: (channel: any, note: any,
|
|
207
|
-
delayModLFO: (_channel: any, note: any,
|
|
208
|
-
freqModLFO: (_channel: any, note: any,
|
|
209
|
-
delayVibLFO: (channel: any, note: any,
|
|
210
|
-
freqVibLFO: (channel: any, note: any,
|
|
205
|
+
modLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
206
|
+
vibLfoToPitch: (channel: any, note: any, scheduleTime: any) => void;
|
|
207
|
+
modLfoToFilterFc: (channel: any, note: any, scheduleTime: any) => void;
|
|
208
|
+
modLfoToVolume: (channel: any, note: any, scheduleTime: any) => void;
|
|
209
|
+
chorusEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
210
|
+
reverbEffectsSend: (channel: any, note: any, scheduleTime: any) => void;
|
|
211
|
+
delayModLFO: (_channel: any, note: any, _scheduleTime: any) => void;
|
|
212
|
+
freqModLFO: (_channel: any, note: any, scheduleTime: any) => void;
|
|
213
|
+
delayVibLFO: (channel: any, note: any, _scheduleTime: any) => void;
|
|
214
|
+
freqVibLFO: (channel: any, note: any, scheduleTime: any) => void;
|
|
211
215
|
};
|
|
212
216
|
getControllerState(channel: any, noteNumber: any, velocity: any, polyphonicKeyPressure: any): Float32Array<any>;
|
|
213
217
|
applyVoiceParams(channel: any, controllerType: any, scheduleTime: any): void;
|
|
@@ -234,7 +238,8 @@ export class Midy {
|
|
|
234
238
|
setSostenutoPedal(channelNumber: any, value: any, scheduleTime: any): void;
|
|
235
239
|
getSoftPedalFactor(channel: any, note: any): number;
|
|
236
240
|
setSoftPedal(channelNumber: any, softPedal: any, scheduleTime: any): void;
|
|
237
|
-
setFilterResonance(channelNumber: any,
|
|
241
|
+
setFilterResonance(channelNumber: any, ccValue: any, scheduleTime: any): void;
|
|
242
|
+
getRelativeKeyBasedValue(channel: any, note: any, controllerType: any): any;
|
|
238
243
|
setReleaseTime(channelNumber: any, releaseTime: any, scheduleTime: any): void;
|
|
239
244
|
setAttackTime(channelNumber: any, attackTime: any, scheduleTime: any): void;
|
|
240
245
|
setBrightness(channelNumber: any, brightness: any, scheduleTime: any): void;
|
|
@@ -259,9 +264,9 @@ export class Midy {
|
|
|
259
264
|
handleCoarseTuningRPN(channelNumber: any, scheduleTime: any): void;
|
|
260
265
|
setCoarseTuning(channelNumber: any, value: any, scheduleTime: any): void;
|
|
261
266
|
handleModulationDepthRangeRPN(channelNumber: any, scheduleTime: any): void;
|
|
262
|
-
setModulationDepthRange(channelNumber: any,
|
|
267
|
+
setModulationDepthRange(channelNumber: any, value: any, scheduleTime: any): void;
|
|
263
268
|
allSoundOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
264
|
-
|
|
269
|
+
resetChannelStates(channelNumber: any): void;
|
|
265
270
|
resetAllControllers(channelNumber: any, _value: any, scheduleTime: any): void;
|
|
266
271
|
allNotesOff(channelNumber: any, _value: any, scheduleTime: any): Promise<any[]>;
|
|
267
272
|
omniOff(channelNumber: any, value: any, scheduleTime: any): void;
|
package/esm/midy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"AA4JA;
|
|
1
|
+
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"AA4JA;IA0CE;;;;;;;;;;;;;;;MAeE;IAEF,+BAkBC;IA5ED,aAAa;IACb,yBAAqB;IACrB,2BAAuB;IACvB;;;;MAIE;IACF;;;;;;MAME;IACF,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;IACrC,+BAEE;IAoBA,kBAAgC;IAChC,kBAA8C;IAC9C,eAAwD;IACxD,qBAGE;IACF;;;;;;;;;;;MAA2D;IAC3D,6BAA+D;IAC/D,gBAAiD;IACjD;;;kBAAyD;IACzD;;;;;;;;MAAyD;IAQ3D,4BAMC;IAED,mCASC;IAED,2DAYC;IAED,yCAmBC;IAED,oCASC;IAED,sBAoCC;IAED,8DAcC;IAED;;;;MAeC;IAED,sCAMC;IAED,yCAqBC;IAED,kDAUC;IAED,mDAIC;IAED,2FAWC;IAED,+EA6DC;IAED,mCAOC;IAED,uBAQC;IAED,yDA2BC;IAED,2BA+CC;IAED,uDAEC;IAED,wDAEC;IAED;;;MAoGC;IAED,kGAeC;IAED,mGAeC;IAED,wEAMC;IAED,uBAMC;IAED,sBAKC;IAED,uBAQC;IAED,wBAKC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,yDAQC;IAED,yEASC;IAED,kFAuBC;IAED;;;;MASC;IAED,gFAUC;IAED,mFAYC;IAED,sGAcC;IAID;;;MA8BC;IAED;;;kBA6BC;IAED;;;;;;;;MA0CC;IAED,2BAEC;IAED,8BAEC;IAED,8BAEC;IAED,4BAEC;IAED,qCAkBC;IAED,6CAEC;IAED,2DAIC;IAED,+DAiBC;IAED,mDAIC;IAED,2CAoDC;IAED,8EAYC;IAED,oEAkBC;IAED,+DAKC;IAED,qDAoBC;IAED,6CAIC;IAED,8EAqBC;IAED,oEAyBC;IAED,kEAoBC;IAED,+DAcC;IAED,6FAyBC;IAED,oGAmEC;IAED,4BAYC;IAED,0EAiBC;IAED,8EAoBC;IAED,kGAiDC;IAED,6FASC;IAED,gCAmBC;IAED,iEAqBC;IAED,qGAuBC;IAED,6CAUC;IAED,qDAUC;IAED,qFASC;IAED,sFAeC;IAED,wFAkBC;IAED,oGAoCC;IAED,sGAeC;IAED,mFAeC;IAED,4EAgBC;IAED,wFAGC;IAED,sEAWC;IAED,mEAYC;IAED,mEAaC;IAED,sEAMC;IAED,oEAQC;IAED,gEAyBC;IAED,gEAyBC;IAED,gCAKC;IAED,kDAKC;IAED,gEAMC;IAED,8CAOC;IAED;;;;;;;;;;;MAiDC;IAED,gHAQC;IAED,6EAgCC;IAED,qCAqCC;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,4E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