# react-mic-waver

> React Wave generator for browser mic

Latest version **1.0.0** (published 2022-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-mic-waver
pnpm add react-mic-waver
yarn add react-mic-waver
bun add react-mic-waver
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-07-21 |
| First published | 2022-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 42.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pedro Aritz Rasines Relloso |
| Maintainers | aritzmetal |
| Keywords | typescript, react, npm, package, mic, wave |

## Links

- npm: https://www.npmjs.com/package/react-mic-waver
- Repository: https://github.com/aritzmetal/react-mic-waver
- Issues: https://github.com/aritzmetal/react-mic-waver/issues
- npm.io page: https://npm.io/package/react-mic-waver

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-07-21
- 0.1.3 — 2022-07-20
- 0.1.2 — 2022-04-03
- 0.1.1 — 2022-04-02
- 0.1.0 — 2022-04-02

## README

## About

It detects the user voice and renders a oscillating wave.
It provides the wave component and also a simple MediaStream context for simple usage.

### Instalation

`npm`

```sh
  npm install --save react-mic-waver
```

`yarn`

```sh
  yarn add react-mic-waver
```

### Example

The `MediaStreamProvider` and also the `useMediaStream` hook come with the `AudioVisualiser` default export as a little controller that works out of the box if you don't need a complex custom implementation of the stream context. The stream generated is passed as a parameter to the `AudioVisualiser` component to generate the analyzer over it and render the wave.

#### Wrapper Element 
```tsx
...
import { 
  MediaStreamProvider, 
  } from "react-mic-waver"
...

  <MediaStreamProvider video={false} audio={true}>
        <Component />
  </MediaStreamProvider>
...
```

#### Component 

```tsx
...
import AudioVisualiser, { useMediaStream } from "react-mic-waver";
...

export const Component = () => {

  ...
  const { stream, start, stop } = useMediaStream();

  const toggleMic = () => stream ? stop() : start()

  ...

  return (
    ...
      <div style={{width: "300px", height: "200px", background: "#fff"}}>
       <button className="App-btn" onClick={toggleMic}>
          {stream ? 'Close Microphone' : "Open Microphone"}
        </button>
        <AudioVisualiser stream={stream} onRender={() => console.log("Render!")} style={{background: "red"}}/>
      </div>
    ...
  );
};

```

### Props

|   Props   |     Type      | Default |                  Description                   |
|:---------:|:-------------:|:-------:|:----------------------------------------------:|
|  stream   |  MediaStream  |    -    |               stream to analyze                |
|   color   |    string     | "black" |           color of the rendered wave           |
|   width   | number/string | "auto"  |            width of the wave canvas            |
|  height   | number/string | "auto"  |           height of the wave canvas            |
| lineWidth |    number     |    2    |           width of the rendered wave           |
| onRender  |  () => void   |    -    |   callback that fires when wave is rendered    |
|   style   | CSSProperties |    -    | extra styles applied to the canvas of the wave |

---
_Source: https://npm.io/package/react-mic-waver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
