# wavyd

> A simple harmonic synthesis and wavetable generation toy

Latest version **1.0.10** (published 2015-03-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install wavyd
pnpm add wavyd
yarn add wavyd
bun add wavyd
```

Provides the command `wavyd`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2015-03-29 |
| First published | 2015-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | David Harvey |
| Maintainers | davidharvey |
| Keywords | ['sound', 'synthesis', 'harmonic', 'wavetable'] |

## Links

- npm: https://www.npmjs.com/package/wavyd
- Repository: https://github.com/davethehat/wavyd
- Issues: https://github.com/davethehat/wavyd/issues
- npm.io page: https://npm.io/package/wavyd

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^3.5.0
- [speaker](https://npm.io/package/speaker.md) ^0.2.4
- [minimist](https://npm.io/package/minimist.md) ^1.1.1

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.10 (latest) — 2015-03-29
- 1.0.9 — 2015-03-28
- 1.0.8 — 2015-03-25
- 1.0.7 — 2015-03-25
- 1.0.6 — 2015-03-25
- 1.0.5 — 2015-03-25
- 1.0.4 — 2015-03-24
- 1.0.2 — 2015-03-22
- 1.0.1 — 2015-03-21
- 1.0.0 — 2015-03-21

## README

# wavyd
Little harmonic synthesis toy and wavetable generator. Originally written to generate wavetable data for
the awesome [Open.Theremin](http://www.gaudi.ch/OpenTheremin/) 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](https://github.com.TooTallNate/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](https://www.npmjs.com/package/canvas) 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](http://theremin.tf/wp-content/uploads/2015/03/wavegen.pdf)
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:

```javascript
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...

---
_Source: https://npm.io/package/wavyd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
