Wavegen

Help
Last updated: 2026.04.06


Length:
Bit Depth: 4-bit
Function:
Absolute mode






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!

This help section is a bit of a mess, but should go in much greater detail than previously...

Help

Wavegen is a utility that allows you to generate a waveform for use with various chiptune systems using a formula.
This manual will cover the accepted parameters as well as usage examples.

Parameters

Length Defines how long the waveform generated should be. Typically 32, but can be arbitrary.
Note that selecting a preset will overwrite this setting.

Depth Defines the bit-depth of the resulting waveform. The value is used in the formula: 2^x-1, where x represents the the bit depth of the targeted systemm.

This is the main way to interact with the tool. Enter a desired function to generate a waveform.
sin(p) generates a sine wave.
  • Multiplying p by a number will increase how many oscillations will get generated.
  • You can shift the starting phase by adding another number.
    • sin(2*p) generates a sine wave an octave above the played note, harmonically speaking.
    • sin(p+0.25) shifts the phase by 90 degrees.
    • sin(2*p + 0.25) generates a sine wave an octave above the played note, at a phase of 90 degrees.

saw(p) generates a sawtooth wave.
  • Like with the sin(p) function, you can multiply or alter the phase by multiplying or adding to p respectively.

tri(p) generates a triangle wave.
  • Like with the sin(p) function, you can multiply or alter the phase by multiplying or adding to p respectively.
  • Adding a comma and then specifying a number between 0.0 and 1.0f lets you determine where the peak of the triangle will be situated. Default is 0.5.
  • tri(p,0.25) generates an asymmetrical triangle with the peak occurring at the 25% point of the cycle.

squ(p) generates a square wave.
  • Like with the tri(p) function, you can multiply or alter the phase by multiplying or adding to p respectively, and the comma defines the pulse width in this case, so for instance, squ(p,0.25) generates a 25% pulse width waveform.

JavaScript functions are considered valid.
  • An example: p <= 1/8 ? sin(0.125+p*8) : -sin(0.2+p*2.33) demonstrates ternary operations as part of the formula.
  • Mathematical arguments like Math.pow() can also be used.

Any maths used with formulas is also valid.
  • 0.25 * saw(1.5*p) will lower the saw function's volume to 25%.
  • 0.5 * squ(2*p) + 0.5 * squ (3*p + 0.25) generates two square wave sounds, tuned to the 2nd and 3rd harmonic specifically.
    • The second tone is phase shifted by 90. Note how using the addition parameter (aka the plus symbol) can be used to add multiple different sounds together to generate more complex waveforms.
  • sin(1.0*p + 0.14*sin(1.0*p)) generates a phase-modulated sound, very similar to how Yamaha's sound chips work.
    • Demonstrates that you can do complex math inside a function, in this case using a sin function within a sin itself.
    • 1.0 * p inside the sin functions work similarly to "multiplier" values found on Yamaha FM chips. Setting this to 2.0 will be like setting that multiplier to 2.
    • 0.14 works like a modulation amount. Increase to get a more dramatic effect.

Distortion Four distortion settings are provided plus a modifier.

Output format Eight formats are currently defined Please note that as of right not all of the hex output modes are a little bugged - they will only pad values up to 1 byte (for values less than 0x10).

Separator The separator field lets you define what each value is separated by. By default, it's prefilled with " ". Using "\n" will set the separator to be a newline.