Skip to content

audioWorklet userData #18989

Description

@Jonathhhan

I wonder, if it is possible to pass a struct like this as userData:

struct AudioStruct{
  int numInputs = 0; 
  int numOutputs = 0; 
  ofBuffer inBuffer; 
  ofBuffer outBuffer; 
}
AudioStruct audioData;  //defined somewhere in the class 

        audioData.inputs = 2; 
        audioData.outputs = 0; 
	emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, (void *)&audioData);

And then read it in ProcessAudio?

EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData)
{
#ifdef REPORT_RESULT
	++audioProcessedCount;
#endif

AudioStruct * audioData = (AudioStruct *) userData; //everything you need in the struct 
audioData->outBuffer = ..... 

I copied the code examples from here: openframeworks/openFrameworks#7363

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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