Wavegen

Help

Preset: FDS | N163/GB | PC-E | SCC
Length:
Depth:
Function:
Distortion: none | clip | fold | wrap | absolute
Output format: decimal | $XXh | 0xXXh | XXh | Xh | float
Separator: "" | " " | ", " | "," | "\n"
Signed output (only applies to hex output): unsigned | signed

Output:

Click to copy


Graph:

This page has been adapted from an old FC2 PPMCK page. I preserved it and roughly translated it to preserve it and open the tool up for international audiences. I also updated it along the way with some extra features (value clamping for most options is a new feature here). Special thanks to DEFENSE MECHANISM for helping prepare this page in particular. Original page by h7 (h7mailmail-at-yahoo co jp) (I am unsure if that address is still active, try your luck!)

This site is open source!

Help

This is a tool to generate waveforms for soundchips like the N163, Gameboy, PC-Engine/HuC6280, SCC (K051649/K052539), FDS and others by adusting the parameters.

Parameters

"Length" adjusts the total number of sample points present in the waveform, the default is 32. This corresponds to the horizontal axis on the graph.
"Depth" configures the amplitude of each sample in the waveform, this is analogous to the bit depth of it. The default value is 15, corresponding to a 4-bit depth, represented by the vertical axis on the graph.

For all non-floating number output options, all samples will be rounded down to the nearest step in the bitdepth (Essentially, Math.floor(x) is done for every sample so it lands on a step).
The distortion selector allows for 4 distortion options, and a toggleable "absolute" box leading to 8 unique options to choose from.

Usage

The phase of a waveform can be shifted by adding or subtracting a number to or from operator "p". (0 to 1 represents 0° to 360° - 0.25 is 90°, 0.50 is 180°, 0.75 is 270°)
The available waveforms are as follows:
sin(y*p+x) - generates a sine wave of y*p periods, whose phase is shifted by +x.
saw(y*p+x) - generates a sawtooth wave. Same parameters as sin().
tri(y*p+x,z) - generates a triangle wave. Same parameters as sin(), but with the addition of peak position "z", 0.5 represents a symmetric waveform.
squ(y*p+x,z) - generates a square wave. Same parameters as tri(), the parameter "z" controls the pulse width of the waveform.
"p" is not a parameter that can be modified and in all cases must be included as-is.

Examples

You can copy & paste these examples into the function input, please tweak them as needed!

squ(p, 0.25) - generates a 25% pulse width waveform.
tri(2*p+0.50, 0.60) - generates two triangle waves, whose phase is shifted by 180 degrees and has the wave peak shifted to at 60% of the wave.
0.5*sin(p) + 0.5*sin(2.0*p) - you can achieve additive synthesis by adding together multiple functions at different frequencies (multipliers).
sin(1.0*p + 0.14*sin(1.0*p)) - rudimentary 2-operator FM synthesis can be achieved as well!
(p < 1/2.5 ? sin(2.5*p) : 0) - using ternary to generate an interesting bass-like waveform.
p <= 1/8 ? sin(0.125+p*8) : -sin(0.2+p*2.33) - using ternary again, this time to generate a classic Namco wavetable sound.
(p = (p < 0.5 ? p:1+p)*2)*0 + saw(Math.pow(p,3.7)) - the function parser can accept Javascript (as this tool is JS)!