@dgck81lnn/koishi-plugin-music 0.1.1 → 0.1.2
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/browser/synth.js +3 -2
- package/package.json +1 -1
package/browser/synth.js
CHANGED
|
@@ -58,13 +58,14 @@ function encodeWav(samples) {
|
|
|
58
58
|
writeInt16(16) // sample depth
|
|
59
59
|
writeBytes("data")
|
|
60
60
|
writeInt32(samples.length * 2) // size of data chunk
|
|
61
|
-
for (let i = 0; i < samples.length; i++)
|
|
61
|
+
for (let i = 0; i < samples.length; i++)
|
|
62
|
+
writeInt16(Math.min(Math.max(samples[i] * 0x7fff, -32768), 32767))
|
|
62
63
|
|
|
63
64
|
return buffer
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
// https://gist.github.com/jonleighton/958841
|
|
67
|
-
|
|
68
|
+
function arrayBufferToBase64(arrayBuffer) {
|
|
68
69
|
var base64 = ''
|
|
69
70
|
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
|
|
70
71
|
var bytes = new Uint8Array(arrayBuffer)
|