Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/src/components/visualizaion/EchoOsci.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const EchoOsci = () => {
}, [])

useEffect(() => {
if (!audioBuffer || !analyser) return
initPlayer(audioBuffer, [analyser])
if (!audioBuffer || !analyser.current) return
initPlayer(audioBuffer, [analyser.current])
}, [audioBuffer, analyser])

const handleTrigger = () => {
Expand Down
15 changes: 10 additions & 5 deletions example/src/components/visualizaion/EchoSpectrogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ export const EchoSpectrogram = () => {
}, [])

React.useEffect(() => {
if (!analyser || !filterLow.current || !filterMid.current || !filterHigh.current) return
initPlayer(audioBuffer!, [filterLow.current, filterMid.current, filterHigh.current, analyser])
if (!analyser.current || !filterLow.current || !filterMid.current || !filterHigh.current) return
initPlayer(audioBuffer!, [
filterLow.current,
filterMid.current,
filterHigh.current,
analyser.current,
])
}, [audioBuffer, analyser, filterLow.current, filterMid.current, filterHigh.current])

React.useEffect(() => {
Expand Down Expand Up @@ -101,9 +106,9 @@ export const SpectrogramDefault = () => {
}, [])

React.useEffect(() => {
if (!audioBuffer || !analyser) return
initPlayer(audioBuffer!, [analyser])
}, [audioBuffer, analyser])
if (!audioBuffer || !analyser.current) return
initPlayer(audioBuffer!, [analyser.current])
}, [audioBuffer, analyser.current])

const handleTrigger = async () => {
if (isPlaying) stop()
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/visualizaion/EchoWaveform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const EchoWaveform = () => {
{tab === 'a' ? (
<Waveform
data={data}
audioDuration={audioDuration}
audioDuration={audioDuration.current}
percentage={percentage}
onClick={handleClick}
waveHeight={100}
Expand Down
12 changes: 6 additions & 6 deletions example/src/components/visualizaion/VuMeter/EchoMono.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ export const VuMeterMono = () => {
}, [])

useEffect(() => {
if (!audioBuffer || !meter) return
initPlayer(audioBuffer, [meter])
}, [audioBuffer, meter])
if (!audioBuffer || !meter.current) return
initPlayer(audioBuffer, [meter.current])
}, [audioBuffer, meter.current])

const handlePlay = () => {
if (!player) return
if (!player.current) return
observe()
}

const handleStop = () => {
if (!player) return
if (!player.current) return
cancelObserve()
}

const handleTriggerPlay = () => {
if (!player) return
if (!player.current) return
if (isPlaying) pause()
else play()
}
Expand Down
6 changes: 3 additions & 3 deletions example/src/components/visualizaion/VuMeter/EchoStereo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const VueMeterStereo = () => {
}, [])

React.useEffect(() => {
if (!audioBuffer || !meter) return
initPlayer(audioBuffer, [meter])
}, [audioBuffer, meter])
if (!audioBuffer || !meter.current) return
initPlayer(audioBuffer, [meter.current])
}, [audioBuffer, meter.current])

const handleClick = () => {
if (isPlaying) pause()
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/useOscilloscope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const FFT_SIZE = 1024
export const useOscilloscope = (props: UseOscilloscopeProps = {}) => {
const { fftSize = FFT_SIZE, onReady, onError } = props

const analyser = useRef<Tone.Analyser>()
const observerId = useRef<number>(0)
const analyser = useRef<Tone.Analyser>()
const [data, setData] = useState<OscilloscopeDataPoint[]>([])
const [error, setError] = useState<boolean>(false)
const [errorMessage, setErrorMessage] = useState<string>('')
Expand Down Expand Up @@ -95,7 +95,7 @@ export const useOscilloscope = (props: UseOscilloscopeProps = {}) => {

return {
init,
analyser: analyser.current,
analyser,
data,
getData,
observer,
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/usePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ export const usePlayer = (props: UsePlayerProps = {}) => {
}

return {
player: player.current,
audioDuration: audioDuration.current,
player,
audioDuration,
isReady,
isPlaying,
isFinish,
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/useSpectrogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const useSpectrogram = (props: UseSpectrogramProps = {}) => {
}, [error])

return {
analyser: analyser.current,
analyser,
data,
init,
getData,
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/useVuMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const useVuMeter = (props: UseVuMeterProps) => {
}, [_value])

return {
meter: isStereo ? split.current! : meter.current!,
meter: isStereo ? split : meter,
value,
init,
getValue,
Expand Down