python - How to synthesize sounds? -
I want to produce sounds that meet the audio from real devices. The problem is that I have very little clue how to get it.
I know this much more than real instruments that it seems that the production is rarely clean. But how to generate such impure sound?
This far as I've got to do this, it produces quite plain sound from where I'm not sure that it is also using alsa correctly. Numpy.fft imported from fft import numpy, alsaaudio Import from PCM numpy.random import random_sample to IFFT, PCM_NONBLOCK, PCM_FORMAT_FLOAT_LE PCM = PCM () #mode = PCM_NONBLOCK) pcm.setrate (44100) Pcm.setformat (PCM_FORMAT_FLOAT_LE) pcm.setchannels (1) pcm.setperiodsize (4096) def sine_wave (x, freq = 100): sample = numpy.arange (x * 4096, (x + 1) * 4096, dtype = numpy. Float32 sample = * numpy .pi * 2/44100 sample * = freq return numpy.sin (sample) for x in xrange (1000): sample = sine_wave (x, 100) pcm.write (sample.tostring ())
Happy, if you want to generate (from scratch) Te is something that really feels like a physical object "organic", ie, you probably think that it is sound to generate, learn a little bit about it. For a solid introduction, you can see a book like Fletcher and Rostings, there are so many things on the web, you can see a cloud primer James Clark
On this type of things By doing less skimmery you will know what you are doing against the opposite. Modeling physical devices is very difficult in the right form!
If you want to do something that looks physical, but rather something that seems like the instrument x, your job is a bit easier. You can create frequencies very easily and stack them together, add a little noise, and you will get something that does not speak anything like at least one pure voice.
Reading a bit about Fourier analysis will help normalize, such as Frequency Modulation (FM) techniques.
Have fun!
Comments
Post a Comment