Tuesday, January 26, 2010

A bit of technical stuff

     Digital Signals Processing was boring today, but I did have an interesting idea. I am going to write  piece of MATLAB code designed to decompose an audio signal into component sinusoids by approximation. I understand that a Fourier Transform would be easier, but I'm not sure how to implement that with digital data.

     I'll start with an exact input sinusoid. The function will first read the max amplitude and then create a low-res 3-d table of various sinusoids by sweeping amplitude, frequency and phase across a predefined range, probably somewhere in the human speech range, then calculate an error function for each generated sinusoid as compared to the input, and lastly select the function for which error is a minimum.

     Once an approximation is settled on, the function will "jiggle" the signal in three dimensions, again selecting for the lowest error function, in increasingly small scale, hopefully arriving at an approximation that is indistinguishable from the input signal.

     Matching a single sinusoid will likely be easy. The next step will be to input a sum of two sinusoids and direct the function to try the same thing, but approximating two signals. The initial step will be very computationally intensive, as a thorough sampling would involve calculating an error function for every possible combination of two sinusoids in the three-dimensional predefined range, which may itself be rather large. The jiggling will be difficult for the same reason; it will occur in six dimensions instead of three. The alternative is to sequentially jiggle first one and then the other signal. I wonder what effects this would have on accuracy.

     Ultimately, I hope to be able to pare the code down to something computationally feasible and have it approximate signals that are the sum of many sinusoids. Theoretically, I should then be able to input a voice recording, decompose it, and resynthesize it. The final product will probably be little more than a "Your voice as a robot" widget that consumes enough power to light the city of Chicago for two days, but hey. Why not?

No comments:

Post a Comment