@dgck81lnn/koishi-plugin-music 0.2.3 → 0.2.4
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/lib/index.js +5 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.Config = koishi_1.Schema.object({
|
|
|
18
18
|
])
|
|
19
19
|
.default("process.stdout")
|
|
20
20
|
.description("在 js 代码执行指令中返回结果的方式。"),
|
|
21
|
-
noise: koishi_1.Schema.computed(
|
|
21
|
+
noise: koishi_1.Schema.computed(koishi_1.Schema.boolean())
|
|
22
22
|
.default(true)
|
|
23
23
|
.description("是否添加白噪音来尝试规避 QQ 的语音编码杂音问题。"),
|
|
24
24
|
});
|
|
@@ -45,6 +45,8 @@ const gutterFunc = (f) => {
|
|
|
45
45
|
this.noteHz(baseFrequency * ratio, beats);
|
|
46
46
|
},
|
|
47
47
|
noteHz(frequency, beats) {
|
|
48
|
+
frequency = +frequency;
|
|
49
|
+
beats = +beats;
|
|
48
50
|
if (!Number.isFinite(beats))
|
|
49
51
|
return;
|
|
50
52
|
const start = time;
|
|
@@ -54,6 +56,7 @@ const gutterFunc = (f) => {
|
|
|
54
56
|
notes.push({ start, end: time, frequency, gain });
|
|
55
57
|
},
|
|
56
58
|
rest(beats) {
|
|
59
|
+
beats = +beats;
|
|
57
60
|
if (!Number.isFinite(beats))
|
|
58
61
|
return;
|
|
59
62
|
time += (60 / +bpm) * beats;
|
|
@@ -138,7 +141,7 @@ function apply(ctx, config) {
|
|
|
138
141
|
const page = await ctx.puppeteer.page();
|
|
139
142
|
try {
|
|
140
143
|
const opt = {
|
|
141
|
-
noise: session.resolve(config.noise),
|
|
144
|
+
noise: session.resolve(config.noise) !== false, // workaround Schema.computed storing default (true) as null
|
|
142
145
|
};
|
|
143
146
|
ctx.logger.debug("synth options: %o", opt);
|
|
144
147
|
const base64 = (await page.evaluate(
|