@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-GMLite.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,31 @@ 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", {
|
|
18
24
|
enumerable: true,
|
|
19
25
|
configurable: true,
|
|
20
26
|
writable: true,
|
|
21
27
|
value: void 0
|
|
22
28
|
});
|
|
23
|
-
Object.defineProperty(this, "
|
|
29
|
+
Object.defineProperty(this, "modulationLFO", {
|
|
24
30
|
enumerable: true,
|
|
25
31
|
configurable: true,
|
|
26
32
|
writable: true,
|
|
27
33
|
value: void 0
|
|
28
34
|
});
|
|
29
|
-
Object.defineProperty(this, "
|
|
35
|
+
Object.defineProperty(this, "modulationDepth", {
|
|
30
36
|
enumerable: true,
|
|
31
37
|
configurable: true,
|
|
32
38
|
writable: true,
|
|
@@ -313,7 +319,7 @@ export class MidyGMLite {
|
|
|
313
319
|
const t = this.audioContext.currentTime + offset;
|
|
314
320
|
queueIndex = await this.scheduleTimelineEvents(t, offset, queueIndex);
|
|
315
321
|
if (this.isPausing) {
|
|
316
|
-
await this.stopNotes();
|
|
322
|
+
await this.stopNotes(0, true);
|
|
317
323
|
this.notePromises = [];
|
|
318
324
|
resolve();
|
|
319
325
|
this.isPausing = false;
|
|
@@ -321,7 +327,7 @@ export class MidyGMLite {
|
|
|
321
327
|
return;
|
|
322
328
|
}
|
|
323
329
|
else if (this.isStopping) {
|
|
324
|
-
await this.stopNotes();
|
|
330
|
+
await this.stopNotes(0, true);
|
|
325
331
|
this.notePromises = [];
|
|
326
332
|
resolve();
|
|
327
333
|
this.isStopping = false;
|
|
@@ -329,7 +335,7 @@ export class MidyGMLite {
|
|
|
329
335
|
return;
|
|
330
336
|
}
|
|
331
337
|
else if (this.isSeeking) {
|
|
332
|
-
this.stopNotes();
|
|
338
|
+
this.stopNotes(0, true);
|
|
333
339
|
this.startTime = this.audioContext.currentTime;
|
|
334
340
|
queueIndex = this.getQueueIndex(this.resumeTime);
|
|
335
341
|
offset = this.resumeTime - this.startTime;
|
|
@@ -410,21 +416,24 @@ export class MidyGMLite {
|
|
|
410
416
|
}
|
|
411
417
|
return { instruments, timeline };
|
|
412
418
|
}
|
|
413
|
-
|
|
419
|
+
async stopChannelNotes(channelNumber, velocity, stopPedal) {
|
|
414
420
|
const now = this.audioContext.currentTime;
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.notePromises.push(promise);
|
|
423
|
-
}
|
|
424
|
-
});
|
|
421
|
+
const channel = this.channels[channelNumber];
|
|
422
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
423
|
+
noteList.forEach((note) => {
|
|
424
|
+
if (note) {
|
|
425
|
+
const promise = this.scheduleNoteRelease(channelNumber, note.noteNumber, velocity, now, stopPedal);
|
|
426
|
+
this.notePromises.push(promise);
|
|
427
|
+
}
|
|
425
428
|
});
|
|
426
|
-
channel.scheduledNotes.clear();
|
|
427
429
|
});
|
|
430
|
+
channel.scheduledNotes.clear();
|
|
431
|
+
await Promise.all(this.notePromises);
|
|
432
|
+
}
|
|
433
|
+
stopNotes(velocity, stopPedal) {
|
|
434
|
+
for (let i = 0; i < this.channels.length; i++) {
|
|
435
|
+
this.stopChannelNotes(i, velocity, stopPedal);
|
|
436
|
+
}
|
|
428
437
|
return Promise.all(this.notePromises);
|
|
429
438
|
}
|
|
430
439
|
async start() {
|
|
@@ -507,36 +516,54 @@ export class MidyGMLite {
|
|
|
507
516
|
}
|
|
508
517
|
setVolumeEnvelope(note) {
|
|
509
518
|
const { instrumentKey, startTime } = note;
|
|
510
|
-
note.
|
|
519
|
+
note.volumeNode = new GainNode(this.audioContext, { gain: 0 });
|
|
511
520
|
const attackVolume = this.cbToRatio(-instrumentKey.initialAttenuation);
|
|
512
521
|
const sustainVolume = attackVolume * (1 - instrumentKey.volSustain);
|
|
513
522
|
const volDelay = startTime + instrumentKey.volDelay;
|
|
514
523
|
const volAttack = volDelay + instrumentKey.volAttack;
|
|
515
524
|
const volHold = volAttack + instrumentKey.volHold;
|
|
516
525
|
const volDecay = volHold + instrumentKey.volDecay;
|
|
517
|
-
note.
|
|
526
|
+
note.volumeNode.gain
|
|
518
527
|
.setValueAtTime(1e-6, volDelay) // exponentialRampToValueAtTime() requires a non-zero value
|
|
519
528
|
.exponentialRampToValueAtTime(attackVolume, volAttack)
|
|
520
529
|
.setValueAtTime(attackVolume, volHold)
|
|
521
530
|
.linearRampToValueAtTime(sustainVolume, volDecay);
|
|
522
531
|
}
|
|
523
|
-
|
|
524
|
-
const { instrumentKey,
|
|
532
|
+
setPitch(note, semitoneOffset) {
|
|
533
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
534
|
+
const modEnvToPitch = instrumentKey.modEnvToPitch / 100;
|
|
535
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
536
|
+
if (modEnvToPitch === 0)
|
|
537
|
+
return;
|
|
538
|
+
const basePitch = note.bufferSource.playbackRate.value;
|
|
539
|
+
const peekPitch = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset + modEnvToPitch);
|
|
540
|
+
const modDelay = startTime + instrumentKey.modDelay;
|
|
541
|
+
const modAttack = modDelay + instrumentKey.modAttack;
|
|
542
|
+
const modHold = modAttack + instrumentKey.modHold;
|
|
543
|
+
const modDecay = modHold + instrumentKey.modDecay;
|
|
544
|
+
note.bufferSource.playbackRate.value
|
|
545
|
+
.setValueAtTime(basePitch, modDelay)
|
|
546
|
+
.exponentialRampToValueAtTime(peekPitch, modAttack)
|
|
547
|
+
.setValueAtTime(peekPitch, modHold)
|
|
548
|
+
.linearRampToValueAtTime(basePitch, modDecay);
|
|
549
|
+
}
|
|
550
|
+
setFilterNode(channel, note) {
|
|
551
|
+
const { instrumentKey, noteNumber, startTime } = note;
|
|
525
552
|
const softPedalFactor = 1 -
|
|
526
553
|
(0.1 + (noteNumber / 127) * 0.2) * channel.softPedal;
|
|
527
554
|
const maxFreq = this.audioContext.sampleRate / 2;
|
|
528
555
|
const baseFreq = this.centToHz(instrumentKey.initialFilterFc) *
|
|
529
556
|
softPedalFactor;
|
|
530
557
|
const peekFreq = this.centToHz(instrumentKey.initialFilterFc + instrumentKey.modEnvToFilterFc) * softPedalFactor;
|
|
531
|
-
const sustainFreq =
|
|
532
|
-
(peekFreq - baseFreq) * (1 - instrumentKey.modSustain)
|
|
558
|
+
const sustainFreq = baseFreq +
|
|
559
|
+
(peekFreq - baseFreq) * (1 - instrumentKey.modSustain);
|
|
560
|
+
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
561
|
+
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
562
|
+
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
533
563
|
const modDelay = startTime + instrumentKey.modDelay;
|
|
534
564
|
const modAttack = modDelay + instrumentKey.modAttack;
|
|
535
565
|
const modHold = modAttack + instrumentKey.modHold;
|
|
536
566
|
const modDecay = modHold + instrumentKey.modDecay;
|
|
537
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
538
|
-
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
539
|
-
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
540
567
|
note.filterNode = new BiquadFilterNode(this.audioContext, {
|
|
541
568
|
type: "lowpass",
|
|
542
569
|
Q: instrumentKey.initialFilterQ / 10, // dB
|
|
@@ -547,35 +574,49 @@ export class MidyGMLite {
|
|
|
547
574
|
.exponentialRampToValueAtTime(adjustedPeekFreq, modAttack)
|
|
548
575
|
.setValueAtTime(adjustedPeekFreq, modHold)
|
|
549
576
|
.linearRampToValueAtTime(adjustedSustainFreq, modDecay);
|
|
550
|
-
note.bufferSource.detune.setValueAtTime(note.bufferSource.detune.value + instrumentKey.modEnvToPitch, modDelay);
|
|
551
577
|
}
|
|
552
|
-
startModulation(channel, note,
|
|
578
|
+
startModulation(channel, note, startTime) {
|
|
553
579
|
const { instrumentKey } = note;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
});
|
|
557
|
-
note.modLFO = new OscillatorNode(this.audioContext, {
|
|
580
|
+
const { modLfoToPitch, modLfoToVolume } = instrumentKey;
|
|
581
|
+
note.modulationLFO = new OscillatorNode(this.audioContext, {
|
|
558
582
|
frequency: this.centToHz(instrumentKey.freqModLFO),
|
|
559
583
|
});
|
|
560
|
-
note.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
584
|
+
note.filterDepth = new GainNode(this.audioContext, {
|
|
585
|
+
gain: instrumentKey.modLfoToFilterFc,
|
|
586
|
+
});
|
|
587
|
+
const modulationDepth = Math.abs(modLfoToPitch) + channel.modulationDepth;
|
|
588
|
+
const modulationDepthSign = (0 < modLfoToPitch) ? 1 : -1;
|
|
589
|
+
note.modulationDepth = new GainNode(this.audioContext, {
|
|
590
|
+
gain: modulationDepth * modulationDepthSign,
|
|
591
|
+
});
|
|
592
|
+
const volumeDepth = this.cbToRatio(Math.abs(modLfoToVolume)) - 1;
|
|
593
|
+
const volumeDepthSign = (0 < modLfoToVolume) ? 1 : -1;
|
|
594
|
+
note.volumeDepth = new GainNode(this.audioContext, {
|
|
595
|
+
gain: volumeDepth * volumeDepthSign,
|
|
596
|
+
});
|
|
597
|
+
note.modulationLFO.start(startTime + instrumentKey.delayModLFO);
|
|
598
|
+
note.modulationLFO.connect(note.filterDepth);
|
|
599
|
+
note.filterDepth.connect(note.filterNode.frequency);
|
|
600
|
+
note.modulationLFO.connect(note.modulationDepth);
|
|
601
|
+
note.modulationDepth.connect(note.bufferSource.detune);
|
|
602
|
+
note.modulationLFO.connect(note.volumeDepth);
|
|
603
|
+
note.volumeDepth.connect(note.volumeNode.gain);
|
|
565
604
|
}
|
|
566
605
|
async createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3) {
|
|
567
606
|
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
568
607
|
const note = new Note(noteNumber, velocity, startTime, instrumentKey);
|
|
569
608
|
note.bufferSource = await this.createNoteBufferNode(instrumentKey, isSF3);
|
|
570
|
-
|
|
609
|
+
this.setFilterNode(channel, note);
|
|
571
610
|
this.setVolumeEnvelope(note);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
611
|
+
if (0 < channel.modulationDepth) {
|
|
612
|
+
this.setPitch(note, semitoneOffset);
|
|
613
|
+
this.startModulation(channel, note, startTime);
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
note.bufferSource.playbackRate.value = this.calcPlaybackRate(instrumentKey, noteNumber, semitoneOffset);
|
|
576
617
|
}
|
|
577
618
|
note.bufferSource.connect(note.filterNode);
|
|
578
|
-
note.filterNode.connect(note.
|
|
619
|
+
note.filterNode.connect(note.volumeNode);
|
|
579
620
|
note.bufferSource.start(startTime, instrumentKey.start / instrumentKey.sampleRate);
|
|
580
621
|
return note;
|
|
581
622
|
}
|
|
@@ -591,8 +632,8 @@ export class MidyGMLite {
|
|
|
591
632
|
if (!instrumentKey)
|
|
592
633
|
return;
|
|
593
634
|
const note = await this.createNote(channel, instrumentKey, noteNumber, velocity, startTime, isSF3);
|
|
594
|
-
note.
|
|
595
|
-
note.
|
|
635
|
+
note.volumeNode.connect(channel.gainL);
|
|
636
|
+
note.volumeNode.connect(channel.gainR);
|
|
596
637
|
const scheduledNotes = channel.scheduledNotes;
|
|
597
638
|
if (scheduledNotes.has(noteNumber)) {
|
|
598
639
|
scheduledNotes.get(noteNumber).push(note);
|
|
@@ -621,17 +662,14 @@ export class MidyGMLite {
|
|
|
621
662
|
const velocityRate = (velocity + 127) / 127;
|
|
622
663
|
const volEndTime = stopTime +
|
|
623
664
|
note.instrumentKey.volRelease * velocityRate;
|
|
624
|
-
note.
|
|
665
|
+
note.volumeNode.gain
|
|
625
666
|
.cancelScheduledValues(stopTime)
|
|
626
667
|
.linearRampToValueAtTime(0, volEndTime);
|
|
627
|
-
const
|
|
628
|
-
const baseFreq = this.centToHz(note.instrumentKey.initialFilterFc);
|
|
629
|
-
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
630
|
-
const modEndTime = stopTime +
|
|
668
|
+
const modRelease = stopTime +
|
|
631
669
|
note.instrumentKey.modRelease * velocityRate;
|
|
632
670
|
note.filterNode.frequency
|
|
633
671
|
.cancelScheduledValues(stopTime)
|
|
634
|
-
.linearRampToValueAtTime(
|
|
672
|
+
.linearRampToValueAtTime(0, modRelease);
|
|
635
673
|
note.ending = true;
|
|
636
674
|
this.scheduleTask(() => {
|
|
637
675
|
note.bufferSource.loop = false;
|
|
@@ -640,15 +678,17 @@ export class MidyGMLite {
|
|
|
640
678
|
note.bufferSource.onended = () => {
|
|
641
679
|
scheduledNotes[i] = null;
|
|
642
680
|
note.bufferSource.disconnect();
|
|
681
|
+
note.volumeNode.disconnect();
|
|
643
682
|
note.filterNode.disconnect();
|
|
644
|
-
note.
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
683
|
+
if (note.volumeDepth)
|
|
684
|
+
note.volumeDepth.disconnect();
|
|
685
|
+
if (note.modulationDepth)
|
|
686
|
+
note.modulationDepth.disconnect();
|
|
687
|
+
if (note.modulationLFO)
|
|
688
|
+
note.modulationLFO.stop();
|
|
649
689
|
resolve();
|
|
650
690
|
};
|
|
651
|
-
bufferSource.stop(volEndTime);
|
|
691
|
+
note.bufferSource.stop(volEndTime);
|
|
652
692
|
});
|
|
653
693
|
}
|
|
654
694
|
}
|
|
@@ -661,10 +701,10 @@ export class MidyGMLite {
|
|
|
661
701
|
const channel = this.channels[channelNumber];
|
|
662
702
|
const promises = [];
|
|
663
703
|
channel.sustainPedal = false;
|
|
664
|
-
channel.scheduledNotes.forEach((
|
|
665
|
-
|
|
666
|
-
if (
|
|
667
|
-
const { noteNumber } =
|
|
704
|
+
channel.scheduledNotes.forEach((noteList) => {
|
|
705
|
+
noteList.forEach((note) => {
|
|
706
|
+
if (note) {
|
|
707
|
+
const { noteNumber } = note;
|
|
668
708
|
const promise = this.releaseNote(channelNumber, noteNumber, velocity);
|
|
669
709
|
promises.push(promise);
|
|
670
710
|
}
|
|
@@ -709,7 +749,7 @@ export class MidyGMLite {
|
|
|
709
749
|
handleControlChange(channelNumber, controller, value) {
|
|
710
750
|
switch (controller) {
|
|
711
751
|
case 1:
|
|
712
|
-
return this.
|
|
752
|
+
return this.setModulationDepth(channelNumber, value);
|
|
713
753
|
case 6:
|
|
714
754
|
return this.dataEntryMSB(channelNumber, value);
|
|
715
755
|
case 7:
|
|
@@ -740,18 +780,19 @@ export class MidyGMLite {
|
|
|
740
780
|
const now = this.audioContext.currentTime;
|
|
741
781
|
const activeNotes = this.getActiveNotes(channel, now);
|
|
742
782
|
activeNotes.forEach((activeNote) => {
|
|
743
|
-
if (activeNote.
|
|
744
|
-
|
|
745
|
-
gainNode.gain.setValueAtTime(this.cbToRatio(instrumentKey.modLfoToVolume + channel.modulation), now);
|
|
783
|
+
if (activeNote.modulationDepth) {
|
|
784
|
+
activeNote.modulationDepth.gain.setValueAtTime(channel.modulationDepth, now);
|
|
746
785
|
}
|
|
747
786
|
else {
|
|
787
|
+
const semitoneOffset = this.calcSemitoneOffset(channel);
|
|
788
|
+
this.setPitch(activeNote, semitoneOffset);
|
|
748
789
|
this.startModulation(channel, activeNote, now);
|
|
749
790
|
}
|
|
750
791
|
});
|
|
751
792
|
}
|
|
752
|
-
|
|
793
|
+
setModulationDepth(channelNumber, modulation) {
|
|
753
794
|
const channel = this.channels[channelNumber];
|
|
754
|
-
channel.
|
|
795
|
+
channel.modulationDepth = (modulation / 127) * channel.modulationDepthRange;
|
|
755
796
|
this.updateModulation(channel);
|
|
756
797
|
}
|
|
757
798
|
setVolume(channelNumber, volume) {
|
|
@@ -845,37 +886,13 @@ export class MidyGMLite {
|
|
|
845
886
|
this.updateDetune(channel, detuneChange);
|
|
846
887
|
}
|
|
847
888
|
allSoundOff(channelNumber) {
|
|
848
|
-
|
|
849
|
-
const channel = this.channels[channelNumber];
|
|
850
|
-
const velocity = 0;
|
|
851
|
-
const stopPedal = true;
|
|
852
|
-
const promises = [];
|
|
853
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
854
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
855
|
-
if (activeNote) {
|
|
856
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, noteNumber, velocity, now, stopPedal);
|
|
857
|
-
promises.push(notePromise);
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
return promises;
|
|
889
|
+
return this.stopChannelNotes(channelNumber, 0, true);
|
|
861
890
|
}
|
|
862
891
|
resetAllControllers(channelNumber) {
|
|
863
892
|
Object.assign(this.channels[channelNumber], this.effectSettings);
|
|
864
893
|
}
|
|
865
894
|
allNotesOff(channelNumber) {
|
|
866
|
-
|
|
867
|
-
const channel = this.channels[channelNumber];
|
|
868
|
-
const velocity = 0;
|
|
869
|
-
const stopPedal = false;
|
|
870
|
-
const promises = [];
|
|
871
|
-
channel.scheduledNotes.forEach((noteList) => {
|
|
872
|
-
const activeNote = this.getActiveNote(noteList, now);
|
|
873
|
-
if (activeNote) {
|
|
874
|
-
const notePromise = this.scheduleNoteRelease(channelNumber, activeNote.noteNumber, velocity, now, stopPedal);
|
|
875
|
-
promises.push(notePromise);
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
return promises;
|
|
895
|
+
return this.stopChannelNotes(channelNumber, 0, false);
|
|
879
896
|
}
|
|
880
897
|
handleUniversalNonRealTimeExclusiveMessage(data) {
|
|
881
898
|
switch (data[2]) {
|
|
@@ -968,7 +985,7 @@ Object.defineProperty(MidyGMLite, "channelSettings", {
|
|
|
968
985
|
dataLSB: 0,
|
|
969
986
|
program: 0,
|
|
970
987
|
pitchBend: 0,
|
|
971
|
-
modulationDepthRange:
|
|
988
|
+
modulationDepthRange: 50, // cent
|
|
972
989
|
}
|
|
973
990
|
});
|
|
974
991
|
Object.defineProperty(MidyGMLite, "effectSettings", {
|
|
@@ -977,7 +994,7 @@ Object.defineProperty(MidyGMLite, "effectSettings", {
|
|
|
977
994
|
writable: true,
|
|
978
995
|
value: {
|
|
979
996
|
expression: 1,
|
|
980
|
-
|
|
997
|
+
modulationDepth: 0,
|
|
981
998
|
sustainPedal: false,
|
|
982
999
|
rpnMSB: 127,
|
|
983
1000
|
rpnLSB: 127,
|
package/esm/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/esm/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":"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"}
|