Skip to content

danigb/in-seconds

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

in-seconds

time calculator for music applications

Build Status Coverage

Work in progress. It uses the awesome nearley to parse the strings:

var inSeconds = require('in-seconds')
inSeconds('100Hz') // => 0.01
inSeconds('120bpm') // => 0.5

// if Hz can be expressed in seconds, notes too
inSeconds('C4') // => 0.00382225643297143
inSeconds('60midi') // => 0.00382225643297143

// note durations
inSeconds('8n', { bpm: 120 }) // => 0.25 (a quarter note at 120bpm )
inSeconds('4t', { bpm: 100 }) // a quarter triplet note at 100bpm

// offsets
inSeconds('+8n', { bpm: 120, now: 1.21 }) // => 1.46 (an eight note after now)

// quantization
inSeconds('@8n' { bpm: 120, now: 1.21 }) // => the next quarter note after 1.21 (at 120 bpm)

// arithmetic fun!
inSeconds('4n + 8n', { bpm: 120 }) // => 0.75 (a quarter note + a eight not at 120 bpm)
inSeconds('100Hz + 1') // => 1.01
inSeconds('2 * C3') // => 0.00382225643297143 (same as C4)

See tests for more.

Install

No release yet.

Develop

Clone this repo, install dependencies with npm: npm install and then run the tests: npm test

License

MIT

About

time calculator for music applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published