New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

zusound

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zusound

Hear bugs before you see them - audio debugging for Zustand

latest
Source
npmnpm
Version
0.2.3
Version published
Weekly downloads
12
500%
Maintainers
1
Weekly downloads
 
Created
Source

🔊 zusound

Hear your state changes. Debug faster.

zusound is a Zustand middleware that converts state changes into short Web Audio cues so you can hear update patterns while debugging.

Install

npm install zusound

Supported Zustand versions: >=4 <6.

Quick Usage

import { create } from 'zustand'
import { zusound } from 'zusound'

const useStore = create(
  zusound((set) => ({
    count: 0,
    inc: () => set((state) => ({ count: state.count + 1 })),
  }))
)

API

zusound(initializer, options?)

The middleware signature matches standard Zustand middleware usage.

createZusound(options?)

Create a configured, stateful instance that works in both middleware and subscriber mode:

import { create } from 'zustand'
import { createZusound } from 'zusound'

const useStore = create((set) => ({
  count: 0,
  inc: () => set((state) => ({ count: state.count + 1 })),
}))

const zs = createZusound({ enabled: true, volume: 0.5, debounceMs: 80 })
const unsubscribe = useStore.subscribe(zs)

// later
unsubscribe()
zs.cleanup()

Use a fresh createZusound(...) instance for each store.subscribe(...) attachment when you want explicit lifecycle control.

ZusoundOptions

OptionTypeDefaultDescription
enabledbooleantrue in dev-like envs, false otherwiseEnables/disables audio feedback
volumenumber0.3Global playback volume (0..1)
debounceMsnumber0Debounce state-change sound emission
soundMappingRecord<string, Partial<SoundParams>>undefinedPath-level overrides for timbre/frequency/waveform
aestheticsPartial<AestheticParams>type-specific defaultsBase tuning for pleasantness/brightness/arousal/valence/simultaneity
mapChangeToAesthetics(change) => Partial<AestheticParams>undefinedPer-change dynamic aesthetic override hook
performanceModebooleanfalseUses static consonance ranking to reduce dissonance computation cost
onError(error, context) => voidundefinedOptional hook for non-fatal middleware/audio errors

Aesthetic Parameters

ParamRangeEffect
pleasantness0..1Consonance selection, supports fractional semitone interpolation
brightness0..1Harmonic rolloff control for timbre brightness
arousal0..1Envelope speed (attack/decay/release)
valence0..1Envelope sustain character
simultaneity0..1Dyad onset spread (1 = together, 0 = spread over ~80% duration)
baseMidinumberBase pitch center before interval mapping
durationnumberOptional note duration override (seconds)

Advanced Example

import { create } from 'zustand'
import { zusound } from 'zusound'

const useStore = create(
  zusound(
    (set) => ({
      count: 0,
      status: 'idle',
      inc: () => set((state) => ({ count: state.count + 1 })),
      setStatus: (status: string) => set({ status }),
    }),
    {
      enabled: true,
      volume: 0.28,
      debounceMs: 40,
      performanceMode: false,
      aesthetics: {
        pleasantness: 0.75,
        brightness: 0.65,
        arousal: 0.55,
        valence: 0.6,
        simultaneity: 1,
        baseMidi: 69,
      },
      mapChangeToAesthetics: (change) => {
        if (change.operation === 'add') return { pleasantness: 0.9, valence: 0.8 }
        if (change.operation === 'remove') return { pleasantness: 0.35, arousal: 0.7 }
        return {}
      },
    }
  )
)

Production Notes

  • Defaults are production-safe: audio is off in production unless enabled: true is explicitly set.
  • If the runtime environment cannot be classified, audio stays off unless enabled: true is set.
  • Browsers may keep AudioContext suspended until user interaction.
  • performanceMode is recommended for low-power or high-frequency update scenarios.
  • Use onError if you need telemetry for non-fatal audio/debugging failures.

What You'll Hear

  • Numbers: pitch-centric tones
  • Booleans: short click-like cues
  • Strings: brighter/longer character
  • Objects/arrays: more layered motion
  • Root project overview: README
  • Quick start guide: QUICK_START
  • Dev workflow: DEVELOPMENT
  • Demo usage: demo/README
  • React strict TypeScript demo: examples/README
  • Operations runbook: docs/RUNBOOK

License

MIT © joe-byounghern-kim

Keywords

zustand

FAQs

Package last updated on 07 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts