YuzukiTsuru / World.JS

World.JS is a JavaScript Wrapper for World Vocoder Powered by Emscripten
https://www.gloomyghost.com/World.JS/
MIT License
33 stars 5 forks source link

CheapTrick_JS error #3

Closed baba5246 closed 3 years ago

baba5246 commented 3 years ago

Thank you for developing the javascript version of World!! I built WorldJS.js as described in the README, and tried it on a simple web server, but the following error came up. It seems to be an error related to the detached ArrayBuffer in WorldJS.wasm. I have confirmed that the Dio_JS function, written before CheapTrick_JS, can run and output an f0 value. How can I resolve this?

Uncaught TypeError: Cannot perform %TypedArray%.prototype.set on a detached ArrayBuffer
    at Float64Array.set (<anonymous>)
    at methodCaller_emscripten$$val_$emscripten$$val_emscripten$$val$ (eval at new_ (WorldJS.js:5008), <anonymous>:6:26)
    at __emval_call_method (WorldJS.js:5513)
    at emscripten::internal::MethodCaller<emscripten::val, emscripten::val&, emscripten::val>::call(emscripten::internal::_EM_VAL*, char const*, emscripten::val&, emscripten::val&&) (static/js/lib/WorldJS.wasm:wasm-function[105]:0x325a)
    at emscripten::val emscripten::val::call<emscripten::val, emscripten::val&, emscripten::val>(char const*, emscripten::val&, emscripten::val&&) const (static/js/lib/WorldJS.wasm:wasm-function[57]:0x1556)
    at double* (anonymous namespace)::GetPtrFrom1XArray<double>(emscripten::val, int*) (static/js/lib/WorldJS.wasm:wasm-function[53]:0x13ba)
    at CheapTrick_JS(emscripten::val, emscripten::val, emscripten::val, int) (static/js/lib/WorldJS.wasm:wasm-function[59]:0x17af)
    at emscripten::internal::Invoker<emscripten::val, emscripten::val, emscripten::val, emscripten::val, int>::invoke(emscripten::val (*)(emscripten::val, emscripten::val, emscripten::val, int), emscripten::internal::_EM_VAL*, emscripten::internal::_EM_VAL*, emscripten::internal::_EM_VAL*, int) (static/js/lib/WorldJS.wasm:wasm-function[89]:0x2c67)
    at Object.CheapTrick_JS (eval at new_ (WorldJS.js:5008), <anonymous>:11:10)

The code and environment I tried to use is as follows.

<script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="static/js/lib/WorldJS.js"></script>
</head>
<body>
<script>
  const x = Module.WavRead_JS('static/js/lib/vaiueo2d.wav')
  const f0 = Module.Dio_JS(x.x, x.fs, 2.0)
  const sp = Module.CheapTrick_JS(x.x, f0.f0, f0.time_axis, x.fs)
  const ap = Module.D4C_JS(x.x, f0.f0, f0.time_axis, sp.fft_size, x.fs)
  const synthesis = Module.Synthesis_JS(f0.f0 * 2.0, sp.spectral * 1.2, ap.aperiodicity, sp.fft_size, x.fs, 2.0)
  Module.WavWrite_JS(synthesis.x, synthesis.fs, synthesis.nbit, 'static/js/lib/out.wav')
</script>
</body>
</html>
</script>
OS: Mac OS 10.13.6(17G14042)
Browser: Chrome (version: 87.0.4280.141(Official Build) (x86_64))
YuzukiTsuru commented 3 years ago

Sorry for taking so long to reply. Try to use the latest branch of World.JS, I am currently not got such an error. The latest build added more debug information.

YuzukiTsuru commented 3 years ago

Well, I know. You read the static/js/lib/vaiueo2d.wav file in the wrong place. World.JS Currently, it does not support reading files directly from the hard disk. The current method is to provide *.data file to import the wav file.

The File System is based on Emscripten, not basic JavaScript

visit Emscripten home for more detials: https://emscripten.org/docs/porting/files/index.html

image