vuepress-plugin-chiptune 1.0.4 → 1.0.5
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/package.json +1 -1
- package/src/Chiptune.vue +2 -1
- package/src/neoloop.js +17 -6
package/package.json
CHANGED
package/src/Chiptune.vue
CHANGED
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
</template>
|
|
75
75
|
|
|
76
76
|
<script>
|
|
77
|
-
import { init, generateLoop, modifySounds, remixLoop, togglePlayPause, downloadWav, exportMIDI, triggerRandom, stopMusic } from './neoloop.js';
|
|
77
|
+
import { init, generateLoop, modifySounds, remixLoop, togglePlayPause, downloadWav, exportMIDI, triggerRandom, stopMusic, cleanup } from './neoloop.js';
|
|
78
78
|
|
|
79
79
|
export default {
|
|
80
80
|
name: 'Chiptune',
|
|
@@ -83,6 +83,7 @@ export default {
|
|
|
83
83
|
},
|
|
84
84
|
beforeUnmount() {
|
|
85
85
|
stopMusic();
|
|
86
|
+
cleanup();
|
|
86
87
|
},
|
|
87
88
|
methods: {
|
|
88
89
|
generateLoop,
|
package/src/neoloop.js
CHANGED
|
@@ -5,6 +5,7 @@ let originalMotif = [], visualStep = 0;
|
|
|
5
5
|
let canvas, ctx2d;
|
|
6
6
|
let seedInput, scaleSelect, lengthSelect, chaos, chaosValue, bpmSlider, bpmOutput, togglePlay;
|
|
7
7
|
let useLead, useLead2, useBass, useDrums, useFx, useReverb, useDelay, useChorus;
|
|
8
|
+
let chaosInputListener, bpmInputListener;
|
|
8
9
|
|
|
9
10
|
function initDOMReferences() {
|
|
10
11
|
canvas = document.getElementById("pianoRoll");
|
|
@@ -394,7 +395,7 @@ async function renderAudio(seed, scaleMode, style, params, motif, steps) {
|
|
|
394
395
|
}
|
|
395
396
|
|
|
396
397
|
if (useDrumsChecked) {
|
|
397
|
-
const drumMultiplier = style === "crystal" || "dreamchip" ? 0.4 : 1.0;
|
|
398
|
+
const drumMultiplier = (style === "crystal" || style === "dreamchip") ? 0.4 : 1.0;
|
|
398
399
|
if (i % 8 === 0) playNoise(ctx, t, 0.05, 0.1 * drumMultiplier, master);
|
|
399
400
|
if (i % 8 === 4) playNoise(ctx, t, 0.04, 0.08 * drumMultiplier, master);
|
|
400
401
|
if (i % 2 === 0) playNoise(ctx, t, 0.03, 0.04 * drumMultiplier, master);
|
|
@@ -475,7 +476,7 @@ function playMusic() {
|
|
|
475
476
|
source._interval = interval;
|
|
476
477
|
|
|
477
478
|
isPlaying = true;
|
|
478
|
-
togglePlay.textContent = "
|
|
479
|
+
togglePlay.textContent = "暂停";
|
|
479
480
|
}
|
|
480
481
|
|
|
481
482
|
export function stopMusic() {
|
|
@@ -486,7 +487,7 @@ export function stopMusic() {
|
|
|
486
487
|
source = null;
|
|
487
488
|
context = null;
|
|
488
489
|
isPlaying = false;
|
|
489
|
-
if (togglePlay) togglePlay.textContent = "
|
|
490
|
+
if (togglePlay) togglePlay.textContent = "播放";
|
|
490
491
|
}
|
|
491
492
|
|
|
492
493
|
export function togglePlayPause() {
|
|
@@ -612,8 +613,18 @@ export function exportMIDI() {
|
|
|
612
613
|
|
|
613
614
|
export function init() {
|
|
614
615
|
if (initDOMReferences()) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
616
|
+
chaosInputListener = () => chaosValue.textContent = chaos.value;
|
|
617
|
+
bpmInputListener = () => bpmOutput.textContent = bpmSlider.value;
|
|
618
|
+
chaos.addEventListener('input', chaosInputListener);
|
|
619
|
+
bpmSlider.addEventListener('input', bpmInputListener);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export function cleanup() {
|
|
624
|
+
if (chaos && chaosInputListener) {
|
|
625
|
+
chaos.removeEventListener('input', chaosInputListener);
|
|
626
|
+
}
|
|
627
|
+
if (bpmSlider && bpmInputListener) {
|
|
628
|
+
bpmSlider.removeEventListener('input', bpmInputListener);
|
|
618
629
|
}
|
|
619
630
|
}
|