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

tune

v0.2.1

Published

Tune up baudio

Downloads

142

Readme

tune

Tune up baudio.

tune

install

Install tune and baudio: npm install tune baudio

You also need to install SoX: http://sox.sourceforge.net/

examples

Just a single note

var baudio = require('baudio'), tune = require('tune');

var a = tune('A');

var b = baudio(function(t) { return a(t); });
b.play();

Hungarian Dance no5

var baudio = require('baudio'), tune = require('tune');

var hungarian = tune(String(
  'A5 . . . . D5 . F5 . . . . D5 . C#5 . . . . D5 E5 D5 . . . . ' +
  'Bb5 . . . . C5 . D5 . A5 . . . . G4 F4 E4 . . A5 D4 . . .'
).split(' '), {tempo: 8});

var b = baudio(function(t) { return hungarian(t); });
b.play();

Soundgarden - Black Hole Sun

var baudio = require('baudio'), tune = require('tune');

var blackholesun = tune(String(
  'A4 E4 A5 D5 A5 E4 A4 C4 E4 A5 D5 . . . ' +
  'G3 D4 G4 D5 G4 D4 E3 F#3 C#4 F#4 C#5 . . . ' +
  'E3 F3 C4 F4 A#5 F4 C4 F3 E3 D4 E4 B5 . . .'
).split(' '));

var b = baudio(function(t) {
  // black hole sun + some fx
  return blackholesun(t) + Math.sin(2 * Math.PI * t);
});
b.play();

Final Fantasy Arpeggios

var baudio = require('baudio'), tune = require('tune');

var ff = [];
[
  'C D E G',
  'A B C E',
  'C D E G',
  'A B C E',
  'A C F G',
  'A B D G',
  'Ab C Eb G',
  'A Bb D F',
].forEach(function(chord) {
  chord = chord.split(' ');
  var oct = 3, arp = [];
  for (var i = 0; i < (chord.length - 1) * 4; i++) {
    if (i % 4 === 0) oct++;
    arp.push(chord[i % 4] + oct);
  }
  ff = ff.concat(arp.concat(arp.slice(0, -1).reverse()));
});
ff = tune(ff);

var b = baudio(function(t) { return ff(t); });
b.play();

methods

var tune = require('tune');

var t = tune(notes)

Returns a function: function(time[, options]) that will return a value based on time between -1 and 1 to formulate a wave. Then you return the value within your baudio function.

notes can be a single note string: 'A#5' or an array of notes: ['C4', 'D5', 'E4', 'Gb7']. Mark notes with sharps # and flats b. Then ending number refers to the octave. In a sequence if the octave isn't specified, it will use the last set octave or 4. Use . for muted notes.

options are an object literal {}:

  • tempo [4] - how fast to transition through the notes
  • volume [1.0] - volume to play the tune: 0.0 - 1.0

Release History

  • 0.2.1 - Readme update.
  • 0.2.0 - tune just returns a function now.
  • 0.1.2 - Add mute notes.
  • 0.1.1 - Better API interface. Add volume option.
  • 0.1.0 - initial release

License

Copyright (c) 2014 Kyle Robinson Young
Licensed under the MIT license.