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

wavyd

v1.0.10

Published

A simple harmonic synthesis and wavetable generation toy

Downloads

1

Readme

wavyd

Little harmonic synthesis toy and wavetable generator. Originally written to generate wavetable data for the awesome Open.Theremin project, but then things got a little out of hand...

installation

npm install -g wavyd

dependencies

nodejs (tested with v0.10.n and 0.12.n)

On ubuntu, installation of the audio package requires libasound2-dev: install using

sudu apt-get install libasound2-dev

On windows, the situation is a bit more complicated. The speaker package used for audio output is built using node-gyp, which requires both python and (to compile the binary extensions to node) a MS Visual Studio C++ installation. Follow the instructions on the node-gyp github page before installing wavyd.

Otherwise, all dependencies arte defined in package.json, except for node-canvas (for png support), which requires an installation of Cairo. Check here for more information.

usage

$ wavyd <arguments>

Arguments (with defaults):

--freq    Audio frequency to play (440)
--type	  Wave type: hs (harmonic synthesis) || ew (etherwave) (hs)
--spec    Specification for wave (depends on type, see below)
--dur     Audio duration in seconds (3)
--silent  Suppress audio preview of wave
--dump    If given, write wavetable data to stdout (false)
--table   Size (#samples) of wavetable to generate (1024)
--round   If true, round samples in wavetable to integer values (false)
--scale   Scale samples in wavetable by this value (1.0)
--plot    If given, generate a graphic representation of waveform: ascii|png (false)
--pn      For png plot, output filename (plot.png)
--pw      For png plot, pixel width of image (640)
--ph      For png plot, pixel height of image (360)
--pm      For png plot, inner margin of image (4)
--preset  If given, a path to a preset/template file
--help    Show this help message (false)

Spec argument depends on the --type argument passed. For hs (harmonic synthesis) it should be a quoted list of weight:phase pairs w:p separated by spaces and/or commas, e.g.

"1:0, 0.5:0, 0.25:0.2PI"

(Note that phases are in radians relative to the current partial, and that you can use "PI" as a constant in these expressions)

For ew (etherwave) it should be a quoted string with values for wf (waveform offset) and br (brightness) as follows:

"wf:55, br:140"

Both wf and br values should be 0-255.

For information on the algorithm, see Thierry Frankel's paper on implementing the generator in native Arduino code.

To write output to a wave file, redirect stdout as follows

$ wavyd --preset ./MyCPPTemplate.js --silent > wavetable.cpp

Preset/template file

A preset/template file has the following form, which should be relatively self-explanatory:

var template = [
"/*===========================================",
"Wavetable for Open.Theremin",
"Generated at {date} by wavyd",
"Type: {type}",
"Spec: {spec}",
"============================================*/",
"",
"#include <avr/pgmspace.h>",
"",
"const int16_t wave_table[{table}] PROGMEM = {\\",
"*{value}{-,}",
"}"
];

module.exports = {
  opts: {
    dump:  true,
    table: 1024,
    round: true,
    scale: 2048
  },
  template: template
};

Note:

  1. The file is a javascript source file, exporting via module.exports a template and a set of options
  2. The options overwrite any additional or default options passed to wavyd
  3. The template is an array of strings, that will be written to the output with values substituted
  4. Any string in the template surrounded by curly braces {} will be substituted (with the braces) by the options field with that name (e.g. the number of samples in the generated wavetable will be {table})
  5. The special value {date} gives an ISO date string with the date and time of generation
  6. Any line starting with '*' will be repeated once for every sample generated in the wavetable
  7. In these lines, the only template values are {value} and {index}, the sample value and its index in the wavetable respectively
  8. Braces which include a dash followed by a literal value: the literal value will be emitted for all but the last repetition of the line (to allow for commas between array values, for example, as above)

etc

The name of the project is a gentle tip-of-the-hat to my old friends Nick and Colin, who greet me (amongst the many other names by which I'm known) as wavy Davy...