@marmooo/midy 0.0.1 → 0.0.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/midy-GM1.d.ts +2 -11
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +83 -126
- package/esm/midy-GM2.d.ts +3 -7
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +91 -102
- package/esm/midy-GMLite.d.ts +2 -11
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +84 -127
- package/esm/midy.d.ts +2 -7
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +94 -102
- package/package.json +1 -1
- package/script/midy-GM1.d.ts +2 -11
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +83 -126
- package/script/midy-GM2.d.ts +3 -7
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +91 -102
- package/script/midy-GMLite.d.ts +2 -11
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +84 -127
- package/script/midy.d.ts +2 -7
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +94 -102
package/script/midy-GMLite.js
CHANGED
|
@@ -11,12 +11,6 @@ class MidyGMLite {
|
|
|
11
11
|
writable: true,
|
|
12
12
|
value: 120
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(this, "secondsPerBeat", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: 0.5
|
|
19
|
-
});
|
|
20
14
|
Object.defineProperty(this, "totalTime", {
|
|
21
15
|
enumerable: true,
|
|
22
16
|
configurable: true,
|
|
@@ -147,10 +141,10 @@ class MidyGMLite {
|
|
|
147
141
|
const response = await fetch(midiUrl);
|
|
148
142
|
const arrayBuffer = await response.arrayBuffer();
|
|
149
143
|
const midi = (0, _esm_js_1.parseMidi)(new Uint8Array(arrayBuffer));
|
|
144
|
+
this.ticksPerBeat = midi.header.ticksPerBeat;
|
|
150
145
|
const midiData = this.extractMidiData(midi);
|
|
151
146
|
this.instruments = midiData.instruments;
|
|
152
147
|
this.timeline = midiData.timeline;
|
|
153
|
-
this.ticksPerBeat = midi.header.ticksPerBeat;
|
|
154
148
|
this.totalTime = this.calcTotalTime();
|
|
155
149
|
}
|
|
156
150
|
setChannelAudioNodes(audioContext) {
|
|
@@ -229,18 +223,20 @@ class MidyGMLite {
|
|
|
229
223
|
async scheduleTimelineEvents(t, offset, queueIndex) {
|
|
230
224
|
while (queueIndex < this.timeline.length) {
|
|
231
225
|
const event = this.timeline[queueIndex];
|
|
232
|
-
|
|
233
|
-
if (time > t + this.lookAhead)
|
|
226
|
+
if (event.startTime > t + this.lookAhead)
|
|
234
227
|
break;
|
|
235
228
|
switch (event.type) {
|
|
236
229
|
case "controller":
|
|
237
230
|
this.handleControlChange(event.channel, event.controllerType, event.value);
|
|
238
231
|
break;
|
|
239
232
|
case "noteOn":
|
|
240
|
-
|
|
241
|
-
|
|
233
|
+
if (event.velocity !== 0) {
|
|
234
|
+
await this.scheduleNoteOn(event.channel, event.noteNumber, event.velocity, event.startTime + this.startDelay - offset);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
/* falls through */
|
|
242
238
|
case "noteOff": {
|
|
243
|
-
const notePromise = this.scheduleNoteRelease(event.channel, event.noteNumber, event.velocity,
|
|
239
|
+
const notePromise = this.scheduleNoteRelease(event.channel, event.noteNumber, event.velocity, event.startTime + this.startDelay - offset);
|
|
244
240
|
if (notePromise) {
|
|
245
241
|
this.notePromises.push(notePromise);
|
|
246
242
|
}
|
|
@@ -249,9 +245,6 @@ class MidyGMLite {
|
|
|
249
245
|
case "programChange":
|
|
250
246
|
this.handleProgramChange(event.channel, event.programNumber);
|
|
251
247
|
break;
|
|
252
|
-
case "setTempo":
|
|
253
|
-
this.secondsPerBeat = event.microsecondsPerBeat / 1000000;
|
|
254
|
-
break;
|
|
255
248
|
case "sysEx":
|
|
256
249
|
this.handleSysEx(event.data);
|
|
257
250
|
}
|
|
@@ -260,9 +253,8 @@ class MidyGMLite {
|
|
|
260
253
|
return queueIndex;
|
|
261
254
|
}
|
|
262
255
|
getQueueIndex(second) {
|
|
263
|
-
const ticks = this.secondToTicks(second, this.secondsPerBeat);
|
|
264
256
|
for (let i = 0; i < this.timeline.length; i++) {
|
|
265
|
-
if (
|
|
257
|
+
if (second <= this.timeline[i].startTime) {
|
|
266
258
|
return i;
|
|
267
259
|
}
|
|
268
260
|
}
|
|
@@ -370,18 +362,28 @@ class MidyGMLite {
|
|
|
370
362
|
timeline.push(event);
|
|
371
363
|
});
|
|
372
364
|
});
|
|
365
|
+
const priority = {
|
|
366
|
+
setTempo: 0,
|
|
367
|
+
controller: 1,
|
|
368
|
+
};
|
|
373
369
|
timeline.sort((a, b) => {
|
|
374
|
-
if (a.ticks !== b.ticks)
|
|
370
|
+
if (a.ticks !== b.ticks)
|
|
375
371
|
return a.ticks - b.ticks;
|
|
376
|
-
|
|
377
|
-
if (a.type !== "controller" && b.type === "controller") {
|
|
378
|
-
return -1;
|
|
379
|
-
}
|
|
380
|
-
if (a.type === "controller" && b.type !== "controller") {
|
|
381
|
-
return 1;
|
|
382
|
-
}
|
|
383
|
-
return 0;
|
|
372
|
+
return (priority[a.type] || 2) - (priority[b.type] || 2);
|
|
384
373
|
});
|
|
374
|
+
let prevTempoTime = 0;
|
|
375
|
+
let prevTempoTicks = 0;
|
|
376
|
+
let secondsPerBeat = 0.5;
|
|
377
|
+
for (let i = 0; i < timeline.length; i++) {
|
|
378
|
+
const event = timeline[i];
|
|
379
|
+
const timeFromPrevTempo = this.ticksToSecond(event.ticks - prevTempoTicks, secondsPerBeat);
|
|
380
|
+
event.startTime = prevTempoTime + timeFromPrevTempo;
|
|
381
|
+
if (event.type === "setTempo") {
|
|
382
|
+
prevTempoTime += this.ticksToSecond(event.ticks - prevTempoTicks, secondsPerBeat);
|
|
383
|
+
secondsPerBeat = event.microsecondsPerBeat / 1000000;
|
|
384
|
+
prevTempoTicks = event.ticks;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
385
387
|
return { instruments, timeline };
|
|
386
388
|
}
|
|
387
389
|
stopNotes() {
|
|
@@ -433,32 +435,12 @@ class MidyGMLite {
|
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
437
|
calcTotalTime() {
|
|
436
|
-
const endOfTracks = [];
|
|
437
|
-
let prevTicks = 0;
|
|
438
438
|
let totalTime = 0;
|
|
439
|
-
let secondsPerBeat = 0.5;
|
|
440
439
|
for (let i = 0; i < this.timeline.length; i++) {
|
|
441
440
|
const event = this.timeline[i];
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const durationTicks = event.ticks - prevTicks;
|
|
445
|
-
totalTime += this.ticksToSecond(durationTicks, secondsPerBeat);
|
|
446
|
-
secondsPerBeat = event.microsecondsPerBeat / 1000000;
|
|
447
|
-
prevTicks = event.ticks;
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case "endOfTrack":
|
|
451
|
-
endOfTracks.push(event);
|
|
452
|
-
}
|
|
441
|
+
if (totalTime < event.startTime)
|
|
442
|
+
totalTime = event.startTime;
|
|
453
443
|
}
|
|
454
|
-
let maxTicks = 0;
|
|
455
|
-
for (let i = 0; i < endOfTracks.length; i++) {
|
|
456
|
-
const event = endOfTracks[i];
|
|
457
|
-
if (maxTicks < event.ticks)
|
|
458
|
-
maxTicks = event.ticks;
|
|
459
|
-
}
|
|
460
|
-
const durationTicks = maxTicks - prevTicks;
|
|
461
|
-
totalTime += this.ticksToSecond(durationTicks, secondsPerBeat);
|
|
462
444
|
return totalTime;
|
|
463
445
|
}
|
|
464
446
|
currentTime() {
|
|
@@ -467,7 +449,7 @@ class MidyGMLite {
|
|
|
467
449
|
}
|
|
468
450
|
getActiveNotes(channel) {
|
|
469
451
|
const activeNotes = new Map();
|
|
470
|
-
channel.scheduledNotes.
|
|
452
|
+
channel.scheduledNotes.forEach((scheduledNotes) => {
|
|
471
453
|
const activeNote = this.getActiveChannelNotes(scheduledNotes);
|
|
472
454
|
if (activeNote) {
|
|
473
455
|
activeNotes.set(activeNote.noteNumber, activeNote);
|
|
@@ -486,43 +468,8 @@ class MidyGMLite {
|
|
|
486
468
|
const lfo = new OscillatorNode(audioContext, {
|
|
487
469
|
frequency: 5,
|
|
488
470
|
});
|
|
489
|
-
const lfoGain = new GainNode(audioContext);
|
|
490
|
-
lfo.connect(lfoGain);
|
|
491
471
|
return {
|
|
492
472
|
lfo,
|
|
493
|
-
lfoGain,
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
createReverbEffect(audioContext, options = {}) {
|
|
497
|
-
const { decay = 0.8, preDecay = 0, } = options;
|
|
498
|
-
const sampleRate = audioContext.sampleRate;
|
|
499
|
-
const length = sampleRate * decay;
|
|
500
|
-
const impulse = new AudioBuffer({
|
|
501
|
-
numberOfChannels: 2,
|
|
502
|
-
length,
|
|
503
|
-
sampleRate,
|
|
504
|
-
});
|
|
505
|
-
const preDecayLength = Math.min(sampleRate * preDecay, length);
|
|
506
|
-
for (let channel = 0; channel < impulse.numberOfChannels; channel++) {
|
|
507
|
-
const channelData = impulse.getChannelData(channel);
|
|
508
|
-
for (let i = 0; i < preDecayLength; i++) {
|
|
509
|
-
channelData[i] = Math.random() * 2 - 1;
|
|
510
|
-
}
|
|
511
|
-
for (let i = preDecayLength; i < length; i++) {
|
|
512
|
-
const attenuation = Math.exp(-(i - preDecayLength) / sampleRate / decay);
|
|
513
|
-
channelData[i] = (Math.random() * 2 - 1) * attenuation;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
const convolverNode = new ConvolverNode(audioContext, {
|
|
517
|
-
buffer: impulse,
|
|
518
|
-
});
|
|
519
|
-
const dryGain = new GainNode(audioContext);
|
|
520
|
-
const wetGain = new GainNode(audioContext);
|
|
521
|
-
convolverNode.connect(wetGain);
|
|
522
|
-
return {
|
|
523
|
-
convolverNode,
|
|
524
|
-
dryGain,
|
|
525
|
-
wetGain,
|
|
526
473
|
};
|
|
527
474
|
}
|
|
528
475
|
connectNoteEffects(channel, gainNode) {
|
|
@@ -546,7 +493,7 @@ class MidyGMLite {
|
|
|
546
493
|
});
|
|
547
494
|
let volume = (velocity / 127) * channel.volume * channel.expression;
|
|
548
495
|
if (volume === 0)
|
|
549
|
-
volume = 1e-6; // exponentialRampToValueAtTime()
|
|
496
|
+
volume = 1e-6; // exponentialRampToValueAtTime() requires a non-zero value
|
|
550
497
|
const attackVolume = this.cbToRatio(-noteInfo.initialAttenuation) * volume;
|
|
551
498
|
const sustainVolume = attackVolume * (1 - noteInfo.volSustain);
|
|
552
499
|
const volDelay = startTime + noteInfo.volDelay;
|
|
@@ -558,35 +505,46 @@ class MidyGMLite {
|
|
|
558
505
|
.exponentialRampToValueAtTime(attackVolume, volAttack)
|
|
559
506
|
.setValueAtTime(attackVolume, volHold)
|
|
560
507
|
.linearRampToValueAtTime(sustainVolume, volDecay);
|
|
561
|
-
if (channel.modulation > 0) {
|
|
562
|
-
const lfoGain = channel.modulationEffect.lfoGain;
|
|
563
|
-
lfoGain.connect(bufferSource.detune);
|
|
564
|
-
lfoGain.gain.cancelScheduledValues(startTime + channel.vibratoDelay);
|
|
565
|
-
lfoGain.gain.setValueAtTime(channel.modulation, startTime + channel.vibratoDelay);
|
|
566
|
-
}
|
|
567
508
|
// filter envelope
|
|
509
|
+
const maxFreq = this.audioContext.sampleRate / 2;
|
|
568
510
|
const baseFreq = this.centToHz(noteInfo.initialFilterFc);
|
|
569
511
|
const peekFreq = this.centToHz(noteInfo.initialFilterFc + noteInfo.modEnvToFilterFc);
|
|
570
512
|
const sustainFreq = baseFreq +
|
|
571
513
|
(peekFreq - baseFreq) * (1 - noteInfo.modSustain);
|
|
514
|
+
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
515
|
+
const adjustedPeekFreq = Math.min(maxFreq, peekFreq);
|
|
516
|
+
const adjustedSustainFreq = Math.min(maxFreq, sustainFreq);
|
|
572
517
|
const filterNode = new BiquadFilterNode(this.audioContext, {
|
|
573
518
|
type: "lowpass",
|
|
574
|
-
Q:
|
|
575
|
-
frequency:
|
|
519
|
+
Q: noteInfo.initialFilterQ / 10, // dB
|
|
520
|
+
frequency: adjustedBaseFreq,
|
|
576
521
|
});
|
|
577
522
|
const modDelay = startTime + noteInfo.modDelay;
|
|
578
523
|
const modAttack = modDelay + noteInfo.modAttack;
|
|
579
524
|
const modHold = modAttack + noteInfo.modHold;
|
|
580
525
|
const modDecay = modHold + noteInfo.modDecay;
|
|
581
526
|
filterNode.frequency
|
|
582
|
-
.setValueAtTime(
|
|
583
|
-
.exponentialRampToValueAtTime(
|
|
584
|
-
.setValueAtTime(
|
|
585
|
-
.linearRampToValueAtTime(
|
|
527
|
+
.setValueAtTime(adjustedBaseFreq, modDelay)
|
|
528
|
+
.exponentialRampToValueAtTime(adjustedPeekFreq, modAttack)
|
|
529
|
+
.setValueAtTime(adjustedPeekFreq, modHold)
|
|
530
|
+
.linearRampToValueAtTime(adjustedSustainFreq, modDecay);
|
|
531
|
+
let lfoGain;
|
|
532
|
+
if (channel.modulation > 0) {
|
|
533
|
+
const vibratoDelay = startTime + channel.vibratoDelay;
|
|
534
|
+
const vibratoAttack = vibratoDelay + 0.1;
|
|
535
|
+
lfoGain = new GainNode(this.audioContext, {
|
|
536
|
+
gain: 0,
|
|
537
|
+
});
|
|
538
|
+
lfoGain.gain
|
|
539
|
+
.setValueAtTime(1e-6, vibratoDelay) // exponentialRampToValueAtTime() requires a non-zero value
|
|
540
|
+
.exponentialRampToValueAtTime(channel.modulation, vibratoAttack);
|
|
541
|
+
channel.modulationEffect.lfo.connect(lfoGain);
|
|
542
|
+
lfoGain.connect(bufferSource.detune);
|
|
543
|
+
}
|
|
586
544
|
bufferSource.connect(filterNode);
|
|
587
545
|
filterNode.connect(gainNode);
|
|
588
546
|
bufferSource.start(startTime, noteInfo.start / noteInfo.sampleRate);
|
|
589
|
-
return { bufferSource, gainNode, filterNode };
|
|
547
|
+
return { bufferSource, gainNode, filterNode, lfoGain };
|
|
590
548
|
}
|
|
591
549
|
async scheduleNoteOn(channelNumber, noteNumber, velocity, startTime) {
|
|
592
550
|
const channel = this.channels[channelNumber];
|
|
@@ -599,16 +557,17 @@ class MidyGMLite {
|
|
|
599
557
|
const noteInfo = soundFont.getInstrumentKey(bankNumber, channel.program, noteNumber);
|
|
600
558
|
if (!noteInfo)
|
|
601
559
|
return;
|
|
602
|
-
const { bufferSource, gainNode, filterNode } = await this
|
|
560
|
+
const { bufferSource, gainNode, filterNode, lfoGain } = await this
|
|
603
561
|
.createNoteAudioChain(channel, noteInfo, noteNumber, velocity, startTime, isSF3);
|
|
604
562
|
this.connectNoteEffects(channel, gainNode);
|
|
605
563
|
const scheduledNotes = channel.scheduledNotes;
|
|
606
564
|
const scheduledNote = {
|
|
607
|
-
gainNode,
|
|
608
|
-
filterNode,
|
|
609
565
|
bufferSource,
|
|
610
|
-
|
|
566
|
+
filterNode,
|
|
567
|
+
gainNode,
|
|
568
|
+
lfoGain,
|
|
611
569
|
noteInfo,
|
|
570
|
+
noteNumber,
|
|
612
571
|
startTime,
|
|
613
572
|
};
|
|
614
573
|
if (scheduledNotes.has(noteNumber)) {
|
|
@@ -635,15 +594,18 @@ class MidyGMLite {
|
|
|
635
594
|
continue;
|
|
636
595
|
if (targetNote.ending)
|
|
637
596
|
continue;
|
|
638
|
-
const { bufferSource, filterNode, gainNode, noteInfo } = targetNote;
|
|
597
|
+
const { bufferSource, filterNode, gainNode, lfoGain, noteInfo } = targetNote;
|
|
639
598
|
const velocityRate = (velocity + 127) / 127;
|
|
640
599
|
const volEndTime = stopTime + noteInfo.volRelease * velocityRate;
|
|
641
600
|
gainNode.gain.cancelScheduledValues(stopTime);
|
|
642
601
|
gainNode.gain.linearRampToValueAtTime(0, volEndTime);
|
|
602
|
+
const maxFreq = this.audioContext.sampleRate / 2;
|
|
643
603
|
const baseFreq = this.centToHz(noteInfo.initialFilterFc);
|
|
604
|
+
const adjustedBaseFreq = Math.min(maxFreq, baseFreq);
|
|
644
605
|
const modEndTime = stopTime + noteInfo.modRelease * velocityRate;
|
|
645
|
-
filterNode.frequency
|
|
646
|
-
|
|
606
|
+
filterNode.frequency
|
|
607
|
+
.cancelScheduledValues(stopTime)
|
|
608
|
+
.linearRampToValueAtTime(adjustedBaseFreq, modEndTime);
|
|
647
609
|
targetNote.ending = true;
|
|
648
610
|
this.scheduleTask(() => {
|
|
649
611
|
bufferSource.loop = false;
|
|
@@ -654,6 +616,8 @@ class MidyGMLite {
|
|
|
654
616
|
bufferSource.disconnect(0);
|
|
655
617
|
filterNode.disconnect(0);
|
|
656
618
|
gainNode.disconnect(0);
|
|
619
|
+
if (lfoGain)
|
|
620
|
+
lfoGain.disconnect(0);
|
|
657
621
|
resolve();
|
|
658
622
|
};
|
|
659
623
|
bufferSource.stop(volEndTime);
|
|
@@ -664,25 +628,21 @@ class MidyGMLite {
|
|
|
664
628
|
const now = this.audioContext.currentTime;
|
|
665
629
|
return this.scheduleNoteRelease(channelNumber, noteNumber, velocity, now);
|
|
666
630
|
}
|
|
667
|
-
releaseSustainPedal(channelNumber) {
|
|
668
|
-
const
|
|
631
|
+
releaseSustainPedal(channelNumber, halfVelocity) {
|
|
632
|
+
const velocity = halfVelocity * 2;
|
|
669
633
|
const channel = this.channels[channelNumber];
|
|
634
|
+
const promises = [];
|
|
670
635
|
channel.sustainPedal = false;
|
|
671
636
|
channel.scheduledNotes.forEach((scheduledNotes) => {
|
|
672
637
|
scheduledNotes.forEach((scheduledNote) => {
|
|
673
638
|
if (scheduledNote) {
|
|
674
|
-
const {
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
gainNode.gain.linearRampToValueAtTime(0, volEndTime);
|
|
678
|
-
const baseFreq = this.centToHz(noteInfo.initialFilterFc);
|
|
679
|
-
const modEndTime = stopTime + noteInfo.modRelease;
|
|
680
|
-
filterNode.frequency.cancelScheduledValues(stopTime);
|
|
681
|
-
filterNode.frequency.linearRampToValueAtTime(baseFreq, modEndTime);
|
|
682
|
-
bufferSource.stop(volEndTime);
|
|
639
|
+
const { noteNumber } = scheduledNote;
|
|
640
|
+
const promise = this.releaseNote(channelNumber, noteNumber, velocity);
|
|
641
|
+
promises.push(promise);
|
|
683
642
|
}
|
|
684
643
|
});
|
|
685
644
|
});
|
|
645
|
+
return promises;
|
|
686
646
|
}
|
|
687
647
|
handleMIDIMessage(statusByte, data1, data2) {
|
|
688
648
|
const channelNumber = statusByte & 0x0F;
|
|
@@ -715,7 +675,7 @@ class MidyGMLite {
|
|
|
715
675
|
scheduledNotes.forEach((scheduledNote) => {
|
|
716
676
|
if (scheduledNote) {
|
|
717
677
|
const { initialAttenuation } = scheduledNote.noteInfo;
|
|
718
|
-
const gain = this.cbToRatio(initialAttenuation) * pressure;
|
|
678
|
+
const gain = this.cbToRatio(-initialAttenuation) * pressure;
|
|
719
679
|
scheduledNote.gainNode.gain.cancelScheduledValues(now);
|
|
720
680
|
scheduledNote.gainNode.gain.setValueAtTime(gain, now);
|
|
721
681
|
}
|
|
@@ -764,13 +724,9 @@ class MidyGMLite {
|
|
|
764
724
|
}
|
|
765
725
|
}
|
|
766
726
|
setModulation(channelNumber, modulation) {
|
|
767
|
-
const now = this.audioContext.currentTime;
|
|
768
727
|
const channel = this.channels[channelNumber];
|
|
769
|
-
channel.modulation = (modulation
|
|
770
|
-
channel.modulationDepthRange;
|
|
771
|
-
const lfoGain = channel.modulationEffect.lfoGain;
|
|
772
|
-
lfoGain.gain.cancelScheduledValues(now);
|
|
773
|
-
lfoGain.gain.setValueAtTime(channel.modulation, now);
|
|
728
|
+
channel.modulation = (modulation / 127) *
|
|
729
|
+
(channel.modulationDepthRange * 100);
|
|
774
730
|
}
|
|
775
731
|
setVolume(channelNumber, volume) {
|
|
776
732
|
const channel = this.channels[channelNumber];
|
|
@@ -796,9 +752,10 @@ class MidyGMLite {
|
|
|
796
752
|
channel.gainNode.gain.setValueAtTime(volume, now);
|
|
797
753
|
}
|
|
798
754
|
setSustainPedal(channelNumber, value) {
|
|
799
|
-
|
|
755
|
+
const isOn = value >= 64;
|
|
756
|
+
this.channels[channelNumber].sustainPedal = isOn;
|
|
800
757
|
if (!isOn) {
|
|
801
|
-
this.releaseSustainPedal(channelNumber);
|
|
758
|
+
this.releaseSustainPedal(channelNumber, value);
|
|
802
759
|
}
|
|
803
760
|
}
|
|
804
761
|
setRPNMSB(channelNumber, value) {
|
|
@@ -933,7 +890,7 @@ Object.defineProperty(MidyGMLite, "channelSettings", {
|
|
|
933
890
|
configurable: true,
|
|
934
891
|
writable: true,
|
|
935
892
|
value: {
|
|
936
|
-
volume:
|
|
893
|
+
volume: 100 / 127,
|
|
937
894
|
pan: 0,
|
|
938
895
|
vibratoRate: 5,
|
|
939
896
|
vibratoDepth: 0.5,
|
|
@@ -943,7 +900,7 @@ Object.defineProperty(MidyGMLite, "channelSettings", {
|
|
|
943
900
|
dataLSB: 0,
|
|
944
901
|
program: 0,
|
|
945
902
|
pitchBend: 0,
|
|
946
|
-
modulationDepthRange:
|
|
903
|
+
modulationDepthRange: 0.5,
|
|
947
904
|
}
|
|
948
905
|
});
|
|
949
906
|
Object.defineProperty(MidyGMLite, "effectSettings", {
|
package/script/midy.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export class Midy {
|
|
|
34
34
|
};
|
|
35
35
|
constructor(audioContext: any);
|
|
36
36
|
ticksPerBeat: number;
|
|
37
|
-
secondsPerBeat: number;
|
|
38
37
|
totalTime: number;
|
|
39
38
|
reverbFactor: number;
|
|
40
39
|
masterFineTuning: number;
|
|
@@ -65,7 +64,6 @@ export class Midy {
|
|
|
65
64
|
pannerNode: any;
|
|
66
65
|
modulationEffect: {
|
|
67
66
|
lfo: any;
|
|
68
|
-
lfoGain: any;
|
|
69
67
|
};
|
|
70
68
|
reverbEffect: {
|
|
71
69
|
convolverNode: any;
|
|
@@ -117,7 +115,6 @@ export class Midy {
|
|
|
117
115
|
pannerNode: any;
|
|
118
116
|
modulationEffect: {
|
|
119
117
|
lfo: any;
|
|
120
|
-
lfoGain: any;
|
|
121
118
|
};
|
|
122
119
|
reverbEffect: {
|
|
123
120
|
convolverNode: any;
|
|
@@ -138,7 +135,6 @@ export class Midy {
|
|
|
138
135
|
pannerNode: any;
|
|
139
136
|
modulationEffect: {
|
|
140
137
|
lfo: any;
|
|
141
|
-
lfoGain: any;
|
|
142
138
|
};
|
|
143
139
|
reverbEffect: {
|
|
144
140
|
convolverNode: any;
|
|
@@ -205,7 +201,6 @@ export class Midy {
|
|
|
205
201
|
getActiveChannelNotes(scheduledNotes: any): any;
|
|
206
202
|
createModulationEffect(audioContext: any): {
|
|
207
203
|
lfo: any;
|
|
208
|
-
lfoGain: any;
|
|
209
204
|
};
|
|
210
205
|
createReverbEffect(audioContext: any, options?: {}): {
|
|
211
206
|
convolverNode: any;
|
|
@@ -231,8 +226,8 @@ export class Midy {
|
|
|
231
226
|
noteOn(channelNumber: any, noteNumber: any, velocity: any): Promise<void>;
|
|
232
227
|
scheduleNoteRelease(channelNumber: any, noteNumber: any, velocity: any, stopTime: any, stopPedal?: boolean): Promise<any> | undefined;
|
|
233
228
|
releaseNote(channelNumber: any, noteNumber: any, velocity: any): Promise<any> | undefined;
|
|
234
|
-
releaseSustainPedal(channelNumber: any):
|
|
235
|
-
|
|
229
|
+
releaseSustainPedal(channelNumber: any, halfVelocity: any): any[];
|
|
230
|
+
releaseSostenutoPedal(channelNumber: any, halfVelocity: any): any[];
|
|
236
231
|
handleMIDIMessage(statusByte: any, data1: any, data2: any): any;
|
|
237
232
|
handlePolyphonicKeyPressure(channelNumber: any, noteNumber: any, pressure: any): void;
|
|
238
233
|
handleProgramChange(channelNumber: any, program: any): void;
|
package/script/midy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"AAMA;
|
|
1
|
+
{"version":3,"file":"midy.d.ts","sourceRoot":"","sources":["../src/midy.js"],"names":[],"mappings":"AAMA;IAwBE;;;;;;;;;;;;;;;;;;;;MAoBE;IAEF;;;;;;;;;;;MAWE;IAEF,+BAMC;IAhED,qBAAmB;IACnB,kBAAc;IACd,qBAAmB;IACnB,yBAAqB;IACrB,2BAAuB;IACvB,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;IAsChB,kBAAgC;IAChC,gBAA4C;IAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAAiD;IAInD,4BAMC;IAED,mCASC;IAED,gDAMC;IAED,sCASC;IAED;;;;;;;;;;;;;;;;;MAuBC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAWC;IAED,0DAyBC;IAED,8DAUC;IAED,qDAOC;IAED,2EA4CC;IAED,mCAOC;IAED,0BA+CC;IAED,uDAEC;IAED,wDAEC;IAED;;;MA2GC;IAED,4BAsBC;IAED,uBAKC;IAED,aAGC;IAED,cAKC;IAED,wBAIC;IAED,0BAKC;IAED,wBAOC;IAED,sBAGC;IAED,4CASC;IAED,gDAKC;IAED;;MAOC;IAED;;;;MAoCC;IAED;;;;;MA2CC;IAED,sDA2BC;IAED,2BAEC;IAED,4BAEC;IAED;;;;OAsFC;IAED,gDAQC;IAED,kGAgDC;IAED,0EAGC;IAED,sIA6CC;IAED,0FAGC;IAED,kEAeC;IAED,oEAYC;IAED,gEAqBC;IAED,sFAeC;IAED,4DAIC;IAED,+DAEC;IAED,8DAGC;IAED,0EAkEC;IAED,+CAEC;IAED,yDAIC;IAED,iEAEC;IAED,iDAIC;IAED,2CAMC;IAED,yDAIC;IAED,+CAEC;IAED,sCAKC;IAED,sDAMC;IAED,oDAEC;IAED,iDASC;IAED,iDAIC;IAED,wDAUC;IAED,uDAGC;IAED,2DAOC;IAED,6DAOC;IAED,6DASC;IAED,4CAkBC;IAED,4CAkBC;IAED,gDAEC;IAED,gDAEC;IAGD,+DAuBC;IAED,uCAoBC;IAED,8CAEC;IAED,uCAoBC;IAED,gBAEC;IAED,eAEC;IAED,eAEC;IAED,eAEC;IAED,4DAmBC;IAED,oBAQC;IAED,oBAQC;IAED,yDAgDC;IAED,yCAGC;IAED,sCAIC;IAED,6CAGC;IAED,8CAMC;IAED,+CAGC;IAED,kDAMC;IAED,wCAEC;IAED,6BASC;IAED,0DAUC;CACF"}
|