Skip to content

Example for using Kali in real time that produce reasonably good audio #5

@Willena

Description

@Willena

Hi !
I am currently trying to use your project in a realtime project. Audio should be processed and pushed to speakers without the latency of processing the whole track.

I am using the scriptPrecessorNode witch is feeding the Kali instance with the buffer given by the scriptProcessor.
Actualy it is working but the sound is very bad. You can listen the audio sample to understand a bit more what it sound like.

Here the code I use :

this.kali = new Kali(2);
this.setup(audioContext.sampleRate, 0.5);
input = audioContext.createScriptProcessor(4096, 1, 1);
that = this;
input.onaudioprocess = function (audioProcessingEvent) {
      var inputBuffer = audioProcessingEvent.inputBuffer;
      var outputBuffer = audioProcessingEvent.outputBuffer;

      var inputData = inputBuffer.getChannelData(0);

      var numInputFrames = inputData.length;
      var numChannels = 1;
      var stretchFactor = 1;

      var completed = new Float32Array(numInputFrames * numChannels + 1);

      that.kali.input(dataToInput);
      that.kali.process();
      that.kali.output(complete)
      that.kali.flush();

    outputBuffer.copyToChannel(completed, 0, 0);

  };

Any ideas of what I am doing wrong ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions