Skip to main content
cngx-src documentation

CngxAudioPitch

DirectivePrimaryv0.1.0WCAG AA

projects/common/audio/pitch-mode/audio-pitch.directive.ts

Import#

import { CngxAudioPitch } from '@cngx/common/audio'

Description#

Pitch-mode audio binder. Sonifies a continuous numeric value: each change of [cngxAudioPitch] clamps against a fixed domain, linear-scales into an output frequency range, and plays a short tone. Useful for sliders, gauges, and live metrics — the ear tracks a value without looking.

<input type="range" min="0" max="100"
  [cngxAudioPitch]="volume()"
  [pitchDomain]="[0, 100]"
  [pitchRange]="[220, 880]" />

The inputs are discrete rather than an options record so [cngxAudioPitch] stays a native reactive input — passing [cngxAudioPitch]="volume()" binds a signal value directly, never a Signal smuggled inside a config object. The domain is caller-supplied and fixed; it is never accumulated from observed values, so the directive holds no hidden state. Value-to-frequency is a pure derivation; rapid sweeps are throttled through the shared createDebouncer.

https://cngxjs.github.io/cngx/examples/#/common/audio/pitch/slider

Metadata#

Index#

Inputs#

audioDisabled#
input()

Suppress this element's audio without unbinding.

default false, { transform: booleanAttribute }
audioVolume#number | undefined
input()

Per-element volume multiplier in [0, 1]; unset uses the tone default.

pitchDomain#[number, number]
input()Required

Fixed input domain [min, max] the value is clamped against.

pitchDurationMs#number
input()

Tone duration in ms. Default 120.

default 120
pitchRange#[number, number]
input()

Output frequency range [lo, hi] in Hz. Default [220, 880].

default [220, 880]
pitchThrottleMs#number
input()

Minimum ms between tones during a sweep. Default 50.

default 50
value#number
input()Required

The tracked value to sonify.

default { alias: 'cngxAudioPitch' }