{"name":"prefab-audio-features","title":"Audio features","kind":"prefab","status":"available","summary":"Audio-reactive features from a native AnalyserNode: rms, energy, spectral centroid + raw bins. Mic (with consent) or any AudioNode/MediaStream.","spec":"prefab-audio-features@0.1.1","version":"0.1.1","versions":["0.1.1","0.1.0"],"license":"MIT","source":"prototir","sizeKB":2,"requires":[],"permissions":["microphone"],"flags":{"wasm":false,"streamed":false},"compatibility":"Desktop and mobile browsers. The microphone needs the \"microphone\" permission in prototir.json; the player is asked first.","install":{"manifest":"{\n  \"modules\": [\n    \"prefab-audio-features@0.1.1\"\n  ],\n  \"permissions\": [\n    \"microphone\"\n  ]\n}","importFrom":"prefab-audio-features"},"example":"import { createAudioFeatures } from 'prefab-audio-features';\n\nconst af = await createAudioFeatures({\n  onFeatures({ rms, energy, centroid }) {\n    blob.scale = 1 + rms * 4;\n  }\n});","api":[{"heading":"createAudioFeatures(options)","entries":[{"signature":"source: 'microphone' | MediaStream | AudioNode","description":"What to listen to. Defaults to the microphone. Pass an AudioNode (for example from prefab-audio) to react to your own soundtrack."},{"signature":"context","description":"An AudioContext to use; must match an AudioNode source's context."},{"signature":"fftSize = 1024, smoothing = 0.8","description":"AnalyserNode settings."},{"signature":"onFeatures({ rms, energy, centroid, freq })","description":"Called every animation frame. rms is loudness, energy is overall level 0..1, centroid is brightness 0..1, freq is the raw frequency bins."}]},{"heading":"The returned object","entries":[{"signature":"features","description":"The latest values, updated every frame."},{"signature":"analyser, ctx, stream","description":"The underlying Web Audio objects."},{"signature":"destroy()","description":"Stops the loop. Stops the microphone and closes the context only if it created them; yours stay alive."}]}],"notes":[],"upstreamDocs":null,"labs":[]}