Tone.js icon indicating copy to clipboard operation
Tone.js copied to clipboard

Feature Request: Tone.Processor()

Open Hazmatron7 opened this issue 4 years ago • 1 comments

While we can use Tone.Context.addAudioWorkletModule() and Tone.Context.createAudioWorkletNode(), it would be cool to see a Tone.Processor() Node for custom processing. The idea I am suggesting is that it uses AudioWorklet as the processor and has these features:

  • set a buffer size from 128 to 16384. (Maybe use a ring buffer for this or something)
  • choose either 'buffer' or 'array' for audio data to be presented as in the processing callback
  • allowing features like making custom AudioParams and or setting numberOfInputs etc
  • works along with Tone.Transport as well as context time
  • allowing to start and stop the processor to save performance

example Idea:

let processor = new Tone.Processor({
   //context:  BaseContext,
  numberOfInputs: 1, //number
  numberOfOutputs: 1, //number
  bufferSize: 128, //PowerOfTwo
  dataType: "array" // string: "buffer" | "array" 
  //other props etc...
});

processor.onprocess = (event) => {
//event contains the info of audio data and timing etc
//process audio data here:
};

How does the idea sound? I think it would be very useful tool to have. :)

Hazmatron7 avatar Oct 27 '20 05:10 Hazmatron7

Hi team! Any plans on this?

asabadyr avatar Mar 27 '23 10:03 asabadyr