@marmooo/midy 0.1.2 → 0.1.3
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/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts +153 -0
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts.map +1 -0
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/{soundfont-parser@0.0.2 → soundfont-parser@0.0.4}/+esm.js +73 -66
- package/esm/midy-GM1.d.ts +17 -12
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +125 -96
- package/esm/midy-GM2.d.ts +21 -14
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +146 -107
- package/esm/midy-GMLite.d.ts +15 -12
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +115 -98
- package/esm/midy.d.ts +18 -15
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +147 -134
- package/package.json +1 -1
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts +153 -0
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts.map +1 -0
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/{soundfont-parser@0.0.2 → soundfont-parser@0.0.4}/+esm.js +75 -68
- package/script/midy-GM1.d.ts +17 -12
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +125 -96
- package/script/midy-GM2.d.ts +21 -14
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +146 -107
- package/script/midy-GMLite.d.ts +15 -12
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +115 -98
- package/script/midy.d.ts +18 -15
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +147 -134
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.2/+esm.d.ts +0 -135
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.2/+esm.d.ts.map +0 -1
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.2/+esm.d.ts +0 -135
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.2/+esm.d.ts.map +0 -1
package/script/midy-GMLite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MidyGMLite = void 0;
|
|
4
4
|
const _esm_js_1 = require("./deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.js");
|
|
5
|
-
const _esm_js_2 = require("./deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.
|
|
5
|
+
const _esm_js_2 = require("./deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.js");
|
|
6
6
|
class Note {
|
|
7
7
|
constructor(noteNumber, velocity, startTime, instrumentKey) {
|
|
8
8
|
Object.defineProperty(this, "bufferSource", {
|
|
@@ -11,25 +11,31 @@ class Note {
|
|
|
11
11
|
writable: true,
|
|
12
12
|
value: void 0
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(this, "
|
|
14
|
+
Object.defineProperty(this, "filterNode", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
configurable: true,
|
|
17
17
|
writable: true,
|
|
18
18
|
value: void 0
|
|
19
19
|
});
|
|
20
|
-
Object.defineProperty(this, "
|
|
20
|
+
Object.defineProperty(this, "volumeNode", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(this, "volumeDepth", {
|
|
21
27
|
enumerable: true,
|
|
22
28
|
configurable: true,
|
|
23
29
|
writable: true,
|
|
24
30
|
value: void 0
|
|
25
31
|
});
|
|
26
|
-
Object.defineProperty(this, "
|
|
32
|
+
Object.defineProperty(this, "modulationLFO", {
|
|
27
33
|
enumerable: true,
|
|
28
34
|
configurable: true,
|
|
29
35
|
writable: true,
|
|
30
36
|
value: void 0
|
|
31
37
|
});
|
|
32
|
-
Object.defineProperty(this, "
|
|
38
|
+
Object.defineProperty(this, "modulationDepth", {
|
|
33
39
|
enumerable: true,
|
|
34
40
|
configurable: true,
|
|
35
41
|
writable: true,
|
|
@@ -316,7 +322,7 @@ class MidyGMLite {
|
|
|
316
322
|
const t = this.audioContext.currentTime + offset;
|
|
317
323
|
queueIndex = await this.scheduleTimelineEvents(t, offset, queueIndex);
|
|
318
324
|
if (this.isPausing) {
|
|
319
|
-
await this.stopNotes();
|
|
325
|
+
await this.stopNotes(0, true);
|
|
320
326
|
this.notePromises = [];
|
|
321
327
|
resolve();
|
|
322
328
|
this.isPausing = false;
|
|
@@ -324,7 +330,7 @@ class MidyGMLite {
|
|
|
324
330
|
return;
|
|
325
331
|
}
|
|
326
332
|
else if (this.isStopping) {
|
|
327
|
-
await this.stopNotes();
|
|
333
|
+
await this.stopNotes(0, true);
|
|
328
334
|
this.notePromises = [];
|
|
329
335
|
resolve();
|
|
330
336
|
this.isStopping = false;
|
|
@@ -332,7 +338,7 @@ class MidyGMLite {
|
|
|
332
338
|
return;
|
|
333
339
|
}
|
|
334
340
|
else if (this.isSeeking) {
|
|
335
|
-
this.stopNotes();
|
|
341
|
+
this.stopNotes(0, true);
|
|
336
342
|
this.startTime = this.audioContext.currentTime;
|
|
337
343
|
queueIndex = this.getQueueIndex(this.resumeTime);
|
|
338
344
|
offset = this.resumeTime - this.startTime;
|
|
@@ -413,21 +419,24 @@ class MidyGMLite {
|
|
|
413
419
|
}
|
|
414
420
|
return { instruments, timeline };
|
|
415
421
|
}
|
|
416
|
-
|
|
422
|
+
async stopChannelNotes(channelNumber, velocity, stopPedal) {
|
|
417
423
|
const now = this.audioContext.currentTime;
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
this.notePromises.push(promise);
|
|
426
|
-
}
|
|
427
|
-
});
|
|
424
|
+
const channel = this.channels[channelNumber];
|
|
425
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
426
|
+
noteList.forEach((note) => {
|
|
427
|
+
if (note) {
|
|
428
|
+
const promise = this.scheduleNoteRelease(channelNumber, note.noteNumber, velocity, now, stopPedal);
|
|
429
|
+
this.notePromises.push(promise);
|
|
430
|
+
}
|
|
428
431
|
});
|
|
429
|
-
channel.scheduledNotes.clear();
|
|
430
432
|
});
|
|
433
|
+
channel.scheduledNotes.clear();
|
|
434
|
+
await Promise.all(this.notePromises);
|
|
435
|
+
}
|
|
436
|
+
stopNotes(velocity, stopPedal) {
|
|
437
|
+
for (let i = 0; i < this.channels.length; i++) {
|
|
438
|
+
this.stopChannelNotes(i, velocity, stopPedal);
|
|
439
|
+
}
|
|
431
440
|
return Promise.all(this.notePromises);
|
|
432
441
|
}
|
|
433
442
|
async start() {
|
|
@@ -510,36 +519,54 @@ class MidyGMLite {
|
|
|
510
519
|
}
|
|
511
520
|
setVolumeEnvelope(note) {
|
|
512
521
|
const { instrumentKey, startTime } = note;
|
|
513
|
-
note.
|
|
522
|
+
note.volumeNode = new GainNode(this.audioContext, { gain: 0 });
|
|
514
523
|
const attackVolume = this.cbToRatio(-instrumentKey.initialAttenuation);
|
|
515
524
|
const sustainVolume = attackVolume * (1 - instrumentKey.volSustain);
|
|
516
525
|
const volDelay = startTime + instrumentKey.volDelay;
|
|
517
526
|
const volAttack = volDelay + instrumentKey.volAttack;
|
|
518
527
|
const volHold = volAttack + instrumentKey.volHold;
|
|
519
528
|
const volDecay = volHold + instrumentKey.volDecay;
|
|
520
|
-
note.
|
|
529
|
+
note.volumeNode.gain
|
|
521
530
|
.setValueAtTime(1e-6, volDelay) // exponentialRampToValueAtTime() requires a non-zero value
|
|
522
531
|
.exponentialRampToValueAtTime(attackVolume, volAttack)
|
|
523
532
|
.setValueAtTime(attackVolume, volHold)
|
|
524
533
|
.linearRampToValueAtTime(sustainVolume, volDecay);
|
|
525
534
|
}
|
|
526
|
-
|
|
527
|
-
const { instrumentKey,
|
|
535
|
+
setPitch(note, semitoneOffset) {
|
|
536
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
537
|
+
const modEnvToPitch = instrumentKey.modEnvToPitch / 100;
|
|
538
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
539
|
+
if (modEnvToPitch === 0)
|
|
540
|
+
return;
|
|
541
|
+
const basePitch = note.bufferSource.playbackRate.value;
|
|
542
|
+
const peekPitch = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset + modEnvToPitch);
|
|
543
|
+
const modDelay = startTime + instrumentKey.modDelay;
|
|
544
|
+
const modAttack = modDelay + instrumentKey.modAttack;
|
|
545
|
+
const modHold = modAttack + instrumentKey.modHold;
|
|
546
|
+
const modDecay = modHold + instrumentKey.modDecay;
|
|
547
|
+
note.bufferSource.playbackRate.value
|
|
548
|
+
.setValueAtTime(basePitch, modDelay)
|
|
549
|
+
.exponentialRampToValueAtTime(peekPitch, modAttack)
|
|
550
|
+
.setValueAtTime(peekPitch, modHold)
|
|
551
|
+
.linearRampToValueAtTime(basePitch, modDecay);
|
|
552
|
+
}
|
|
553
|
+
setFilterNode(channel, note) {
|
|
554
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
528
555
|
const softPedalFactor = 1 -
|
|
529
556
|
(0.1 + (noteNumber / 127) * 0.2) * channel.softPedal;
|
|
530
557
|
const maxFreq = this.audioContext.sampleRate / 2;
|
|
531
558
|
const baseFreq = this.centToHz(instrumentKey.initialFilterFc) *
|
|
532
559
|
softPedalFactor;
|
|
533
560
|
const peekFreq = this.centToHz(instrumentKey.initialFilterFc + instrumentKey.modEnvToFilterFc) * softPedalFactor;
|
|
534
|
-
const sustainFreq =
|
|
535
|
-
(peekFreq - baseFreq) * (1 - instrumentKey.modSustain)
|
|
561
|
+
const sustainFreq = baseFreq +
|
|
562
|
+
(peekFreq - baseFreq) * (1 - instrumentKey.modSustain);
|
|
563
|
+
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
564
|
+
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
565
|
+
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
536
566
|
const modDelay = startTime + instrumentKey.modDelay;
|
|
537
567
|
const modAttack = modDelay + instrumentKey.modAttack;
|
|
538
568
|
const modHold = modAttack + instrumentKey.modHold;
|
|
539
569
|
const modDecay = modHold + instrumentKey.modDecay;
|
|
540
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
541
|
-
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
542
|
-
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
543
570
|
note.filterNode = new BiquadFilterNode(this.audioContext, {
|
|
544
571
|
type: "lowpass",
|
|
545
572
|
Q: instrumentKey.initialFilterQ / 10, // dB
|
|
@@ -550,35 +577,49 @@ class MidyGMLite {
|
|
|
550
577
|
.exponentialRampToValueAtTime(adjustedPeekFreq, modAttack)
|
|
551
578
|
.setValueAtTime(adjustedPeekFreq, modHold)
|
|
552
579
|
.linearRampToValueAtTime(adjustedSustainFreq, modDecay);
|
|
553
|
-
note.bufferSource.detune.setValueAtTime(note.bufferSource.detune.value + instrumentKey.modEnvToPitch, modDelay);
|
|
554
580
|
}
|
|
555
|
-
startModulation(channel, note,
|
|
581
|
+
startModulation(channel, note, startTime) {
|
|
556
582
|
const { instrumentKey } = note;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
});
|
|
560
|
-
note.modLFO = new OscillatorNode(this.audioContext, {
|
|
583
|
+
const { modLfoToPitch, modLfoToVolume } = instrumentKey;
|
|
584
|
+
note.modulationLFO = new OscillatorNode(this.audioContext, {
|
|
561
585
|
frequency: this.centToHz(instrumentKey.freqModLFO),
|
|
562
586
|
});
|
|
563
|
-
note.
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
587
|
+
note.filterDepth = new GainNode(this.audioContext, {
|
|
588
|
+
gain: instrumentKey.modLfoToFilterFc,
|
|
589
|
+
});
|
|
590
|
+
const modulationDepth = Math.abs(modLfoToPitch) + channel.modulationDepth;
|
|
591
|
+
const modulationDepthSign = (0 < modLfoToPitch) ? 1 : -1;
|
|
592
|
+
note.modulationDepth = new GainNode(this.audioContext, {
|
|
593
|
+
gain: modulationDepth * modulationDepthSign,
|
|
594
|
+
});
|
|
595
|
+
const volumeDepth = this.cbToRatio(Math.abs(modLfoToVolume)) - 1;
|
|
596
|
+
const volumeDepthSign = (0 < modLfoToVolume) ? 1 : -1;
|
|
597
|
+
note.volumeDepth = new GainNode(this.audioContext, {
|
|
598
|
+
gain: volumeDepth * volumeDepthSign,
|
|
599
|
+
});
|
|
600
|
+
note.modulationLFO.start(startTime + instrumentKey.delayModLFO);
|
|
601
|
+
note.modulationLFO.connect(note.filterDepth);
|
|
602
|
+
note.filterDepth.connect(note.filterNode.frequency);
|
|
603
|
+
note.modulationLFO.connect(note.modulationDepth);
|
|
604
|
+
note.modulationDepth.connect(note.bufferSource.detune);
|
|
605
|
+
note.modulationLFO.connect(note.volumeDepth);
|
|
606
|
+
note.volumeDepth.connect(note.volumeNode.gain);
|
|
568
607
|
}
|
|
569
608
|
async createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3) {
|
|
570
609
|
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
571
610
|
const note = new Note(noteNumber, velocity, startTime, instrumentKey);
|
|
572
611
|
note.bufferSource = await this.createNoteBufferNode(instrumentKey, isSF3);
|
|
573
|
-
|
|
612
|
+
this.setFilterNode(channel, note);
|
|
574
613
|
this.setVolumeEnvelope(note);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
614
|
+
if (0 < channel.modulationDepth) {
|
|
615
|
+
this.setPitch(note, semitoneOffset);
|
|
616
|
+
this.startModulation(channel, note, startTime);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
579
620
|
}
|
|
580
621
|
note.bufferSource.connect(note.filterNode);
|
|
581
|
-
note.filterNode.connect(note.
|
|
622
|
+
note.filterNode.connect(note.volumeNode);
|
|
582
623
|
note.bufferSource.start(startTime, instrumentKey.start / instrumentKey.sampleRate);
|
|
583
624
|
return note;
|
|
584
625
|
}
|
|
@@ -594,8 +635,8 @@ class MidyGMLite {
|
|
|
594
635
|
if (!instrumentKey)
|
|
595
636
|
return;
|
|
596
637
|
const note = await this.createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3);
|
|
597
|
-
note.
|
|
598
|
-
note.
|
|
638
|
+
note.volumeNode.connect(channel.gainL);
|
|
639
|
+
note.volumeNode.connect(channel.gainR);
|
|
599
640
|
const scheduledNotes = channel.scheduledNotes;
|
|
600
641
|
if (scheduledNotes.has(noteNumber)) {
|
|
601
642
|
scheduledNotes.get(noteNumber).push(note);
|
|
@@ -624,17 +665,14 @@ class MidyGMLite {
|
|
|
624
665
|
const velocityRate = (velocity + 127) / 127;
|
|
625
666
|
const volEndTime = stopTime +
|
|
626
667
|
note.instrumentKey.volRelease * velocityRate;
|
|
627
|
-
note.
|
|
668
|
+
note.volumeNode.gain
|
|
628
669
|
.cancelScheduledValues(stopTime)
|
|
629
670
|
.linearRampToValueAtTime(0, volEndTime);
|
|
630
|
-
const
|
|
631
|
-
const baseFreq = this.centToHz(note.instrumentKey.initialFilterFc);
|
|
632
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
633
|
-
const modEndTime = stopTime +
|
|
671
|
+
const modRelease = stopTime +
|
|
634
672
|
note.instrumentKey.modRelease * velocityRate;
|
|
635
673
|
note.filterNode.frequency
|
|
636
674
|
.cancelScheduledValues(stopTime)
|
|
637
|
-
.linearRampToValueAtTime(
|
|
675
|
+
.linearRampToValueAtTime(0, modRelease);
|
|
638
676
|
note.ending = true;
|
|
639
677
|
this.scheduleTask(() => {
|
|
640
678
|
note.bufferSource.loop = false;
|
|
@@ -643,15 +681,17 @@ class MidyGMLite {
|
|
|
643
681
|
note.bufferSource.onended = () => {
|
|
644
682
|
scheduledNotes[i] = null;
|
|
645
683
|
note.bufferSource.disconnect();
|
|
684
|
+
note.volumeNode.disconnect();
|
|
646
685
|
note.filterNode.disconnect();
|
|
647
|
-
note.
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
686
|
+
if (note.volumeDepth)
|
|
687
|
+
note.volumeDepth.disconnect();
|
|
688
|
+
if (note.modulationDepth)
|
|
689
|
+
note.modulationDepth.disconnect();
|
|
690
|
+
if (note.modulationLFO)
|
|
691
|
+
note.modulationLFO.stop();
|
|
652
692
|
resolve();
|
|
653
693
|
};
|
|
654
|
-
bufferSource.stop(volEndTime);
|
|
694
|
+
note.bufferSource.stop(volEndTime);
|
|
655
695
|
});
|
|
656
696
|
}
|
|
657
697
|
}
|
|
@@ -664,10 +704,10 @@ class MidyGMLite {
|
|
|
664
704
|
const channel = this.channels[channelNumber];
|
|
665
705
|
const promises = [];
|
|
666
706
|
channel.sustainPedal = false;
|
|
667
|
-
channel.scheduledNotes.forEach((
|
|
668
|
-
|
|
669
|
-
if (
|
|
670
|
-
const { noteNumber } =
|
|
707
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
708
|
+
noteList.forEach((note) => {
|
|
709
|
+
if (note) {
|
|
710
|
+
const { noteNumber } = note;
|
|
671
711
|
const promise = this.releaseNote(channelNumber, noteNumber, velocity);
|
|
672
712
|
promises.push(promise);
|
|
673
713
|
}
|
|
@@ -712,7 +752,7 @@ class MidyGMLite {
|
|
|
712
752
|
handleControlChange(channelNumber, controller, value) {
|
|
713
753
|
switch (controller) {
|
|
714
754
|
case 1:
|
|
715
|
-
return this.
|
|
755
|
+
return this.setModulationDepth(channelNumber, value);
|
|
716
756
|
case 6:
|
|
717
757
|
return this.dataEntryMSB(channelNumber, value);
|
|
718
758
|
case 7:
|
|
@@ -743,18 +783,19 @@ class MidyGMLite {
|
|
|
743
783
|
const now = this.audioContext.currentTime;
|
|
744
784
|
const activeNotes = this.getActiveNotes(channel, now);
|
|
745
785
|
activeNotes.forEach((activeNote) => {
|
|
746
|
-
if (activeNote.
|
|
747
|
-
|
|
748
|
-
gainNode.gain.setValueAtTime(this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation), now);
|
|
786
|
+
if (activeNote.modulationDepth) {
|
|
787
|
+
activeNote.modulationDepth.gain.setValueAtTime(channel.modulationDepth, now);
|
|
749
788
|
}
|
|
750
789
|
else {
|
|
790
|
+
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
791
|
+
this.setPitch(activeNote, semitoneOffset);
|
|
751
792
|
this.startModulation(channel, activeNote, now);
|
|
752
793
|
}
|
|
753
794
|
});
|
|
754
795
|
}
|
|
755
|
-
|
|
796
|
+
setModulationDepth(channelNumber, modulation) {
|
|
756
797
|
const channel = this.channels[channelNumber];
|
|
757
|
-
channel.
|
|
798
|
+
channel.modulationDepth = (modulation / 127) * channel.modulationDepthRange;
|
|
758
799
|
this.updateModulation(channel);
|
|
759
800
|
}
|
|
760
801
|
setVolume(channelNumber, volume) {
|
|
@@ -848,37 +889,13 @@ class MidyGMLite {
|
|
|
848
889
|
this.updateDetune(channel, detuneChange);
|
|
849
890
|
}
|
|
850
891
|
allSoundOff(channelNumber) {
|
|
851
|
-
|
|
852
|
-
const channel = this.channels[channelNumber];
|
|
853
|
-
const velocity = 0;
|
|
854
|
-
const stopPedal = true;
|
|
855
|
-
const promises = [];
|
|
856
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
857
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
858
|
-
if (activeNote) {
|
|
859
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, noteNumber, velocity, now, stopPedal);
|
|
860
|
-
promises.push(notePromise);
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
return promises;
|
|
892
|
+
return this.stopChannelNotes(channelNumber, 0, true);
|
|
864
893
|
}
|
|
865
894
|
resetAllControllers(channelNumber) {
|
|
866
895
|
Object.assign(this.channels[channelNumber], this.effectSettings);
|
|
867
896
|
}
|
|
868
897
|
allNotesOff(channelNumber) {
|
|
869
|
-
|
|
870
|
-
const channel = this.channels[channelNumber];
|
|
871
|
-
const velocity = 0;
|
|
872
|
-
const stopPedal = false;
|
|
873
|
-
const promises = [];
|
|
874
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
875
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
876
|
-
if (activeNote) {
|
|
877
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, activeNote.noteNumber, velocity, now, stopPedal);
|
|
878
|
-
promises.push(notePromise);
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
return promises;
|
|
898
|
+
return this.stopChannelNotes(channelNumber, 0, false);
|
|
882
899
|
}
|
|
883
900
|
handleUniversalNonRealTimeExclusiveMessage(data) {
|
|
884
901
|
switch (data[2]) {
|
|
@@ -972,7 +989,7 @@ Object.defineProperty(MidyGMLite, "channelSettings", {
|
|
|
972
989
|
dataLSB: 0,
|
|
973
990
|
program: 0,
|
|
974
991
|
pitchBend: 0,
|
|
975
|
-
modulationDepthRange:
|
|
992
|
+
modulationDepthRange: 50, // cent
|
|
976
993
|
}
|
|
977
994
|
});
|
|
978
995
|
Object.defineProperty(MidyGMLite, "effectSettings", {
|
|
@@ -981,7 +998,7 @@ Object.defineProperty(MidyGMLite, "effectSettings", {
|
|
|
981
998
|
writable: true,
|
|
982
999
|
value: {
|
|
983
1000
|
expression: 1,
|
|
984
|
-
|
|
1001
|
+
modulationDepth: 0,
|
|
985
1002
|
sustainPedal: false,
|
|
986
1003
|
rpnMSB: 127,
|
|
987
1004
|
rpnLSB: 127,
|
package/script/midy.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class Midy {
|
|
|
22
22
|
};
|
|
23
23
|
static effectSettings: {
|
|
24
24
|
expression: number;
|
|
25
|
-
|
|
25
|
+
modulationDepth: number;
|
|
26
26
|
sustainPedal: boolean;
|
|
27
27
|
portamento: boolean;
|
|
28
28
|
sostenutoPedal: boolean;
|
|
@@ -128,7 +128,8 @@ export class Midy {
|
|
|
128
128
|
instruments: Set<any>;
|
|
129
129
|
timeline: any[];
|
|
130
130
|
};
|
|
131
|
-
|
|
131
|
+
stopChannelNotes(channelNumber: any, velocity: any, stopPedal: any): Promise<void>;
|
|
132
|
+
stopNotes(velocity: any, stopPedal: any): Promise<any[]>;
|
|
132
133
|
start(): Promise<void>;
|
|
133
134
|
stop(): void;
|
|
134
135
|
pause(): void;
|
|
@@ -165,9 +166,10 @@ export class Midy {
|
|
|
165
166
|
calcSemitoneOffset(channel: any): any;
|
|
166
167
|
calcPlaybackRate(instrumentKey: any, noteNumber: any, semitoneOffset: any): number;
|
|
167
168
|
setVolumeEnvelope(note: any): void;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
setPitch(note: any, semitoneOffset: any): void;
|
|
170
|
+
setFilterNode(channel: any, note: any): void;
|
|
171
|
+
startModulation(channel: any, note: any, startTime: any): void;
|
|
172
|
+
startVibrato(channel: any, note: any, startTime: any): void;
|
|
171
173
|
createNote(channel: any, instrumentKey: any, noteNumber: any, velocity: any, startTime: any, isSF3: any): Promise<Note>;
|
|
172
174
|
calcBank(channel: any, channelNumber: any): any;
|
|
173
175
|
scheduleNoteOn(channelNumber: any, noteNumber: any, velocity: any, startTime: any): Promise<void>;
|
|
@@ -176,16 +178,16 @@ export class Midy {
|
|
|
176
178
|
releaseNote(channelNumber: any, noteNumber: any, velocity: any): Promise<any> | undefined;
|
|
177
179
|
releaseSustainPedal(channelNumber: any, halfVelocity: any): any[];
|
|
178
180
|
releaseSostenutoPedal(channelNumber: any, halfVelocity: any): any[];
|
|
179
|
-
handleMIDIMessage(statusByte: any, data1: any, data2: any): void |
|
|
181
|
+
handleMIDIMessage(statusByte: any, data1: any, data2: any): void | Promise<any>;
|
|
180
182
|
handlePolyphonicKeyPressure(channelNumber: any, noteNumber: any, pressure: any): void;
|
|
181
183
|
handleProgramChange(channelNumber: any, program: any): void;
|
|
182
184
|
handleChannelPressure(channelNumber: any, pressure: any): void;
|
|
183
185
|
handlePitchBendMessage(channelNumber: any, lsb: any, msb: any): void;
|
|
184
186
|
setPitchBend(channelNumber: any, pitchBend: any): void;
|
|
185
|
-
handleControlChange(channelNumber: any, controller: any, value: any): void |
|
|
187
|
+
handleControlChange(channelNumber: any, controller: any, value: any): void | Promise<void>;
|
|
186
188
|
setBankMSB(channelNumber: any, msb: any): void;
|
|
187
189
|
updateModulation(channel: any): void;
|
|
188
|
-
|
|
190
|
+
setModulationDepth(channelNumber: any, modulation: any): void;
|
|
189
191
|
setPortamentoTime(channelNumber: any, portamentoTime: any): void;
|
|
190
192
|
setVolume(channelNumber: any, volume: any): void;
|
|
191
193
|
panToGain(pan: any): {
|
|
@@ -223,9 +225,9 @@ export class Midy {
|
|
|
223
225
|
setCoarseTuning(channelNumber: any, coarseTuning: any): void;
|
|
224
226
|
handleModulationDepthRangeRPN(channelNumber: any): void;
|
|
225
227
|
setModulationDepthRange(channelNumber: any, modulationDepthRange: any): void;
|
|
226
|
-
allSoundOff(channelNumber: any):
|
|
228
|
+
allSoundOff(channelNumber: any): Promise<void>;
|
|
227
229
|
resetAllControllers(channelNumber: any): void;
|
|
228
|
-
allNotesOff(channelNumber: any):
|
|
230
|
+
allNotesOff(channelNumber: any): Promise<void>;
|
|
229
231
|
omniOff(): void;
|
|
230
232
|
omniOn(): void;
|
|
231
233
|
monoOn(): void;
|
|
@@ -265,12 +267,13 @@ export class Midy {
|
|
|
265
267
|
declare class Note {
|
|
266
268
|
constructor(noteNumber: any, velocity: any, startTime: any, instrumentKey: any);
|
|
267
269
|
bufferSource: any;
|
|
268
|
-
gainNode: any;
|
|
269
270
|
filterNode: any;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
volumeNode: any;
|
|
272
|
+
volumeDepth: any;
|
|
273
|
+
modulationLFO: any;
|
|
274
|
+
modulationDepth: any;
|
|
275
|
+
vibratoLFO: any;
|
|
276
|
+
vibratoDepth: any;
|
|
274
277
|
noteNumber: any;
|
|
275
278
|
velocity: any;
|
|
276
279
|
startTime: any;
|
package/script/midy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"AAwBA;IAkCE;;;;;;;;;;;;;;;;;;;;MAoBE;IAEF;;;;;;;;;;;MAWE;IAEF;;;;;;;MAOE;IAgCF;;;;;OAWC;IAtHD,qBAAmB;IACnB,kBAAc;IACd,yBAAqB;IACrB,2BAAuB;IACvB;;;MAGE;IACF;;;;;;MAME;IACF,cAAa;IACb,cAAa;IACb,0BAAwB;IACxB,kBAAc;IACd,mBAAiB;IACjB,kBAAc;IACd,mBAAe;IACf,kBAAgB;IAChB,sBAA2C;IAC3C,mBAAkB;IAClB,mBAAkB;IAClB,kBAAiB;IACjB,oBAAmB;IACnB,mBAAkB;IAClB,gBAAc;IACd,mBAAiB;IACjB,oBAAkB;IA8ClB;;;;;MA4BE;IAGA,kBAAgC;IAChC;;;;;MAAqD;IACrD,gBAA4C;IAC5C,gBAAiD;IACjD;;;MAA8D;IAC9D;;;;;;;;MAAyD;IAO3D,4BAMC;IAED,mCASC;IAED,gDAMC;IAED,sCASC;IAED;;;;MAeC;IAED,yCAiBC;IAED,+DAyBC;IAED,mEAWC;IAED,qDAOC;IAED,2EAyDC;IAED,mCAOC;IAED,0BA+CC;IAED,uDAEC;IAED,wDAEC;IAED;;;MAgGC;IAED,mFAmBC;IAED,yDAKC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,uDASC;IAED,6CAQC;IAED,kFAuBC;IAED;;;;MAWC;IAED,gFAUC;IAED,mFAYC;IAED,sGAcC;IAID;;;MA+BC;IAED;;;;;;;;MA0CC;IAED,2BAEC;IAED,4BAEC;IAED,sCAKC;IAED,mFAGC;IAED,mCAcC;IAED,+CAwBC;IAED,6CA6BC;IAED,+DA0BC;IAED,4DAiBC;IAED,wHAqCC;IAED,gDAQC;IAED,kGAgCC;IAED,0EAGC;IAED,sIA+CC;IAED,0FAGC;IAED,kEAeC;IAED,oEAYC;IAED,gFAqBC;IAED,sFAcC;IAED,4DAIC;IAED,+DAcC;IAED,qEAGC;IAED,uDAOC;IAED,2FAkEC;IAED,+CAEC;IAED,qCAeC;IAED,8DAIC;IAED,iEAEC;IAED,iDAIC;IAED;;;MAMC;IAED,2CAIC;IAED,yDAIC;IAED,+CAEC;IAED,mDAGC;IAED,sCAUC;IAED,sDAMC;IAGD,oDAEC;IAED,mEAWC;IAED,mEAWC;IAED,wDAWC;IAED,uDAGC;IAED,2DAGC;IAED,6DAGC;IAED,6DAGC;IAED,kFAeC;IAED,2DAMC;IAED,gDAyBC;IAED,wCAEC;IAED,wCAEC;IAED,gDAEC;IAED,gDAEC;IAED,mDAGC;IAED,oDAUC;IAED,kDAKC;IAED,iEAOC;IAED,8CAKC;IAED,yDAMC;IAED,gDAKC;IAED,6DAMC;IAED,wDAKC;IAED,6EAKC;IAED,+CAEC;IAED,8CAEC;IAED,+CAEC;IAED,gBAEC;IAED,eAEC;IAED,eAEC;IAED,eAEC;IAED,4DAmBC;IAED,oBAQC;IAED,oBAQC;IAED,yDAiDC;IAED,yCAGC;IAED,mCAQC;IAED,6CAGC;IAED,2CAMC;IAED,+CAGC;IAED,+CAMC;IAED,mDAeC;IAED,4CAOC;IAED,+BAKC;IAED,qDAiBC;IAED,gCAMC;IAED,kCAEC;IA6BD,4CAEC;IAED,4CAaC;IAED,+BAiBC;IAED,wFAKC;IAED,mCAQC;IAED,qCAEC;IAED,oCAUC;IAED,sCAEC;IAED,oCAaC;IAED,sCAEC;IAED,wCAWC;IAED,0CAEC;IAED,wCAEC;IAED,6BASC;IAED,0DAUC;CACF;AAv1DD;IAUE,gFAKC;IAdD,kBAAa;IACb,gBAAW;IACX,gBAAW;IACX,iBAAY;IACZ,mBAAc;IACd,qBAAgB;IAChB,gBAAW;IACX,kBAAa;IAGX,gBAA4B;IAC5B,cAAwB;IACxB,eAA0B;IAC1B,mBAAkC;CAErC"}
|