Jump to content
  • Advertisement
Sign in to follow this  
PurpleAmethyst

Generating Waveforms In Software

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am writing a little sound effects generator program and am trying to write some waveform generators in software. I am wondering what the most effecient way to generate the follwing waveforms in software might be sinus, sawtooth, triangle, square and noise. Noise and sinus are obvious and I've found ample information on the web about how to generate them, but was wondering about the others. I know they can be generated by summing sinus waveforms of different phases, but this seems a little bit over the top for a simple proggy. So if anyone has any tips or links I'd appreciate it! Patrick

Share this post


Link to post
Share on other sites
Advertisement
the nice thing about 'creating' things in software is that your imagination is the only limiting factor.

you want a sawtooth? x = (y * a) mod b

as simple as that.

actually noise is the least obvious one.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Eelco
you want a sawtooth? x = (y * a) mod b

as simple as that.

Not quite that simple... Yes, it is the "obvious" way to do it, and for a game or a simple sound application it might be good enough. However, sampling such a signal leads to aliasing and quite audible sound artifacts that are unacceptable for high quality sound applications. To avoid aliasing you must produce a bandlimited version of the waveform, which is much less straight-forward to implement efficiently.

Summing sinus waves (truncated harmonic series) is a simple way to generate bandlimited waveforms, but unfortunately it is quite inefficient in most cases. If you google for "bandlimited oscillators" you can probably find some useful theory, implementation considerations and even sample code you can learn from. This paper by Stilson and Smith is a classic on the subject: http://ccrma-www.stanford.edu/~stilti/papers/blit.pdf

Of course, this might be overkill if sound quality is not a priority, but at least one should be aware of these potential problems then dealing with digital signals.

Share this post


Link to post
Share on other sites
Yeah I knew the sawtooth could be done like that, but as AP said above it has problems, although many simple hardware oscillators do generate waveforms like that. Thanks for the paper, I'll let you know how I get on with the sound app. I don't need realtime, although it would be nice, so perhaps the mathematical functions would do.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eelco
ah so you want Hardware waveforms. couldnt see that from your OP.


No, I was just commenting that your method is used by hardware synth chips!

I'm finding that paper a little hard to understand, but I'll get there in the end!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!