JSFiddle - React, Tailwind, and code Playground

JavaScript

AudioWorkletProcessor.contextInfo; // getter

/* AudioWorkletGlobalScope */
registerAudioWorkletNode('foo', 

  // Define AWNode, the main thread representation.
  class extends AudioWorkletNode {
    get parameterDescriptors () {
      return [{
        name: 'volume',
        defaultValue: 0.0
      }];
    },
    
    constructor (options) {
      // Initialize the node with parameter descriptors, 
      // then override the initial value from |options|.
      super(options);
      this.volume.value = options.volume;
    },
    
    onmessage (time) {
      console.log('current audio time = ', time);
    },
    
    start () {
      this.postMessage({ 
      	type:'start'
      });
    }
  },
  
  // Define AWProcessor, the audio thread representation.
  class extends AudioWorkletProcessor {
  
  	// Define states for the internal audio processing.
    constructor () {
      this.started = false;
    },
    
    process (inputs, outputs, parameters) {
      this.postMessage(this.contextInfo.currentTime);
    },
    
    onmessage (data) {
      switch (data.type) {
        case 'start':
          this.started = true;
          break;
        default:
          break;
      }
    }
  }
);