@dgck81lnn/koishi-plugin-music 0.2.2 → 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 +11 -4
- 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,11 +45,18 @@ const gutterFunc = (f) => {
|
|
|
45
45
|
this.noteHz(baseFrequency * ratio, beats);
|
|
46
46
|
},
|
|
47
47
|
noteHz(frequency, beats) {
|
|
48
|
-
|
|
48
|
+
frequency = +frequency;
|
|
49
|
+
beats = +beats;
|
|
50
|
+
if (!Number.isFinite(beats))
|
|
51
|
+
return;
|
|
52
|
+
const start = time;
|
|
53
|
+
time += (60 / +bpm) * beats;
|
|
54
|
+
if (!Number.isFinite(frequency))
|
|
49
55
|
return;
|
|
50
|
-
notes.push({ start
|
|
56
|
+
notes.push({ start, end: time, frequency, gain });
|
|
51
57
|
},
|
|
52
58
|
rest(beats) {
|
|
59
|
+
beats = +beats;
|
|
53
60
|
if (!Number.isFinite(beats))
|
|
54
61
|
return;
|
|
55
62
|
time += (60 / +bpm) * beats;
|
|
@@ -134,7 +141,7 @@ function apply(ctx, config) {
|
|
|
134
141
|
const page = await ctx.puppeteer.page();
|
|
135
142
|
try {
|
|
136
143
|
const opt = {
|
|
137
|
-
noise: session.resolve(config.noise),
|
|
144
|
+
noise: session.resolve(config.noise) !== false, // workaround Schema.computed storing default (true) as null
|
|
138
145
|
};
|
|
139
146
|
ctx.logger.debug("synth options: %o", opt);
|
|
140
147
|
const base64 = (await page.evaluate(
|