@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/esm/midy-GM1.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseMidi } from "./deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.js";
|
|
2
|
-
import { parse, SoundFont, } from "./deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.
|
|
2
|
+
import { parse, SoundFont, } from "./deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.js";
|
|
3
3
|
class Note {
|
|
4
4
|
constructor(noteNumber, velocity, startTime, instrumentKey) {
|
|
5
5
|
Object.defineProperty(this, "bufferSource", {
|
|
@@ -8,25 +8,43 @@ class Note {
|
|
|
8
8
|
writable: true,
|
|
9
9
|
value: void 0
|
|
10
10
|
});
|
|
11
|
-
Object.defineProperty(this, "
|
|
11
|
+
Object.defineProperty(this, "filterNode", {
|
|
12
12
|
enumerable: true,
|
|
13
13
|
configurable: true,
|
|
14
14
|
writable: true,
|
|
15
15
|
value: void 0
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(this, "
|
|
17
|
+
Object.defineProperty(this, "volumeNode", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "volumeDepth", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(this, "modulationLFO", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "modulationDepth", {
|
|
18
36
|
enumerable: true,
|
|
19
37
|
configurable: true,
|
|
20
38
|
writable: true,
|
|
21
39
|
value: void 0
|
|
22
40
|
});
|
|
23
|
-
Object.defineProperty(this, "
|
|
41
|
+
Object.defineProperty(this, "vibratoLFO", {
|
|
24
42
|
enumerable: true,
|
|
25
43
|
configurable: true,
|
|
26
44
|
writable: true,
|
|
27
45
|
value: void 0
|
|
28
46
|
});
|
|
29
|
-
Object.defineProperty(this, "
|
|
47
|
+
Object.defineProperty(this, "vibratoDepth", {
|
|
30
48
|
enumerable: true,
|
|
31
49
|
configurable: true,
|
|
32
50
|
writable: true,
|
|
@@ -313,7 +331,7 @@ export class MidyGM1 {
|
|
|
313
331
|
const t = this.audioContext.currentTime + offset;
|
|
314
332
|
queueIndex = await this.scheduleTimelineEvents(t, offset, queueIndex);
|
|
315
333
|
if (this.isPausing) {
|
|
316
|
-
await this.stopNotes();
|
|
334
|
+
await this.stopNotes(0, true);
|
|
317
335
|
this.notePromises = [];
|
|
318
336
|
resolve();
|
|
319
337
|
this.isPausing = false;
|
|
@@ -321,7 +339,7 @@ export class MidyGM1 {
|
|
|
321
339
|
return;
|
|
322
340
|
}
|
|
323
341
|
else if (this.isStopping) {
|
|
324
|
-
await this.stopNotes();
|
|
342
|
+
await this.stopNotes(0, true);
|
|
325
343
|
this.notePromises = [];
|
|
326
344
|
resolve();
|
|
327
345
|
this.isStopping = false;
|
|
@@ -329,7 +347,7 @@ export class MidyGM1 {
|
|
|
329
347
|
return;
|
|
330
348
|
}
|
|
331
349
|
else if (this.isSeeking) {
|
|
332
|
-
this.stopNotes();
|
|
350
|
+
this.stopNotes(0, true);
|
|
333
351
|
this.startTime = this.audioContext.currentTime;
|
|
334
352
|
queueIndex = this.getQueueIndex(this.resumeTime);
|
|
335
353
|
offset = this.resumeTime - this.startTime;
|
|
@@ -410,21 +428,24 @@ export class MidyGM1 {
|
|
|
410
428
|
}
|
|
411
429
|
return { instruments, timeline };
|
|
412
430
|
}
|
|
413
|
-
|
|
431
|
+
async stopChannelNotes(channelNumber, velocity, stopPedal) {
|
|
414
432
|
const now = this.audioContext.currentTime;
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.notePromises.push(promise);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
433
|
+
const channel = this.channels[channelNumber];
|
|
434
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
435
|
+
noteList.forEach((note) => {
|
|
436
|
+
if (note) {
|
|
437
|
+
const promise = this.scheduleNoteRelease(channelNumber, note.noteNumber, velocity, now, stopPedal);
|
|
438
|
+
this.notePromises.push(promise);
|
|
439
|
+
}
|
|
425
440
|
});
|
|
426
|
-
channel.scheduledNotes.clear();
|
|
427
441
|
});
|
|
442
|
+
channel.scheduledNotes.clear();
|
|
443
|
+
await Promise.all(this.notePromises);
|
|
444
|
+
}
|
|
445
|
+
stopNotes(velocity, stopPedal) {
|
|
446
|
+
for (let i = 0; i < this.channels.length; i++) {
|
|
447
|
+
this.stopChannelNotes(i, velocity, stopPedal);
|
|
448
|
+
}
|
|
428
449
|
return Promise.all(this.notePromises);
|
|
429
450
|
}
|
|
430
451
|
async start() {
|
|
@@ -508,21 +529,39 @@ export class MidyGM1 {
|
|
|
508
529
|
}
|
|
509
530
|
setVolumeEnvelope(note) {
|
|
510
531
|
const { instrumentKey, startTime } = note;
|
|
511
|
-
note.
|
|
532
|
+
note.volumeNode = new GainNode(this.audioContext, { gain: 0 });
|
|
512
533
|
const attackVolume = this.cbToRatio(-instrumentKey.initialAttenuation);
|
|
513
534
|
const sustainVolume = attackVolume * (1 - instrumentKey.volSustain);
|
|
514
535
|
const volDelay = startTime + instrumentKey.volDelay;
|
|
515
536
|
const volAttack = volDelay + instrumentKey.volAttack;
|
|
516
537
|
const volHold = volAttack + instrumentKey.volHold;
|
|
517
538
|
const volDecay = volHold + instrumentKey.volDecay;
|
|
518
|
-
note.
|
|
539
|
+
note.volumeNode.gain
|
|
519
540
|
.setValueAtTime(1e-6, volDelay) // exponentialRampToValueAtTime() requires a non-zero value
|
|
520
541
|
.exponentialRampToValueAtTime(attackVolume, volAttack)
|
|
521
542
|
.setValueAtTime(attackVolume, volHold)
|
|
522
543
|
.linearRampToValueAtTime(sustainVolume, volDecay);
|
|
523
544
|
}
|
|
524
|
-
|
|
525
|
-
const { instrumentKey,
|
|
545
|
+
setPitch(note, semitoneOffset) {
|
|
546
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
547
|
+
const modEnvToPitch = instrumentKey.modEnvToPitch / 100;
|
|
548
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
549
|
+
if (modEnvToPitch === 0)
|
|
550
|
+
return;
|
|
551
|
+
const basePitch = note.bufferSource.playbackRate.value;
|
|
552
|
+
const peekPitch = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset + modEnvToPitch);
|
|
553
|
+
const modDelay = startTime + instrumentKey.modDelay;
|
|
554
|
+
const modAttack = modDelay + instrumentKey.modAttack;
|
|
555
|
+
const modHold = modAttack + instrumentKey.modHold;
|
|
556
|
+
const modDecay = modHold + instrumentKey.modDecay;
|
|
557
|
+
note.bufferSource.playbackRate.value
|
|
558
|
+
.setValueAtTime(basePitch, modDelay)
|
|
559
|
+
.exponentialRampToValueAtTime(peekPitch, modAttack)
|
|
560
|
+
.setValueAtTime(peekPitch, modHold)
|
|
561
|
+
.linearRampToValueAtTime(basePitch, modDecay);
|
|
562
|
+
}
|
|
563
|
+
setFilterNode(channel, note) {
|
|
564
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
526
565
|
const softPedalFactor = 1 -
|
|
527
566
|
(0.1 + (noteNumber / 127) * 0.2) * channel.softPedal;
|
|
528
567
|
const maxFreq = this.audioContext.sampleRate / 2;
|
|
@@ -531,13 +570,13 @@ export class MidyGM1 {
|
|
|
531
570
|
const peekFreq = this.centToHz(instrumentKey.initialFilterFc + instrumentKey.modEnvToFilterFc) * softPedalFactor;
|
|
532
571
|
const sustainFreq = (baseFreq +
|
|
533
572
|
(peekFreq - baseFreq) * (1 - instrumentKey.modSustain)) * softPedalFactor;
|
|
573
|
+
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
574
|
+
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
575
|
+
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
534
576
|
const modDelay = startTime + instrumentKey.modDelay;
|
|
535
577
|
const modAttack = modDelay + instrumentKey.modAttack;
|
|
536
578
|
const modHold = modAttack + instrumentKey.modHold;
|
|
537
579
|
const modDecay = modHold + instrumentKey.modDecay;
|
|
538
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
539
|
-
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
540
|
-
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
541
580
|
note.filterNode = new BiquadFilterNode(this.audioContext, {
|
|
542
581
|
type: "lowpass",
|
|
543
582
|
Q: instrumentKey.initialFilterQ / 10, // dB
|
|
@@ -548,35 +587,49 @@ export class MidyGM1 {
|
|
|
548
587
|
.exponentialRampToValueAtTime(adjustedPeekFreq, modAttack)
|
|
549
588
|
.setValueAtTime(adjustedPeekFreq, modHold)
|
|
550
589
|
.linearRampToValueAtTime(adjustedSustainFreq, modDecay);
|
|
551
|
-
note.bufferSource.detune.setValueAtTime(note.bufferSource.detune.value + instrumentKey.modEnvToPitch, modDelay);
|
|
552
590
|
}
|
|
553
|
-
startModulation(channel, note,
|
|
591
|
+
startModulation(channel, note, startTime) {
|
|
554
592
|
const { instrumentKey } = note;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
});
|
|
558
|
-
note.modLFO = new OscillatorNode(this.audioContext, {
|
|
593
|
+
const { modLfoToPitch, modLfoToVolume } = instrumentKey;
|
|
594
|
+
note.modulationLFO = new OscillatorNode(this.audioContext, {
|
|
559
595
|
frequency: this.centToHz(instrumentKey.freqModLFO),
|
|
560
596
|
});
|
|
561
|
-
note.
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
597
|
+
note.filterDepth = new GainNode(this.audioContext, {
|
|
598
|
+
gain: instrumentKey.modLfoToFilterFc,
|
|
599
|
+
});
|
|
600
|
+
const modulationDepth = Math.abs(modLfoToPitch) + channel.modulationDepth;
|
|
601
|
+
const modulationDepthSign = (0 < modLfoToPitch) ? 1 : -1;
|
|
602
|
+
note.modulationDepth = new GainNode(this.audioContext, {
|
|
603
|
+
gain: modulationDepth * modulationDepthSign,
|
|
604
|
+
});
|
|
605
|
+
const volumeDepth = this.cbToRatio(Math.abs(modLfoToVolume)) - 1;
|
|
606
|
+
const volumeDepthSign = (0 < modLfoToVolume) ? 1 : -1;
|
|
607
|
+
note.volumeDepth = new GainNode(this.audioContext, {
|
|
608
|
+
gain: volumeDepth * volumeDepthSign,
|
|
609
|
+
});
|
|
610
|
+
note.modulationLFO.start(startTime + instrumentKey.delayModLFO);
|
|
611
|
+
note.modulationLFO.connect(note.filterDepth);
|
|
612
|
+
note.filterDepth.connect(note.filterNode.frequency);
|
|
613
|
+
note.modulationLFO.connect(note.modulationDepth);
|
|
614
|
+
note.modulationDepth.connect(note.bufferSource.detune);
|
|
615
|
+
note.modulationLFO.connect(note.volumeDepth);
|
|
616
|
+
note.volumeDepth.connect(note.volumeNode.gain);
|
|
566
617
|
}
|
|
567
618
|
async createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3) {
|
|
568
619
|
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
569
620
|
const note = new Note(noteNumber, velocity, startTime, instrumentKey);
|
|
570
621
|
note.bufferSource = await this.createNoteBufferNode(instrumentKey, isSF3);
|
|
571
|
-
|
|
622
|
+
this.setFilterNode(channel, note);
|
|
572
623
|
this.setVolumeEnvelope(note);
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
624
|
+
if (0 < channel.modulationDepth) {
|
|
625
|
+
this.setPitch(note, semitoneOffset);
|
|
626
|
+
this.startModulation(channel, note, startTime);
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
577
630
|
}
|
|
578
631
|
note.bufferSource.connect(note.filterNode);
|
|
579
|
-
note.filterNode.connect(note.
|
|
632
|
+
note.filterNode.connect(note.volumeNode);
|
|
580
633
|
note.bufferSource.start(startTime, instrumentKey.start / instrumentKey.sampleRate);
|
|
581
634
|
return note;
|
|
582
635
|
}
|
|
@@ -592,8 +645,8 @@ export class MidyGM1 {
|
|
|
592
645
|
if (!instrumentKey)
|
|
593
646
|
return;
|
|
594
647
|
const note = await this.createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3);
|
|
595
|
-
note.
|
|
596
|
-
note.
|
|
648
|
+
note.volumeNode.connect(channel.gainL);
|
|
649
|
+
note.volumeNode.connect(channel.gainR);
|
|
597
650
|
const scheduledNotes = channel.scheduledNotes;
|
|
598
651
|
if (scheduledNotes.has(noteNumber)) {
|
|
599
652
|
scheduledNotes.get(noteNumber).push(note);
|
|
@@ -622,17 +675,14 @@ export class MidyGM1 {
|
|
|
622
675
|
const velocityRate = (velocity + 127) / 127;
|
|
623
676
|
const volEndTime = stopTime +
|
|
624
677
|
note.instrumentKey.volRelease * velocityRate;
|
|
625
|
-
note.
|
|
678
|
+
note.volumeNode.gain
|
|
626
679
|
.cancelScheduledValues(stopTime)
|
|
627
680
|
.linearRampToValueAtTime(0, volEndTime);
|
|
628
|
-
const
|
|
629
|
-
const baseFreq = this.centToHz(note.instrumentKey.initialFilterFc);
|
|
630
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
631
|
-
const modEndTime = stopTime +
|
|
681
|
+
const modRelease = stopTime +
|
|
632
682
|
note.instrumentKey.modRelease * velocityRate;
|
|
633
683
|
note.filterNode.frequency
|
|
634
684
|
.cancelScheduledValues(stopTime)
|
|
635
|
-
.linearRampToValueAtTime(
|
|
685
|
+
.linearRampToValueAtTime(0, modRelease);
|
|
636
686
|
note.ending = true;
|
|
637
687
|
this.scheduleTask(() => {
|
|
638
688
|
note.bufferSource.loop = false;
|
|
@@ -641,15 +691,17 @@ export class MidyGM1 {
|
|
|
641
691
|
note.bufferSource.onended = () => {
|
|
642
692
|
scheduledNotes[i] = null;
|
|
643
693
|
note.bufferSource.disconnect();
|
|
694
|
+
note.volumeNode.disconnect();
|
|
644
695
|
note.filterNode.disconnect();
|
|
645
|
-
note.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
696
|
+
if (note.volumeDepth)
|
|
697
|
+
note.volumeDepth.disconnect();
|
|
698
|
+
if (note.modulationDepth)
|
|
699
|
+
note.modulationDepth.disconnect();
|
|
700
|
+
if (note.modulationLFO)
|
|
701
|
+
note.modulationLFO.stop();
|
|
650
702
|
resolve();
|
|
651
703
|
};
|
|
652
|
-
bufferSource.stop(volEndTime);
|
|
704
|
+
note.bufferSource.stop(volEndTime);
|
|
653
705
|
});
|
|
654
706
|
}
|
|
655
707
|
}
|
|
@@ -662,10 +714,10 @@ export class MidyGM1 {
|
|
|
662
714
|
const channel = this.channels[channelNumber];
|
|
663
715
|
const promises = [];
|
|
664
716
|
channel.sustainPedal = false;
|
|
665
|
-
channel.scheduledNotes.forEach((
|
|
666
|
-
|
|
667
|
-
if (
|
|
668
|
-
const { noteNumber } =
|
|
717
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
718
|
+
noteList.forEach((note) => {
|
|
719
|
+
if (note) {
|
|
720
|
+
const { noteNumber } = note;
|
|
669
721
|
const promise = this.releaseNote(channelNumber, noteNumber, velocity);
|
|
670
722
|
promises.push(promise);
|
|
671
723
|
}
|
|
@@ -710,7 +762,7 @@ export class MidyGM1 {
|
|
|
710
762
|
handleControlChange(channelNumber, controller, value) {
|
|
711
763
|
switch (controller) {
|
|
712
764
|
case 1:
|
|
713
|
-
return this.
|
|
765
|
+
return this.setModulationDepth(channelNumber, value);
|
|
714
766
|
case 6:
|
|
715
767
|
return this.dataEntryMSB(channelNumber, value);
|
|
716
768
|
case 7:
|
|
@@ -741,18 +793,19 @@ export class MidyGM1 {
|
|
|
741
793
|
const now = this.audioContext.currentTime;
|
|
742
794
|
const activeNotes = this.getActiveNotes(channel, now);
|
|
743
795
|
activeNotes.forEach((activeNote) => {
|
|
744
|
-
if (activeNote.
|
|
745
|
-
|
|
746
|
-
gainNode.gain.setValueAtTime(this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation), now);
|
|
796
|
+
if (activeNote.modulationDepth) {
|
|
797
|
+
activeNote.modulationDepth.gain.setValueAtTime(channel.modulationDepth, now);
|
|
747
798
|
}
|
|
748
799
|
else {
|
|
800
|
+
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
801
|
+
this.setPitch(activeNote, semitoneOffset);
|
|
749
802
|
this.startModulation(channel, activeNote, now);
|
|
750
803
|
}
|
|
751
804
|
});
|
|
752
805
|
}
|
|
753
|
-
|
|
806
|
+
setModulationDepth(channelNumber, modulation) {
|
|
754
807
|
const channel = this.channels[channelNumber];
|
|
755
|
-
channel.
|
|
808
|
+
channel.modulationDepth = (modulation / 127) * channel.modulationDepthRange;
|
|
756
809
|
this.updateModulation(channel);
|
|
757
810
|
}
|
|
758
811
|
setVolume(channelNumber, volume) {
|
|
@@ -904,37 +957,13 @@ export class MidyGM1 {
|
|
|
904
957
|
this.updateDetune(channel, detuneChange);
|
|
905
958
|
}
|
|
906
959
|
allSoundOff(channelNumber) {
|
|
907
|
-
|
|
908
|
-
const channel = this.channels[channelNumber];
|
|
909
|
-
const velocity = 0;
|
|
910
|
-
const stopPedal = true;
|
|
911
|
-
const promises = [];
|
|
912
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
913
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
914
|
-
if (activeNote) {
|
|
915
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, noteNumber, velocity, now, stopPedal);
|
|
916
|
-
promises.push(notePromise);
|
|
917
|
-
}
|
|
918
|
-
});
|
|
919
|
-
return promises;
|
|
960
|
+
return this.stopChannelNotes(channelNumber, 0, true);
|
|
920
961
|
}
|
|
921
962
|
resetAllControllers(channelNumber) {
|
|
922
963
|
Object.assign(this.channels[channelNumber], this.effectSettings);
|
|
923
964
|
}
|
|
924
965
|
allNotesOff(channelNumber) {
|
|
925
|
-
|
|
926
|
-
const channel = this.channels[channelNumber];
|
|
927
|
-
const velocity = 0;
|
|
928
|
-
const stopPedal = false;
|
|
929
|
-
const promises = [];
|
|
930
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
931
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
932
|
-
if (activeNote) {
|
|
933
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, activeNote.noteNumber, velocity, now, stopPedal);
|
|
934
|
-
promises.push(notePromise);
|
|
935
|
-
}
|
|
936
|
-
});
|
|
937
|
-
return promises;
|
|
966
|
+
return this.stopChannelNotes(channelNumber, 0, false);
|
|
938
967
|
}
|
|
939
968
|
handleUniversalNonRealTimeExclusiveMessage(data) {
|
|
940
969
|
switch (data[2]) {
|
|
@@ -1029,7 +1058,7 @@ Object.defineProperty(MidyGM1, "channelSettings", {
|
|
|
1029
1058
|
pitchBend: 0,
|
|
1030
1059
|
fineTuning: 0, // cb
|
|
1031
1060
|
coarseTuning: 0, // cb
|
|
1032
|
-
modulationDepthRange:
|
|
1061
|
+
modulationDepthRange: 50, // cent
|
|
1033
1062
|
}
|
|
1034
1063
|
});
|
|
1035
1064
|
Object.defineProperty(MidyGM1, "effectSettings", {
|
|
@@ -1038,7 +1067,7 @@ Object.defineProperty(MidyGM1, "effectSettings", {
|
|
|
1038
1067
|
writable: true,
|
|
1039
1068
|
value: {
|
|
1040
1069
|
expression: 1,
|
|
1041
|
-
|
|
1070
|
+
modulationDepth: 0,
|
|
1042
1071
|
sustainPedal: false,
|
|
1043
1072
|
rpnMSB: 127,
|
|
1044
1073
|
rpnLSB: 127,
|
package/esm/midy-GM2.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export class MidyGM2 {
|
|
|
6
6
|
portamentoTime: number;
|
|
7
7
|
reverbSendLevel: number;
|
|
8
8
|
chorusSendLevel: number;
|
|
9
|
+
vibratoRate: number;
|
|
10
|
+
vibratoDepth: number;
|
|
11
|
+
vibratoDelay: number;
|
|
9
12
|
bank: number;
|
|
10
13
|
bankMSB: number;
|
|
11
14
|
bankLSB: number;
|
|
@@ -19,7 +22,7 @@ export class MidyGM2 {
|
|
|
19
22
|
};
|
|
20
23
|
static effectSettings: {
|
|
21
24
|
expression: number;
|
|
22
|
-
|
|
25
|
+
modulationDepth: number;
|
|
23
26
|
sustainPedal: boolean;
|
|
24
27
|
portamento: boolean;
|
|
25
28
|
sostenutoPedal: boolean;
|
|
@@ -125,7 +128,8 @@ export class MidyGM2 {
|
|
|
125
128
|
instruments: Set<any>;
|
|
126
129
|
timeline: any[];
|
|
127
130
|
};
|
|
128
|
-
|
|
131
|
+
stopChannelNotes(channelNumber: any, velocity: any, stopPedal: any): Promise<void>;
|
|
132
|
+
stopNotes(velocity: any, stopPedal: any): Promise<any[]>;
|
|
129
133
|
start(): Promise<void>;
|
|
130
134
|
stop(): void;
|
|
131
135
|
pause(): void;
|
|
@@ -162,8 +166,10 @@ export class MidyGM2 {
|
|
|
162
166
|
calcSemitoneOffset(channel: any): any;
|
|
163
167
|
calcPlaybackRate(instrumentKey: any, noteNumber: any, semitoneOffset: any): number;
|
|
164
168
|
setVolumeEnvelope(note: any): void;
|
|
165
|
-
|
|
166
|
-
|
|
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;
|
|
167
173
|
createNote(channel: any, instrumentKey: any, noteNumber: any, velocity: any, startTime: any, isSF3: any): Promise<Note>;
|
|
168
174
|
calcBank(channel: any, channelNumber: any): any;
|
|
169
175
|
scheduleNoteOn(channelNumber: any, noteNumber: any, velocity: any, startTime: any): Promise<void>;
|
|
@@ -172,15 +178,15 @@ export class MidyGM2 {
|
|
|
172
178
|
releaseNote(channelNumber: any, noteNumber: any, velocity: any): Promise<any> | undefined;
|
|
173
179
|
releaseSustainPedal(channelNumber: any, halfVelocity: any): any[];
|
|
174
180
|
releaseSostenutoPedal(channelNumber: any, halfVelocity: any): any[];
|
|
175
|
-
handleMIDIMessage(statusByte: any, data1: any, data2: any): void |
|
|
181
|
+
handleMIDIMessage(statusByte: any, data1: any, data2: any): void | Promise<any>;
|
|
176
182
|
handleProgramChange(channelNumber: any, program: any): void;
|
|
177
183
|
handleChannelPressure(channelNumber: any, pressure: any): void;
|
|
178
184
|
handlePitchBendMessage(channelNumber: any, lsb: any, msb: any): void;
|
|
179
185
|
setPitchBend(channelNumber: any, pitchBend: any): void;
|
|
180
|
-
handleControlChange(channelNumber: any, controller: any, value: any): void |
|
|
186
|
+
handleControlChange(channelNumber: any, controller: any, value: any): void | Promise<void>;
|
|
181
187
|
setBankMSB(channelNumber: any, msb: any): void;
|
|
182
188
|
updateModulation(channel: any): void;
|
|
183
|
-
|
|
189
|
+
setModulationDepth(channelNumber: any, modulation: any): void;
|
|
184
190
|
setPortamentoTime(channelNumber: any, portamentoTime: any): void;
|
|
185
191
|
setVolume(channelNumber: any, volume: any): void;
|
|
186
192
|
panToGain(pan: any): {
|
|
@@ -213,9 +219,9 @@ export class MidyGM2 {
|
|
|
213
219
|
setCoarseTuning(channelNumber: any, coarseTuning: any): void;
|
|
214
220
|
handleModulationDepthRangeRPN(channelNumber: any): void;
|
|
215
221
|
setModulationDepthRange(channelNumber: any, modulationDepthRange: any): void;
|
|
216
|
-
allSoundOff(channelNumber: any):
|
|
222
|
+
allSoundOff(channelNumber: any): Promise<void>;
|
|
217
223
|
resetAllControllers(channelNumber: any): void;
|
|
218
|
-
allNotesOff(channelNumber: any):
|
|
224
|
+
allNotesOff(channelNumber: any): Promise<void>;
|
|
219
225
|
omniOff(): void;
|
|
220
226
|
omniOn(): void;
|
|
221
227
|
monoOn(): void;
|
|
@@ -255,12 +261,13 @@ export class MidyGM2 {
|
|
|
255
261
|
declare class Note {
|
|
256
262
|
constructor(noteNumber: any, velocity: any, startTime: any, instrumentKey: any);
|
|
257
263
|
bufferSource: any;
|
|
258
|
-
gainNode: any;
|
|
259
264
|
filterNode: any;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
volumeNode: any;
|
|
266
|
+
volumeDepth: any;
|
|
267
|
+
modulationLFO: any;
|
|
268
|
+
modulationDepth: any;
|
|
269
|
+
vibratoLFO: any;
|
|
270
|
+
vibratoDepth: any;
|
|
264
271
|
noteNumber: any;
|
|
265
272
|
velocity: any;
|
|
266
273
|
startTime: any;
|
package/esm/midy-GM2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"midy-GM2.d.ts","sourceRoot":"","sources":["../src/midy-GM2.js"],"names":[],"mappings":"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,mBAA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