ParaAudioWaveGenerator

Description

This component converts the waveform data of the currently playing audio into texture data in real time and transports it to the material property of the MeshRender associated with the component. Then the visual effects will match the rhythm of the music. This component periodically captures audio data at runtime and assigns values to material properties for each frame. You can define these parameters in your scene shader and apply dynamic visual effects as needed.

if(render != null)
{
  var pb = new MaterialPropertyBlock();
  if (render.HasPropertyBlock())
  {
    render.GetPropertyBlock(pb);
  }

  pb.SetFloat("_Audio1", outputSpectrum[0]);
  pb.SetFloat("_Audio2", outputWave[0]);
  pb.SetTexture("_AudioTex1", GetWaveTex());
  pb.SetTexture("_AudioTex2", GetSpectrumTex());
  pb.SetFloat("_Atmosphere", hue);

  render.SetPropertyBlock(pb);
}

Property

Component property nameProperty description
ParaAudioWaveGenerator.audioSourceThe source of the audio data that the component needs to capture.
ParaAudioWaveGenerator.wavequalityThe quality of the captured audio sound wave data, which corresponds to the length of the output texture. We recommend that you set it to a power of 2 (128, 256, 512).
ParaAudioWaveGenerator.spectrumqualityThe quality of the captured audio spectrum data, which corresponds to the length of the output texture. We recommend that you set it to a power of 2 (128, 256, 512).
ParaAudioWaveGenerator.refreshintervalThe interval of audio data capture. A shorter interval means a greater impact on the efficiency. We recommend that you set it to more than 0.1 seconds.
ParaAudioWaveGenerator.lerpTimeThe interpolation time of the audio data change, that is, how long it takes for the output audio data to be interpolated from the previous captured value to the current captured value. Adjusting this value can make visual effects change more smoothly.
ParaAudioWaveGenerator.hueA float value passed to the shader of the material, which can be used to control any material effect as needed. The corresponding property name in the shader is "_Atmosphere".