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

scorejs

v0.10.0

Published

Create and manipulate musical scores with javascript

Downloads

131

Readme

ScoreJS

Build Status CodeClimate js-standard-style

Work in progress

Create and manipulate musical scores with javascript. The aim of this project is to provide a common interface and a high level toolkit that make easy build useful tools for musicians.

This library is oriented to composition, music learning, score analysis or algorithmic composition. Even you can play music with it, it's not a sequencer or DAW type software.

This code is largely based in two papers:

  • Lisp as a second language, composing programs and music: http://www.mcg.uva.nl/papers/lisp2nd/functional.pdf
  • Haskell School of Music: http://www.cs.yale.edu/homes/hudak/Papers/HSoM.pdf

## Example

// require the library
var score = require('scorejs')

// create the score
var song = score(
  ['melody', '4/4', 'c2 d2 e2 (f2 g2) | a2 b2 | c3'],
  ['harmony', '4/4', 'Cmaj7 | Dm7 G7 | Cmaj7']
)

// play the score:
// create an audio context
var ac = new AudioContext()
// require the player module
var player = require('scorejs/ext/player')
player.play(ac, player.synth, score.tempo(120, song))

// show the score in a piano roll
// given a canvas...
var ctx = canvas.getContext('2d')
// require the pianoroll module
var pianoRoll = require('scorejs/ext/pianoroll')
pianoRoll.draw(ctx, song)

Installation

Via npm package: npm i --save scorejs and require it: var score = require('scorejs')

For browsers use the file in the dist folder:

Important:

It uses Object.assign so if your environment doesn't have it you need a polyfill, for example: https://github.com/sindresorhus/object-assign

Usage

scorejs models scores as collection of notes (objects with duration and pitch properties), that can be arranged sequentially o simultaneously:

// a melody
var seq = score.seq(score.note(1, 'C'), score.note(1, 'D'), score.note(1, 'E'))
// a chord
var chord = score.sim(score.note(3, 'C'), score.note(3, 'E'), score.note(3, 'G'))

The phrase and chord functions are helpers to write the above more concisely:

var seq = score.phrase('C D E', 1)
var chord = score.chord('C E G', 3)

You can combine elements freely:

// the melody and the chord simultaneously
var song = score.sim(
  score.phrase('C D E', 1),
  score.chord('C E G', 3)
)

Finally, you can use a valid JSON data to define scores:

var song = score(
  ['phrase', 'C D E', 1],
  ['chord', 'C E G', 3]
)

Play

There's a built-in scheduler and player based on Web Audio API.

Tests and examples

Clone this repo and install dependencies: npm install

Tests are executed with npm test

Examples can be running with beefy: npm -g install beefy and then: beefy example/pianoroll-example

License

The MIT License (MIT)