Developer API
I have done my best to document all classes, structs, enums and interfaces. I used the help of an A.I. but manually corrected those that were blatantly incorrect. I am updating ambiguous briefs as I go along.
I have not documented the editor module as it only provides some cool editor tricks that should not affect your project. For example, add a ShaderTech details panel category.
As I continue to work inside of VJ Master, class names and functions may change in the future. This can be due to bug fixes, new features or updating to new engine versions.
Audio IO Buffer
This section applies to custom shader code only: compute shaders, Custom material nodes and Niagara HLSL. The audio material expressions, the Niagara data interface and the Blueprint audio events read the buffer for you.
Overview
Each audio source (an IO) is analysed separately. The results are uploaded to the GPU as four flat arrays: frequency bands, amplitudes, pitches and beats. All active IOs share these arrays, with the values of each IO stored one after another.
The Audio IO Buffer is the index into those arrays. For every IO it stores whether the IO is active, how many values it has, and the offset at which its values start in each array.
Layout
The buffer holds one row of 12 unsigned integers per IO. The row is fixed by the IO type.
| Row | IO |
|---|---|
| 0 | Playback Waveform |
| 1 | Playback Noise |
| 2 | Playback Player |
| 3 | Playback Engine Player |
| 4 | Capture Loopback |
| 5 | Capture Microphone |
| 6 | Capture Engine Submix |
| 7 | Reserved |
| 8 – 15 | Additional capture instances created at runtime (1.6) |
The buffer always holds 16 rows, 192 values in total. In Blueprint, the X component of Get IO Id is the row.
Row Fields
| Offset | Define | Description |
|---|---|---|
| 0 | AudioIO_Items_Active | 1 while the IO is running, otherwise 0. The other fields are only valid while this is 1. |
| 1 | AudioIO_Items_Order | Activation order, starting at 1. Used internally to pack the arrays. |
| 2 | AudioIO_Items_NumChannels | Number of channels analysed. |
| 3 | AudioIO_Items_NumFrequencyBands | Number of frequency bands per channel. |
| 4 | AudioIO_Items_FrequencyBandHistorySize | Number of frames of band history kept. 1 keeps the latest frame only. |
| 5 | AudioIO_Items_FrequencyBandsStartIndex | Offset of this IO in the frequency bands array. |
| 6 | AudioIO_Items_AmpltitudeHistorySize | Number of amplitude values kept per channel. |
| 7 | AudioIO_Items_AmplitudesStartIndex | Offset of this IO in the amplitudes array. |
| 8 | AudioIO_Items_PitchHistorySize | Number of pitch values kept per channel. |
| 9 | AudioIO_Items_PitchesStartIndex | Offset of this IO in the pitches array. |
| 10 | AudioIO_Items_BeatHistorySize | Number of beat values kept per channel. |
| 11 | AudioIO_Items_BeatsStartIndex | Offset of this IO in the beats array. |
Indexing
index = row × 12 + offset
The number of frequency bands of Capture Loopback (row 4, offset 3) is at index 4 × 12 + 3 = 51.
The active flag of Capture Microphone (row 5, offset 0) is at index 5 × 12 + 0 = 60.
Reading Values
Frequency bands are stored per channel, then per history frame:
index = start + band + (bands × frame) + (history size × bands × channel)
Example: an IO with 32 bands, a history size of 1 and a start index of 32. Band 5 of the latest frame (frame 0) is at 32 + 5 = 37 for channel 0, and at 32 + 5 + (1 × 32 × 1) = 69 for channel 1.
Amplitudes, pitches and beats hold one value per channel and frame:
index = start + frame + (history size × channel)
Shader Helpers
The plugin provides accessor functions that perform these lookups and validate the IO:
#include "/ST_AudioVisualisation/Shared/Libs/AudioIOBuffersLib.ush" bool IsValid; float Value; GetFrequencyBandValue(IO, BandIndex, HistoryIndex, ChannelIndex, IsValid, Value);
Also available: GetAmplitudeValue, GetPitchValue, GetBeatValue, GetNumFrequencyBands, GetNumChannels and IsIOValid. IO is the row.
The offsets are defined in Shaders/Shared/Libs/AudioIOLib.ush and mirrored in ST_AudioIOLib.h.
