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.
- Parameter p is used for phase. On its own, it's just a linear function that starts from -1.0f and ends at +1.0f, but when combined with actual functions, you can transform this into actual oscillations of waveforms.
- If you multiply this number, you're basically increasing how many oscillations it generates in a given interval when using with one of the functions below.
- Similarly, adding to this number alters the starting phase.
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.
- None - no distortion or limiting will be applied at all.
- Not recommended. If the waveform goes out of bounds, values will not be appropriately clipped.
- Disabled by default, but if you force it to this setting, it will work as "intended".
- Clip - Out of bounds values will be clipped to respective minimum/maximum values.
- This is the default setting.
- Fold - Any out of bounds values will be folded (bounced or reflected).
- This is repeatable, if the waveform is so distorted that it can fold twice, it will fold twice.
- Wrap - Any out of bounds values will be wrapped around from the opposing side. Works like integer under/overflows.
- This is repeatable, if the waveform is so distorted that it can wrap twice, it will wrap twice.
- In addition, an "absolute" toggle is provided. With this setting on, the bottom half of the waveform is rectified by interpreting any negative values as positive.
Output format
Eight formats are currently defined
- Integer - represents the waveform with integers from 0-9, starting from 0.
- Floating-point - represents the waveform in floating point form, from -1 to 1.
- Unsigned hexadecimal - positive values only from 0 going up.
- Signed hexadecimal - Positive and negative values, with respect to the bitdepth.
- Single values - does not pad any of the values to fill out bytes or nybbles
- Padded to nearest nybble - pads low values to always take up the same number of characters (e.g. 12-bit D is represented as 00D)
- Padded to nearest byte - like above, but for full bytes (12-bit D is padded to 000D instead, which takes 16-bits)
Note that any hex output formats gives you access to a prefix field - you can set this to anything ($ for $xx values, 0x for 0xXX values, etc)
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.