Wave file generator

Client-side (javascript) wave file generator.
Although Audacity has some tools to generate test signals (e.g. sine wave) it lacks some features, in particular I could not find convenient way to use it to generate DC offset, needed to test multiple I2S outputs working at the same time using oscilloscope instead of real I2S codecs. This generator is intented to speed up this operation, previously involving generating binary file with 16-bit samples and importing it in Audacity as raw data.

With this generator waveform would be described with sampling frequency (to be put in wave file header), number of bits per sample and javascript formula for sample values.

Sampling frequency:

Sample size:

Number of samples in file:

Formula (directly evaluated javascript):

Symbols that can be used:

n
index of the sample
samplingFrequency
sampling frequency, (value as entered above)

Examples:
3
fill every sample with constant value = 3
n % 10000
saw waveform with values rising from 0 to 9999 and again
( (n/(samplingFrequency/(2*50))) & 0x01 ) ? 8000 : -4000
asymetric (+8000/-4000) 50Hz square wave
10000 * Math.sin(2 * Math.PI * 1000/samplingFrequency * n)
sine wave, 1000 Hz, amplitude = 10000

Different waveforms can be freely combined (added). Sample values after calculating are saturated according to selected bit width (16 or 24 bits).

Name of file to create:


 "Cookie monsters": 2935524    Parse time: 0.001 s