Home
API reference

useAudioSynth

strata-game-library/audio-synth

strata-game-library/audio-synth


strata-game-library/audio-synth / useAudioSynth

Function: useAudioSynth()

useAudioSynth(): AudioSynthContextValue

Defined in: components/AudioSynthProvider.tsx:178

Hook to access the audio synth context.

Returns

AudioSynthContextValue

AudioSynthContextValue with manager and helper functions

Throws

Error if used outside AudioSynthProvider

Example

function ShootButton() {
  const { playSFX, isReady } = useAudioSynth();

  return (
    <button
      onClick={() => playSFX('gunshot')}
      disabled={!isReady}
    >
      Shoot
    </button>
  );
}