Coder Social home page Coder Social logo

yuzukitsuru / world.js Goto Github PK

View Code? Open in Web Editor NEW
32.0 1.0 4.0 1.59 MB

World.JS is a JavaScript Wrapper for World Vocoder Powered by Emscripten

Home Page: https://www.gloomyghost.com/World.JS/

License: MIT License

CMake 7.43% C++ 90.08% C 1.77% HTML 0.11% JavaScript 0.62%
vocoder world javascript javascript-library emscripten audio-processing dsp wrapper morise f0-estimation

world.js's Introduction

world.js's People

Contributors

yuzukitsuru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

world.js's Issues

CheapTrick_JS error

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))

Can I use Dio_JS ( or other native method) with WebAudio API?

Thank you for you great product.

I tried to use this library with audio api.
But I'm not familiar with emscripten. so I could not do it .

Could you give me a hint?

there are my code ( Partially)

audio.js

import { default as Module } from "./WorldJS.js";
/**
   *
   * @param {Float32Array[]} input
   */
  static featureExtract(input) {

   // input is 128 * 32 float32ArrayArray
   // so I must change to Float64Array
    const buffer = new Float64Array(bufferSize * bufferingLength);
    for (const [i, f32] of input.entries()) {
      for (const [j, value] of f32.entries()) {
        buffer[i * bufferSize + j] = value;
      }
    }

    const { Dio_JS  } = Module;
    const { f0, time_axis: timeAxis } = Dio_JS(buffer, sampleRate, framePeriod);
    console.log(f0) // f0 is always zero array like  [0,0,....]

argument of featureExtract(input) come from mediaStream like mic.

I think I could not send buffer propery.
the first argument type of Dis_JS is emscripten::val
Do you know the way to use this function from javascript?

I'm looking forward your reply.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.