Skip to content

🎥 Make videos programmatically with React

add to docs

Jonny Burger2b93d37abaec
diff --git a/packages/docs/docs/visualize-audio.md b/packages/docs/docs/visualize-audio.md
index 2edc5f7567..1587d9aa9e 100644
--- a/packages/docs/docs/visualize-audio.md
+++ b/packages/docs/docs/visualize-audio.md
@@ -11,23 +11,49 @@ This function takes in `AudioData` (preferably fetched by the [`useAudioData()`]
## Arguments
-### `options`
+Takes an object containing the following values:
-The only argument for this function is an object containing the following values:
+### `audioData`
-- `audioData`: `AudioData` - an object containing audio data. You can fetch this object using [`useAudioData()`](/docs/use-audio-data) or [`getAudioData()`](/docs/get-audio-data).
+_`AudioData`_
-- `frame`: `number` - the time of the track that you want to get the audio information for. The `frame` always refers to the position in the audio track - if you have shifted or trimmed the audio in your timeline, the frame returned by `useCurrentFrame` must also be tweaked before you pass it into this function.
+An object containing audio data. You can fetch this object using [`useAudioData()`](/docs/use-audio-data) or [`getAudioData()`](/docs/get-audio-data).
-- `fps`: `number` - the frame rate of the composition. This helps the function understand the meaning of the `frame` input.
+### `frame`
-- `numberOfSamples`: `number` - must be a power of two, such as `32`, `64`, `128`, etc. This parameter controls the length of the output array. A lower number will simplify the spectrum and is useful if you want to animate elements roughly based on the level of lows, mids and highs. A higher number will give the spectrum in more detail, which is useful for displaying a bar chart or waveform-style visualization of the audio.
+_`number`_
-- `smoothing`: `boolean` - when set to `true` the returned values will be an average of the current, previous and next frames. The result is a smoother transition for quickly changing values. Default value is `true`.
+The time of the track that you want to get the audio information for. The `frame` always refers to the position in the audio track - if you have shifted or trimmed the audio in your timeline, the frame returned by `useCurrentFrame` must also be tweaked before you pass it into this function.
+
+### `fps`
+
+_`number`_
+
+The frame rate of the composition. This helps the function understand the meaning of the `frame` input.
+
+### `numberOfSamples`
+
+`number`
+
+Must be a power of two, such as `32`, `64`, `128`, etc. This parameter controls the length of the output array. A lower number will simplify the spectrum and is useful if you want to animate elements roughly based on the level of lows, mids and highs. A higher number will give the spectrum in more detail, which is useful for displaying a bar chart or waveform-style visualization of the audio.
+
+### `smoothing`
+
+`boolean`
+
+When set to `true` the returned values will be an average of the current, previous and next frames. The result is a smoother transition for quickly changing values. Default value is `true`.
+
+### `optimizeFor?`<AvailableFrom v="4.0.83"/>
+
+_`"accuracy" | "speed"`_
+
+Default `"accuracy"`. When set to `"speed"`, a faster Fast Fourier transform is used. Read [user](https://discord.com/channels/809501355504959528/1189048518988550264/1190228606287360030) [experiences](https://discord.com/channels/809501355504959528/1155110845488046111/1155111360481480725) [here](https://github.com/remotion-dev/remotion/issues/2925).
## Return value
-`number[]` - An array of values describing the amplitude of each frequency range. Each value is between 0 and 1. The array is of length defined by the `numberOfSamples` parameter.
+`number[]`
+
+An array of values describing the amplitude of each frequency range. Each value is between 0 and 1. The array is of length defined by the `numberOfSamples` parameter.
The values on the left of the array are low frequencies (for example bass) and as we move towards the right, we go through the mid and high frequencies like drums and vocals.
diff --git a/packages/media-utils/src/fft/get-visualization.ts b/packages/media-utils/src/fft/get-visualization.ts
index 9668f3f4b4..27ef129fa7 100644
--- a/packages/media-utils/src/fft/get-visualization.ts
+++ b/packages/media-utils/src/fft/get-visualization.ts
@@ -1,7 +1,7 @@
// Adapted from node-fft project by Joshua Wong and Ben Bryan
// https://github.com/vail-systems/node-fft
-import {fftAccurate} from './fft';
+import {fftAccurate} from './fft-accurate';
import {fftFast} from './fft-fast';
import {fftMag} from './mag';
import {smoothen} from './smoothing';