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

cotone

v1.1.0

Published

MIDI tick converter module for rhythm action game development

Downloads

5

Readme

cotone.js

MIDI tick converter library for rhythm action game development.

About

Since timescale of music depends on it's tempo (BPM), music note data are usually managed by MIDI-tick unit instead of real-time in common music editing apps.

This library provides features for converting MIDI-tick <-> real-time, and also utils for drawing notes in rhythm action game app (which has note-speed changing feature by tempo).

Sample app

See following codesandbox project https://codesandbox.io/s/cotone-sample-938j8

Usage

Install

npm install cotone

Basic example

First, let's create an instance of key class, Converter.

import { Converter } from 'cotone'

const converter = new Converter()

Optional
The converting result depends on how you define the tick-unit value for quarter notes (This value is usually called "timebase", "ticks-per-quarter-note", "TPQN", etc.). Default is set to 480, but you can customize it with setTimebase

converter.setTimebase(480)

Then, set the tempo using setTempo.

// BPM: 128
converter.setTempo(128)

Now we're ready for conversion.
Assume we have a note data like below.

const noteTicks = [
  480, 960, 1920,
  // ... and so on
]

If you want real-time scale of these notes to schedule-play sounds, you can do like this.

const sound = new Audio('path/to/mysound.wav')
const noteRealSeconds = noteTicks.map(tick => converter.convertTickToSec(tick))

noteRealSeconds.forEach(noteSec => {
  setTimeout(() => {
    sound.play()
  }, noteSec * 1000)
})

Misc

Traditional browser style
<script src="path/to/cotone.js"></script>
<script type="text/javascript">
  const converter = new cotone.Converter()
  // Same as above...
</script>

Advanced

TODO

Documentation

TODO

Development

Build

You should run npm install once to prepare building condition.

Dev

npm run dev

Production

npm run build

Test

npm run test