Skip to content

Commit f6e80cd

Browse files
authored
Merge pull request #51 from codeacme17/refactor
refactor(hook): add JS doc comment to `useOscilloscope` hook
2 parents 274e84b + b8ca602 commit f6e80cd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

packages/hooks/useOscilloscope.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ export interface UseOscilloscopeProps {
1111

1212
const FFT_SIZE = 1024
1313

14+
/**
15+
* `useOscilloscope` is a custom React hook that integrates with Tone.js to create an oscilloscope.
16+
* It is designed to capture and display real-time waveform data from an audio source.
17+
*
18+
* @param {UseOscilloscopeProps} props - The configuration properties for the oscilloscope.
19+
* @param {number} [props.fftSize=1024] - The FFT size, must be a power of 2. Default is 1024.
20+
* @param {Function} props.onReady - Callback executed when the oscilloscope is ready.
21+
* @param {Function} props.onError - Callback executed in case of an error.
22+
*
23+
* @returns {object} An object containing various properties and methods for the oscilloscope:
24+
* - init: Method to initialize the oscilloscope.
25+
* - analyser: The Tone.Analyser instance used by the oscilloscope.
26+
* - data: The current waveform data captured by the oscilloscope.
27+
* - getData: Method to retrieve the current waveform data.
28+
* - observe: Method to start the data observation.
29+
* - cancelObserve: Method to stop the data observation.
30+
* - error: Boolean indicating if an error has occurred.
31+
* - errorMessage: The error message in case of an error.
32+
*
33+
* This hook can be useful in audio analysis applications, allowing for real-time visualization of waveform data.
34+
*/
1435
export const useOscilloscope = (props: UseOscilloscopeProps = {}) => {
1536
const { fftSize = FFT_SIZE, onReady, onError } = props
1637

0 commit comments

Comments
 (0)