Skip to content

Commit 95c8bc7

Browse files
committed
docs: update hooks pages
1 parent c77d5a3 commit 95c8bc7

9 files changed

Lines changed: 21 additions & 21 deletions

File tree

docs/en/hook/useOscilloscope.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ A hook for creating an oscilloscope, which can obtain real-time amplitude data.
4444

4545
Calling this method initializes the `analyser`. After initialization, the `onReady` callback function will be called.
4646

47-
- **analyser** : `Tone.Analyser`
47+
- **analyser** : `React.MutableRefObject<Tone.Analyser | null>`
4848

49-
After initialization, a `waveform` type analyzer [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) instance is constructed.
49+
After initialization, a `waveform` type analyzer [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) instance is constructed. Need to use `.current` to obtain.
5050

5151
- **data** : `SpectrogramDataPoint[]`
5252

docs/en/hook/usePlayer.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ This hook enables the implementation of basic functions of a music player, inclu
8484

8585
<CodeBlock code={`init(audioBuffer, [filter, analyzer])`} />
8686

87-
- **player**: `Tone.Player`
87+
- **player**: `React.MutableRefObject<Tone.Player | null>`
8888

89-
The [Tone.Player](https://tonejs.github.io/docs/14.7.77/Player) instance created after initialization.
89+
The [Tone.Player](https://tonejs.github.io/docs/14.7.77/Player) instance created after initialization. Need to use `.current` to obtain.
9090

91-
- **audioDuration**: `number`
91+
- **audioDuration**: `React.MutableRefObject<number>`
9292

93-
The duration of the audio in seconds.
93+
The duration of the audio in seconds. Need to use `.current` to obtain.
9494

9595
- **isReady**: `boolean`
9696

docs/en/hook/useSpectrogram.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ This hook can be used to generate a spectrogram for audio.
4444

4545
Calling this method can initialize `analyser`, and the `onReady` callback function will be called after the initialization is completed.
4646

47-
- **analyser** : `Tone.Analyser`
47+
- **analyser** : `React.MutableRefObject<Tone.Analyser | null>`
4848

49-
Instance of [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) constructed after initialization
49+
Instance of [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) constructed after initialization. Need to use `.current` to obtain.
5050

5151
- **data** : `SpectrogramDataPoint[]`
5252

docs/en/hook/useVuMeter.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ A Hook for obtaining audio volume levels
4444

4545
Calling this method can initialize `meter`. After the initialization is completed, the `onReady` callback function will be called.
4646

47-
- **meter**: `Tone.Meter | Tone.Split`
47+
- **meter**: `React.MutableRefObject<Tone.Split | null> | React.MutableRefObject<Tone.Meter | null>`
4848

49-
Initially constructed [Tone.Meter](https://tonejs.github.io/docs/14.7.77/Meter)(Mono) or [Tone.Split](https://tonejs.github.io/docs/14.7.77/Split)(Stereo) instances
49+
Initially constructed [Tone.Meter](https://tonejs.github.io/docs/14.7.77/Meter)(Mono) or [Tone.Split](https://tonejs.github.io/docs/14.7.77/Split)(Stereo) instances. Need to use `.current` to obtain.
5050

5151
- **value**: `number | number[]`
5252

docs/zh/hook/useOscilloscope.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import { Github } from 'lucide-react'
4444

4545
调用该方法可以初始化 `analyser`,在初始化完成后会调用 `onReady` 回调函数
4646

47-
- **analyser** : `Tone.Analyser`
47+
- **analyser** : `React.MutableRefObject<Tone.Analyser | null>`
4848

49-
初始化后构建类型为 `waveform` 的分析器 [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) 实例
49+
初始化后构建的类型为 `waveform` 的分析器 [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) 实例,需要使用 `.current` 进行获取
5050

5151
- **data** : `SpectrogramDataPoint[]`
5252

docs/zh/hook/usePlayer.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ import { Github } from 'lucide-react'
8484

8585
<CodeBlock code={`init(audioBuffer, [filter, analyser])`} />
8686

87-
- **player**: `Tone.Player`
87+
- **player**: `React.MutableRefObject<Tone.Player | null>`
8888

89-
初始化后构建的 [Tone.Player](https://tonejs.github.io/docs/14.7.77/Player) 实例
89+
初始化后构建的 [Tone.Player](https://tonejs.github.io/docs/14.7.77/Player) 实例,需要使用 `.current` 获取
9090

91-
- **audioDuration**: `number`
91+
- **audioDuration**: `React.MutableRefObject<number>`
9292

93-
音频的时长,单位为秒
93+
音频的时长,单位为秒,需要使用 `.current` 获取
9494

9595
- **isReady**: `boolean`
9696

docs/zh/hook/useSpectrogram.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import { Github } from 'lucide-react'
4444

4545
调用该方法可以初始化 `analyser`,在初始化完成后会调用 `onReady` 回调函数
4646

47-
- **analyser** : `Tone.Analyser`
47+
- **analyser** : `React.MutableRefObject<Tone.Analyser | null>`
4848

49-
初始化后构建类型为 `fft` 的分析器 [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) 实例
49+
初始化后构建类型为 `fft` 的分析器 [Tone.Analyser](https://tonejs.github.io/docs/14.7.77/Analyser) 实例,需要使用 `.current` 获取
5050

5151
- **data** : `SpectrogramDataPoint[]`
5252

docs/zh/hook/useVuMeter.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import { Github } from 'lucide-react'
4444

4545
调用该方法可以初始化 `meter`,在初始化完成后会调用 `onReady` 回调函数
4646

47-
- **meter**: `Tone.Meter | Tone.Split`
47+
- **meter**: `React.MutableRefObject<Tone.Split | null> | React.MutableRefObject<Tone.Meter | null>`
4848

49-
初始化后构建的 [Tone.Meter](https://tonejs.github.io/docs/14.7.77/Meter)(单声道时) 或 [Tone.Split](https://tonejs.github.io/docs/14.7.77/Split)(双声道时) 实例
49+
初始化后构建的 [Tone.Meter](https://tonejs.github.io/docs/14.7.77/Meter)(单声道时) 或 [Tone.Split](https://tonejs.github.io/docs/14.7.77/Split)(双声道时) 实例,需要使用 `.current` 进行获取
5050

5151
- **value**: `number | number[]`
5252

packages/hooks/useOscilloscope.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const useOscilloscope = (props: UseOscilloscopeProps = {}) => {
3636
const { fftSize = FFT_SIZE, onReady, onError } = props
3737

3838
const observerId = useRef<number>(0)
39-
const analyser = useRef<Tone.Analyser>()
39+
const analyser = useRef<Tone.Analyser | null>(null)
4040
const [data, setData] = useState<OscilloscopeDataPoint[]>([])
4141
const [error, setError] = useState<boolean>(false)
4242
const [errorMessage, setErrorMessage] = useState<string>('')

0 commit comments

Comments
 (0)