@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.
Files changed (2) hide show
  1. package/browser/synth.js +3 -2
  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++) writeInt16(samples[i] * 0x7fff)
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
- window.arrayBufferToBase64 = function (arrayBuffer) {
68
+ function arrayBufferToBase64(arrayBuffer) {
68
69
  var base64 = ''
69
70
  var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
70
71
  var bytes = new Uint8Array(arrayBuffer)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dgck81lnn/koishi-plugin-music",
3
3
  "description": "Synthesize melodies in Koishi",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [