Documentation/vis
namespace

vis

js/vis.js:108

Creates visualizations and manages the per-panel native audio analysis service.
For a guided introduction, see Visualization API.

propertyreadonly

AudioFormat

js/vis.js:123
AudioFormat: ?AudioFormat

Returns a fresh snapshot of the PCM format currently received by the panel's visualization engine, or null when there is no current audio stream. See AudioFormat for the returned object properties.
Channel names can be passed to visualization Channel, LeftChannel, and RightChannel properties.
Paused playback retains the last format. The property is null when the engine has no current format, including stopped playback or before the first audio chunk. Reading it does not create or start the visualization engine.

Example:

const format = vis.AudioFormat;
if (format) {
    for (const channel of format.Channels) {
        console.log(channel.Index + ": " + channel.Names.join(", "));
    }
}

Example source

property

ShaderCacheMaxBytes

js/vis.js:185
ShaderCacheMaxBytes: number = 16777216

Approximate CPU-memory limit for retained HLSL source/profile strings and compiled DXBC in the shared native LRU cache, in bytes. Default: 16777216 (16 MiB); allowed range: 0–1073741824 (1 GiB). Both the byte limit and ShaderCacheMaxEntries must be satisfied; zero in either property disables caching. Changes take effect immediately and are not persisted across restarts. Does not include GPU memory.

See also

property

ShaderCacheMaxEntries

js/vis.js:172
ShaderCacheMaxEntries: number = 128

Maximum number of HLSL-to-DXBC programs retained in the shared native LRU cache. Default: 128; allowed range: 0–4096. The limit applies across all JSplitter panels and takes effect immediately. Set to zero to disable this cache. Changing the value can evict entries, but does not interrupt shader visualizations that are already running. This setting is not persisted across foobar2000 restarts.

See also

propertyreadonly

ShaderCacheStats

js/vis.js:198
ShaderCacheStats: ShaderCacheStats

Snapshot of five statistics from the process-wide HLSL compilation cache. Each read creates a new object; the numbers are not live-updating properties. See ShaderCacheStats for its five fields. Read the limits separately via ShaderCacheMaxEntries and ShaderCacheMaxBytes. d2d.Compile and d2d.CompileAsync do not populate this cache; shader HLSL compiled by CreateAsync does.

Example:

const s = vis.ShaderCacheStats;
console.log(`${s.Entries}/${vis.ShaderCacheMaxEntries} shaders, ` +
    `${(s.Bytes / 1048576).toFixed(2)} MiB; ` +
    `${s.Hits} hits, ${s.Misses} misses, ${s.Evictions} evictions`);
property

ShaderFlags

js/vis.js:159
ShaderFlags: number = 0x8008

HLSL compiler flags used by subsequent CreateAsync calls in this panel. Default: 0x8008, combining optimization level 3 and row-major matrix packing. Accepts an unsigned 32-bit bitmask; see D2DCompileFlags. The mask is forwarded unchanged to the compiler for every HLSL stage in the call. Like ShaderTarget, it is captured at creation time and does not affect supplied DXBC or the separate defaults of d2d.Compile and d2d.CompileAsync. Target and flags are part of the native shader-cache key.

See also

property

ShaderTarget

js/vis.js:147
ShaderTarget: string = "ps_4_0"

HLSL compiler profile used by subsequent CreateAsync calls in this panel. Default: "ps_4_0". Allowed: "ps_4_0", "ps_4_1", "ps_5_0". Each call captures the profile for all its HLSL stages. Changing it does not alter pending compilations, existing visualizations or supplied DXBC. The chosen profile must be supported by the GPU. This property does not change the defaults of d2d.Compile or d2d.CompileAsync.

See also

property

UpdateIntervalMs

js/vis.js:114
UpdateIntervalMs: number = 16

Native audio analysis update interval, in milliseconds.
Default: 16. Accepts unsigned integer milliseconds from 1 to 4,294,967,295. This changes the cadence of the shared audio engine, not the panel repaint interval or shader feedback cadence.

method

Create

js/vis.js:218
Create(source_id, source_params, renderer)

Creates a visualization with a built-in renderer or JavaScript drawing callback synchronously.
source_id selects one of six native audio sources. Use a numeric source ID (0–5) or a named constant from VisSourceType after loading docs/Flags.js with include. Omitted, null or undefined source_params and renderer use the defaults. When a source snapshot is available, a callback receives (gr, x, y, width, height, data) when Draw is called; native analysis still prepares its data. See Visualization API for source settings, built-in renderer settings and callback data. Use CreateAsync for HLSL/DXBC renderers.

Example:

include('docs/Flags.js');
const waveform = vis.Create(VisSourceType.Waveform);
const envelope = vis.Create(VisSourceType.Waveform, { points: 256 }, { style: "envelope" });

Parameters

NameTypeDescription
source_idnumber

Numeric audio source ID (0-5). See VisSourceType

source_paramsoptionalObject

Initial native source analysis settings or null.

rendereroptionalObject|function

Built-in display settings or JS drawing callback.

Returns

Visualization

Example sources

method

CreateAsync

js/vis.js:254
CreateAsync(source_id, source_params, renderer)

Creates a shader visualization and returns a Promise resolving to it. Requires a VisualizationShaderRenderer; built-in settings and JavaScript drawing callbacks use Create instead.

HLSL stages are compiled off the UI thread using the current ShaderTarget and ShaderFlags and can be reused through the shared shader cache. Precompiled DXBC bypasses HLSL compilation. Configuration, compilation and creation failures reject the Promise.

Draw only after the Promise resolves, with window.DrawMode set to 1 (Direct2D). Creation does not schedule repaints. Source runtime properties remain available; shader programs and pipeline structure are fixed at creation time, while FeedbackIntervalMs remains adjustable.

Example:

include('docs/Flags.js');
window.DrawMode = 1;
let visual = null;
// 'hlsl' contains a complete source shader; see the linked examples.
vis.CreateAsync(VisSourceType.Waveform, null, { shader: hlsl })
    .then(v => { visual = v; window.Repaint(); })
    .catch(e => console.log("Visualization creation failed: " + e));

Parameters

NameTypeDescription
source_idnumber

Numeric audio source ID (0–5). See VisSourceType

source_paramsObject

Initial native source analysis settings, or null/undefined to use defaults.

rendererVisualizationShaderRenderer

Shader pipeline configuration.

Returns

Promise<Visualization>

Example sources