-2

I'm using Python, pyaudio and scipy and I would like to combine two sine waves (two tones) in a way that one tone is played after another (create melody). Let's assume that I have two arrays: tone1 and tone2.

tone1 contains data of sine wave with frequency of 350 Hz. tone2 contains sine wave's data with frequency of 440 Hz.

My question is: how to combine these two arrays (tone1 and tone2) into one array that, after being played, will give me a melody without noticeable crack between these two sine waves (tone1 and tone2)?

Laurel
  • 5,965
  • 14
  • 31
  • 57
Shot
  • 345
  • 5
  • 19

1 Answers1

1

Append them together and apply a Fourier Transform smoothing filter. In the regions with a single tone, the Fourier transform will have only one component, and the filter will do nothing; whereas in the transition region you will get both components (plus the crap coming from the jump), that the filter would hopefully smooth out.

Davidmh
  • 3,797
  • 18
  • 35
  • Does numpy/scipy has function to perform Fourier Transform smoothing filtering? – Shot Apr 24 '14 at 11:39
  • I don't think they do, but you can use pyOpenCV: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.html or roll your own. – Davidmh Apr 24 '14 at 11:43