npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-pro-metronome

v1.1.0

Published

react-pro-metronome React component

Downloads

6

Readme

react-pro-metronome

Travis Coveralls Commitizen friendly npm package npm downloads Prettier License

React component that creates a Metronome. The cool thing is that it uses a render prop, so you can decide the look of your own metronome.

Functionalities

  • The basic functionality of a metronome: set a click to a specified BPM.
  • You can set a subdivision between quarter notes and have a click on those subdivisions.
  • You can globally decide if you want sound or just a visual click.
  • If you are using sounds, you can decide the click sound level of each note (including subdivisions) between no-sound, low, medium and high.
  • Because we use a render prop, the appearance of your metronome is entirely up to you!! You can focus on making it as cool as you want, and we'll give you the metronome functionality.

Installation

npm install react-pro-metronome

Load

import ProMetronome from 'react-pro-metronome'

Usage

To create your own metronome in your app, just insert the component using its props to configure it, and define what you want to render (how you want it to look like) inside of the render prop. Here you have an easy example of a metronome with a click in 8th notes, that just renders the current quarter note and the subdivision note, and that has different click sound for quarter notes and for the subdivision...

<ProMetronome
  bpm={95}
  subdivision={2}
  soundEnabled={true}
  soundPattern="31313131"
  render={(props, state) => (
    <div>
      {state.qNote}/{state.subNote}
    </div>
  )}
/>

This will render (at 95 bpm)....

1/1... 1/2... 2/1... 2/2... 3/1... 3/2... 4/1... 4/2... 1/1

Configuration parameters

Component props

| Parameter | Description | Type | Values | Default | | :----------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------: | :--------------------------------------: | :-----: | | bpm | Set the click speed (beeps per minute). | number | 1-300 | 80 | | subdivision | Set the number of notes(clicks) you want to have from one quarter note and the next one. For example, if you want your metronome to have a click in 16th notes, you'll have to set subdivision at 4 (each quarter note has four 16th note). | number | 1-8 | 1 | | isPlaying | Play/Stop the metronome | boolean | true/false | true | | soundEnabled | Enable/disable all click sounds. | boolean | true/false | false | | soundPattern | Define the sound level for each one of the notes of a bar, including subdivisions. It's a string that has to have the length of the number of notes you have in a bar (including subdivisions) in which each character define the sound level: '0' (no sound), '1' (low sound), '2' (medium sound) and '3' (high sound). | string | String composed by: '0', '1', '2' or '3' | '' | | render | Function where you can define what you want the component to render. | function | function | - |

Render prop

| Parameter | Description | Type | Values | Default | | :-----------: | -------------------------------------------------------------------------------------------------------- | :----: | :---------------------: | :-----: | | props | Object with all the props the component is using (passed to the component or default values established) | Object | - | - | | state.qNote | Current quarter note. | number | 1-4 | - | | state.subNote | Current subdivision note. | number | 1-[props.subdivision] | - |

References

Legal

Released under MIT license.