Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add style prop to LiveAudioVisualizer component #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const Visualizer = () => {
| **`maxDecibels`** | A double, representing the maximum decibel value for scaling the FFT analysis data. For more [details](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/maxDecibels) | `-10` | Yes |
| **`minDecibels`** | A double, representing the minimum decibel value for scaling the FFT analysis data, where 0 dB is the loudest possible sound. For more [details](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/minDecibels) | `-90` | Yes |
| **`smoothingTimeConstant`** | A double within the range 0 to 1 (0 meaning no time averaging). For more [details](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/smoothingTimeConstant) | `0.4` | Yes |
| **`style`** | Custom styles that can be passed to the visualization canvas | N/A | Yes |



2 changes: 1 addition & 1 deletion src/AudioVisualizer/AudioVisualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface Props {
*/
currentTime?: number;
/**
* Custome styles that can be passed to the visualization canvas
* Custom styles that can be passed to the visualization canvas
*/
style?: React.CSSProperties;
/**
Expand Down
6 changes: 6 additions & 0 deletions src/LiveAudioVisualizer/LiveAudioVisualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export interface Props {
* Default: `0.4`
*/
smoothingTimeConstant?: number;
/**
* Custom styles that can be passed to the visualization canvas
*/
style?: React.CSSProperties;
}

const LiveAudioVisualizer: (props: Props) => ReactElement = ({
Expand All @@ -88,6 +92,7 @@ const LiveAudioVisualizer: (props: Props) => ReactElement = ({
maxDecibels = -10,
minDecibels = -90,
smoothingTimeConstant = 0.4,
style,
}: Props) => {
const [context, setContext] = useState<AudioContext>();
const [audioSource, setAudioSource] = useState<MediaStreamAudioSourceNode>();
Expand Down Expand Up @@ -177,6 +182,7 @@ const LiveAudioVisualizer: (props: Props) => ReactElement = ({
height={height}
style={{
aspectRatio: "unset",
...style,
}}
/>
);
Expand Down