On Wed, 5 Nov 1997 10:12:56 +0200 Eric van Es writes: >> To maintain a fixed size buffer containing >> a set of n equally spaced in time values that best represent the >events >> over a time period that is continually increasing. >> >> To ensure there are always n values present (the device could be >asked to >> dump its contents at any time) and that they faithfully represent >the >> input time series means the n values must be "adjusted" as each new >sample >> arrives. There are methods for "resampling", for example taking audio samples at 44.1 KHz from a CD and "adjusting" them so they are ready to record on digital tape at 32 KHz. For the case of the new sample rate being exactly double or exactly half (or 3X, etc), it's very simple. But if the rates don't match well, then it gets complicated and strange aliasing effects leading to loss of quality (beyond what just reducing the sample rate does) could be expected. So if you have 60 samples in the buffer and resample them at a rate of 59/60, generating 59 new samples, there will be room for one new sample in the buffer. The resample process would have to be done for each new sample, but this would guarantee there would always be either 59 or 60 samples in the buffer. If you can tolerate not having all 60 at any given time, then the resample could be done every 5 samples and so on. The computation would be real easy if you could accept a 1/2 (30/60) resample, this would halve the sample rate every 30 samples (after the first 60). But the buffer may have as few as 30 samples if the process is stopped immediately after a resampling. I'm not familiar with exactly how resampling works. I suppose one simple method would be to do "weighted interpolation", based on where the new sample points land among the existing ones. For example, if a new sample point lands at 1.75 (3/4 of the way between existing samples 1 and 2), take 3 parts of sample 2 and 1 part of sample 1, and divide the result by 4. This won't work very well, but it's a start. Techniques for resampling must be discussed heavily in DSP literature, where it is needed in many situations. Doubtless there are some web pages about it, or paper pages in the university library.