Board Games30
Role Playing40
Resource Directory
Code Gallery3
Help & Documents13
IOTD: Sound Wave Generator
Sound Wave Generator
Sound Wave Generator, by larienna

Sound Wave Generator is now Available!. Sorry for the delay, it's now in the Depot(utilities). Even if I had made the program in only 3 week, I did not had any place to store the files on the web. I now added a few features compared to the first version.

Sound Wave Generator is a tool that allows you to create a sound wave sample from scratch. No recording equipment required. It is done my setting 3 parameters that will produce different sound effects : Waveform, Envelope and pitch gradient.

The generated sound are saved as wave files or as a .swg parameter file. I know that there has been a demand to make a library to generate the sound inside the game. There is no library available but the source code is available.

I can know generate more chaotic sound than before but I cannot generate all of them (ex: Lightning and fire ) Some chaotic sound have a bad output in the editor but when saved on a .wav, they sound better.

If you have any informations that can allow me to increase the range of "chaotic sound"( or any other sound) that can be created with the editor, send them to me by e-mail.
Ah-ah-ah-ah!! :freaks out: I want it!!
=D - Ceagon Xylas
hmmm, I'll try it out :) sounds like a nice thing :) - Pavel Hilser
Seems very cool! I'll try it out too :) - Pedro Avelar Gontijo
Note for downloading, the files are on my friend's server. The IP get reseted around 6AM(east time) which makes the download links inactive for an hour or two. So if the link is broken, just try later. Even with this problem, we still have a server active most of the time. - larienna
Um, the generated sounds don't seem to center at zero amplitude. Maybe you're converting between signed and unsigned samples at the wrong point?
To achieve more variations, here are some things you may want to try:
more osc types
- PWM (pulse width modulation): Modulate the width of a square wave's pulse, or the attack and release steepness of a sawtooth wave. And tons of other parametric (partly-linear) functions you can imagine. In fact, you can describe a lot of partly-linear wave forms in a general form, using only a few parameters.
- PD (phase distortion): Apply sin() (or better cos()) to an arbitrary function's output (or any osc output for that matter), instead of the usual linear phase.
- Random pulses: If a random number is above a threshold, generate a pulse, else 0. Great for rain and other grainy noise.
modulation schemes
Modulation makes synths versatile. You might want to try at least:
- Signal mixing. The easiest: just add the outputs of several synth chains together. Two slightly detuned chains that are otherwise identical, panned to extreme left and right, for example, give very spacious results.
- Amplitude modulation, i.e. multiply the outputs of two osc's together.
- Frequency modulation, i.e. add the scaled output of one osc (or env) to the (linear or logarithmic) frequency fed to another osc.
- Parameter modulation, i.e. add the scaled output of one osc (env) to any parameter for another os.
- Filters. Filters are very nice. Read up on IIR filters in case you haven't already. A simple 2-pole can do miracles.
- Delay. Easy to implement, great results (if used wisely).
- Reverb. Harder to implement, but very useful and enhancing.
- Various distortions. Simplest is increase amplitude and cut off at max; but it can get as complex as you want it to be.
- Chorus, phaser, flanger and what have you. Especially great for making stereo sounds. - Tobias Dammers
I am assuming that 8 bit goes from -127 to 128, and 16 bit goes from -32767 to 32767. If you add zone zeroline movement, of course the zero amplitude will be changed.

Sorry if I am not familiar with sound vocabulary, for osc type, I think you are talking about the input value in the function. True, i am only incrementing a radian value from 0 to 6.28. Which some what like a sin(running around a circle). So you are suggesting other type of radian incrementation?

I did not made any panning envelope because I tought that they were only useful for stereo output. For modulation and addition, I have read some stuff about synth, so I think it could be possible to make 2 or more different wave form and combine them with an operator.

About the filters, now that you mentioned the name "IIR filters" I can try searching on this. If it is well documented, I might add it.

Thank again for the feedback. Consider that I am not an expert about sound wave, I made this program with the few knowledge I have. - larienna
Well, zero line movement, if it is slow, has little audible effect. It only adds a very low frequency, and reduces headroom.
About osc type, yes, changing the input to the sin function is one way to achieve different wave forms. But there are other possibilities; a simple saw tooth generator (output as float in the [-1.0 ... 1.0] range) could look like this:
float sawtooth(float omega) {
  return 1.0f - omega / M_PI;
A PWM-rect generator might look like this (0.0 <= pulse width <= 1.0):
float pwm_rect(float omega, float pw) {
  float pw_pi = pw * 2.0f * M_PI;
  if (omega < pw_pi)
    return 1.0f;
    return -1.0f;
You can easily imagine other partly-linear curves that may sound interesting. Just keep in mind that input should be in the 0...2*PI range, and output should be -1.0 ... 1.0.
I happen to have some good documentation on filters and DSP in general; PM me if you want me to e-mail it. - Tobias Dammers
This section is only available to registered members.

The Gallery | Add your own image!
Is grammer and spelling important?
View Results