I'm newbie in DSP (maybe the question title is misleading for this reason, I apologize for this, please feel free to edit it) but not in programming. I want to experiment with Fourier (or FFT) transformation. Basically I need the generator which will give me signal looking like this: enter image description here

I would also like to add/remove to/from this signal some noise, This is example for sine wave but I hope you get the point. enter image description here

Is this possible for someone whom only knowledge about Fourier transformation is that is composition of sines and cosines with the aim of being able to create signal of any shape? I've been searching for some code snippet where I can change parameters and see how the signal is changing but my google-fu was not enough for this. Preferred language is python (where i can import module and call function) or R or something multi platform (open source) and simple and fast. Thank you.


2 Answers 2


You can create a sine wave in numpy. Think of it as if you were sampling data from a signal, only you are sampling a mathematical function:

sample_rate = 1024
dt = 1.0/sample_rate
t = np.arange(sample_rate)*dt  # 1 second of samples
freq = 5
amp = 1.0
sine1 = amp*np.sin(2*np.pi*freq*t)
sine2 = .5*np.sin(2*np.pi*15*t)
sinsum = sine1 + sine2

There is a nice introductory book to the topic Think DSP - Digital Signal Processing in Python that covers just what you asked.

The book is free and comes with simple library and examples for generating different types of signals (sine, triangle, square, brownian/pink/gaussian noise), summing those signals together, calculating FFT and plotting both spectrum and spectrograms.

Here is a more detailed example on how to generate, store and plot a sine signal in python (with NumPy, pylab and wave): http://howto.quasoft.net/create-sinusoid-signal-and-store-to-wave-file.html

You will find similar examples in the book.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.