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

nmusic

v0.6.1

Published

a JavaScript music library for easy programmatic music composition

Downloads

24

Readme

nmusic is a JavaScript music library for programmatic music composition which offers an intuitive mix of functional and object-oriented programming styles. It is thoroughly tested and well documented but currently in development.

Usage

Navigate to your project directory and install nmusic:

npm install nmusic

In your project file, import nmusic.

var nmusic = require('nmusic')

// if you'd like, create global variables for the functions you will be using
var plusInterval = nmusic.plusInterval
plusInterval('G3', 'P5')             =>  'D4'

// or, call all functions directly from nmusic
nmusic.interval('Bb3', 'Ab4')        =>  'm7'

To work in a functional style, use the many functional methods. These methods all return strings and numbers which represent pitches and intervals. (The example assumes you have assigned all methods to global variables).

interval('B3', 'F#5')           =>  'P12'
interval.simple('B3', 'F#5')    =>  'P5'
semitonesBetween('B3', 'D#4')   =>   4
plusInterval('B3', -6)          =>  'D3'
plusInterval('B3', '-m6')       =>  'D#3'

To work in an object-oriented style, create Pitch objects. The Pitch methods will return other Pitch objects, but behind the scenes they are just using the same functional methods introduced above.

var p1 = new Pitch('Bb3')
var p2 = p1.plusInterval('P5')
p2.toString()                  => 'F4'
p2 instanceof Pitch            => true
p1.interval(p2)                => 'P5'

Goals

nmusic is made of a set of sensical music classes like Note, Pitch, Duration, Measure. Most of the functionality of the library will be loaded into the factory method nmusic which will parse a variety of arguments and return objects of the appropriate class.

nmusic('Bb3')                  =>  Bb3
nmusic('Bb3') instanceof Note  =>  true
nmusic('Bb3').plus('P4')       =>  Eb4
nmusic('Bb3').interval('Eb4')  =>  P4
nmusic('Bb3').scale('major')   => [Bb3, C4, D4, Eb4, F4, G4, A4]

Docs

View the api documentation here.

Development

To run eslint and tape tests:

npm test

To generate api documentation:

npm run docs

Background & Credits

My first programming project was a simple object oriented music library which I made from scratch to solve counterpoint problems. As I've learned more, I've come back to that library and refactored it several times, and now I aim to completely rebuild it.

There are already some very good JavaScript music libraries out there which have influenced this project:

tonal is an elegant library written in a functional style.

teoria is an object oriented library.

This library aims to be an intuitive mix between a functional and object-oriented style.