Prev: ADC quantizer question.
Next: need solution manual
From: rewindgamez on 9 Oct 2009 15:47 Hello everyone, firstly, this is my first post and I am completely new to DSP. I was previously only interested in graphics/trigonometry problems, however, I'm currently very interested in developing a LPC codec for my own hobby. I know this is a complex problem, and perhaps not the realm of an enthusiast, but I hope it is never too late to learn. I have read several papers; Park-LPC-tutorial, tony robinsons page and Jeremy Bradbury 2000. I am not very familiar with the maths involved and would like to clear a few points: All papers talk about samples; i.e. to predict the next 'sample', I should calculate the sum of the past n-'samples', weighted by the linear prediction coefficients. A sample in my mind is a set of values, representing a quantized sound. so how can i apply the calculation to a set of values? or am i misunderstanding? Also, if there is any java source code for an encode/decode method of LPC, it would greatly help me learn how to use this. Could anyone share? or, if not - would anyone mind writing some very basic pseudo code for me to understand? I'm afraid I don't understand Matlab code or the mathematical notation used in the papers I have. Cheers.
From: Vladimir Vassilevsky on 9 Oct 2009 16:18 rewindgamez wrote: > Hello everyone, > > firstly, this is my first post and I am completely new to DSP. I was > previously only interested in graphics/trigonometry problems, however, I'm > currently very interested in developing a LPC codec for my own hobby. > > I know this is a complex problem, and perhaps not the realm of an > enthusiast, but I hope it is never too late to learn. If you are looking for a recipe, this is not going to work. If your goal is knowledge, start with a good book: L. Rabiner "Digital Speech Processing..." M. Condoz "Digital Speech Coding..." If you are looking for solution, hire a consultant. > I have read several papers; Park-LPC-tutorial, tony robinsons page and > Jeremy Bradbury 2000. Superficial online junk. > I am not very familiar with the maths involved and would like to clear a > few points: > > All papers talk about samples; i.e. to predict the next 'sample', I should > calculate the sum of the past n-'samples', weighted by the linear > prediction coefficients. > A sample in my mind is a set of values, representing a quantized sound. so > how can i apply the calculation to a set of values? or am i > misunderstanding? > > Also, if there is any java source code for an encode/decode method of LPC, > it would greatly help me learn how to use this. Could anyone share? or, if > not - would anyone mind writing some very basic pseudo code for me to > understand? /* Calculation of LPC filter koeffs using Levinson - Durbin recursion. *acf = ponter to array of autocorrelation function values acf[0], acf[1]....acf[lpc_order] *lpc = pointer to filter koeffs calculated by function a[0],a[1]...a[lpc_order-1] lpc_order = the order of LPC */ float lpc(float *acf, float *lpc, int lpc_order) { int i,j; float tmp0,E,Pk; float *tmp; tmp=(float *)alloca(lpc_order*sizeof(float)); E=acf[0]; for(i=0;i<lpc_order;i++) lpc[i]=0.0; for(i=0;i<lpc_order;i++) { tmp0=acf[i+1]; for(j=0;j<i;j++) tmp0-=lpc[j]*acf[i-j]; if(fabs(tmp0)>=E) break; lpc[i]=Pk=tmp0/E; E-=tmp0*Pk; for(j=0;j<i;j++) tmp[j]=lpc[j]; for(j=0;j<i;j++) lpc[j]-=Pk*tmp[i-j-1]; } return E; } > I'm afraid I don't understand Matlab code or the mathematical notation > used in the papers I have. > > Cheers. IHTH Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
From: Rune Allnor on 9 Oct 2009 16:18 On 9 Okt, 21:47, "rewindgamez" <thesamuraieleph...(a)hotmail.co.uk> wrote: > Hello everyone, > > firstly, this is my first post and I am completely new to DSP. I was > previously only interested in graphics/trigonometry problems, however, I'm > currently very interested in developing a LPC codec for my own hobby. > > I know this is a complex problem, and perhaps not the realm of an > enthusiast, but I hope it is never too late to learn. > > I have read several papers; Park-LPC-tutorial, tony robinsons page and > Jeremy Bradbury 2000. > > I am not very familiar with the maths involved and would like to clear a > few points: > > All papers talk about samples; i.e. to predict the next 'sample', I should > calculate the sum of the past n-'samples', weighted by the linear > prediction coefficients. > A sample in my mind is a set of values, representing a quantized sound. so > how can i apply the calculation to a set of values? or am i > misunderstanding? A 'sample' in the DSP context, is just a number. In the real world, the number could representa anything (sound pressure, acceleration, voltages, currents, temperatures, whatever) but as soon as the physical signal was sampled by and ADC, the data are nothing but numbers. The basic idea behind prediction is to use the samples (numbers) already available to you, to predict the sample (number) that arrives next. The better you can do that, the better the codec. One way to do this, is to use the temperature reading today to predict the temperature outdoors tomorrow. In my parts of the world, it is autumn, heading towards winter, so 1) Temperatures are low 2) They tend to get lower every day Using the calendar as starting point my first guess for early October would be +5C. The next day I read the temperature, to find, say, +3C. So I adjust my guess: I was too high with my first guess, so I adjust down; temperatures are dropping, so I adjust down some more. Next guess for tomorrow is -1C. The next day I read, to find 0C, and I adjust again. This is what prediction is all about: Use the numbers you already have, and what knowledge or assumptions about rates of change are reasonable, to predict the next data point as accurately as possible, before you actually see the data points. If you can do this very well, you only have to transmit or store the recipe for the predictor, and a couple of extra numbers. Which takes far less bandwith or space than the raw data. > Also, if there is any java source code for an encode/decode method of LPC, > it would greatly help me learn how to use this. Could anyone share? or, if > not - would anyone mind writing some very basic pseudo code for me to > understand? > > I'm afraid I don't understand Matlab code or the mathematical notation > used in the papers I have. Start working on it. It's like with music: You can get so far just by practice and talent. But at some point you will need to learn how to read notes if you want to proceed. Rune
From: rewindgamez on 9 Oct 2009 16:47 Thanks both for the help. The C code is most helpful for me to understand the filtering. And - thanks for the advice on the books, I'm going to check in the library for those. The weather example is a very good example, even if already familiar with the concept it does help to crystalize it. As for learning the mathematical notation, I have tried several times, and in some areas I am familiar (vectors, cross products, dot products, trigonometry), but for others (statistics, etc.) I am terrible. I will perhaps look for some excercise books as I am terribly out of practice. Once again, thankyou both for the help and pointers!
From: Richard Dobson on 9 Oct 2009 18:15
rewindgamez wrote: ... > A sample in my mind is a set of values, representing a quantized sound. so > how can i apply the calculation to a set of values? or am i > misunderstanding? > In this case it means individual sample values in a soundfile, or as received from a soundcard, i.e. "sample" as in "sample rate". There is an example of LPC audio processing in Csound, very much in the context of speech analysis for resynthesis (analysis utility "lpanal",and opcodes "lpread" and "lpreson"). May not entirely suit what you are looking for (and definitely not cutting-edge implementation!), but could be a reasonable starting point. If you have not come across Csound before (see www.csounds.com) , you will find it a very rich resource for all sorts of musical processing. Also look at the LPC example in the musicdsp archive: http://www.musicdsp.org/archive.php?classid=2#137 It even employs Levinson-Durbin recursion, which should satisfy even the most critical responders on this list. You may find the musicdsp mailing list a more simpatico forum generally, for music-related investigations. Richard Dobson |