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

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

Closed cyder222 closed 3 years ago

cyder222 commented 3 years ago

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.

cyder777 commented 3 years ago

Why I want to use this lib

Because I wanna filter mic input using world features.

What I want to do

extracting feature from buffer of audio api

My Idea and Diffucult point

I tried to use Dio_Js with javascript buffer. but it's nothing to do. ( alway return all zero array as f0)

YuzukiTsuru commented 3 years ago

No, at this time, this library is just a very rough wrapper, and many data conversions are still under development.

Related data types and data conversion will be updated in the next version, and for now it is still in a rapid iteration state.

I will add some warning about that in the readme file.

best

cyder222 commented 3 years ago

Thank you for your reply. Ok. I understood. Could I make pull request for this lib? ( I wanna hellp you if you don't have enough time to development)

YuzukiTsuru commented 3 years ago

yes, that is great.