If we have an audio source with nicely defined beats or impulses, we can use an AudioPeakSignal to quickly convert those impulses into a signal to modulate parameters in our space. Let's see how we can do this.
- Let's start fresh by clicking on File menu/New
For this example, we will import a soundtrack into our space but this could just as easily work with externally sampled audio sources as well. See this article for how to create external audio inputs.
- Undock the timeline panel
- Click the + button on the bottom right of the panel
- Select Import Background Music Track... from the menu that appears
- Browse for a song file, ideally one with well defined beats/impulses
After importing, the soundtrack's Sound node will be placed into an automatically created Overlay ViewPort, which will ensure playback will happen in stereo, and not spatially.
Next, let's create a sphere in the space that we'll pulse to the beat.
- Undock the toolbox panel and select entities from the top list
- Select sphere from the bottom list
- Click and drag in the space to create a small sphere
- Right-click to exit draw mode
Let's remove the physics RigidBody from the sphere so we have complete control over its positioning and size (or else physics will fight us).
- Double-click the sphere in the space
- From the property editor, right click the RigidBody item from the left list
- Select Remove Attribute from the menu that appears
Finally, let's create the AudioPeakSignal and apply it to the Sphere's radius.
- Undock the browser panel
- Click the + button at the bottom right of the panel
- In the menu that appears, under Signals, select New AudioPeakSignal
By default, the AudioPeakSignal is pre-configured to sample the audio output mix, so it will sample what we hear. Let's now apply it to the radius of the Sphere.
- Double-click the Sphere in the space
- Drag and drop the AudioPeakSignal from the browser panel onto the Radius property on the property editor panel
- Click the play button
The sphere should pulse with the beat. Let's tweak the signal a bit to better sample the audio.
- Double-click the AudioPeakSignal item from the browser
- While in play mode, try adjusting the Cutoff, Mutiplier and Drop Off Rate properties until things look correct.
The Cutoff property represents the minimum impulse from the audio signal to be considered a peak. -inf dB will be super sensitive and consider all impulses as peaks while, as you approach 0 dB, only the loudest impulses will register. The Drop Off Rate property controls how fast a peak returns to -inf dB. Finally, the Multiplier property amplifies the peak. Peak Type can be used to switch to Frequency Band mode, where the peak of a particular band of frequencies will be considered instead. When sampling frequencies, you might need to use a lower cutoff to register peaks.