Skip to Content
npm i @clxrity/react-audio

Oscillator

The <Oscillator /> component generates audio signals at specified frequencies and waveforms.


"use client"; import { Oscillator } from "@clxrityy/react-audio"; import { useState } from "react"; export default function Example() { const [isPlaying, setIsPlaying] = useState<boolean>(false); return ( <Oscillator frequency={440} type="sine" isPlaying={isPlaying} onPlayChange={setIsPlaying} /> ); }


Props



PropertyTypeDescriptionRequiredDefault Value
typeOscillatorTypeThe type of oscillator wave (e.g., sine, square, sawtooth, triangle).❌sine
frequencynumberThe frequency of the oscillator in Hz.❌440
gainnumberThe default gain (volume) of the oscillator.❌0.5
onPlayChange(playing: boolean) => voidCallback function to handle play/pause changes.❌undefined
isPlayingbooleanWhether the oscillator is currently playing sound.❌false
onFrequencyChange(frequency: number) => voidCallback function to handle frequency changes.❌undefined
onGainChange(gain: number) => voidCallback function to handle gain changes.❌undefined
Last updated on

Oscillator