Suppose I have some sampled signal data in a ROM on a microcontroller or something, and I'm reading it out to a DAC. Let's say that for some reason, I'd like to begin reading this data at some random position, go for a while, and then stop at a random stopping point and jump to another random position in the ROM and continue reading, and so on, to obtain pseudorandom variations on the waveform data. What sort of interpolation algorithm might be appropriate to use in a situation like this to smooth the discontinuity between the two jump points?

# Waveform interpolation

Started by ●August 9, 2015

Reply by ●August 9, 20152015-08-09

Reply by ●August 9, 20152015-08-09

On 09/08/2015 20:02, bitrex wrote:> Suppose I have some sampled signal data in a ROM on a microcontroller or > something, and I'm reading it out to a DAC. Let's say that for some > reason, I'd like to begin reading this data at some random position, go > for a while, and then stop at a random stopping point and jump to > another random position in the ROM and continue reading, and so on, to > obtain pseudorandom variations on the waveform data.Does it have to be random to random position? Zero crossing and in the same direction will get you something that the ear can barely hear.> What sort of interpolation algorithm might be appropriate to use in a > situation like this to smooth the discontinuity between the two jump > points?Force the wavefrom jump to be at a zero crossing and pick up from a zero crossing with the same sign gradient. -- Regards, Martin Brown

Reply by ●August 9, 20152015-08-09

On 8/9/2015 3:02 PM, bitrex wrote:> Suppose I have some sampled signal data in a ROM on a microcontroller or > something, and I'm reading it out to a DAC. Let's say that for some > reason, I'd like to begin reading this data at some random position, go > for a while, and then stop at a random stopping point and jump to > another random position in the ROM and continue reading, and so on, to > obtain pseudorandom variations on the waveform data. > > What sort of interpolation algorithm might be appropriate to use in a > situation like this to smooth the discontinuity between the two jump > points?What Martin said, or you can use a fade-in, fade-out perhaps, or a cross-fade where the two fades work at the same time. I think the answer to this question depends greatly on the waveform and its use. -- Rick

Reply by ●August 9, 20152015-08-09

On Sunday, August 9, 2015 at 12:02:59 PM UTC-7, bitrex wrote:> What sort of interpolation algorithm might be appropriate to use in a > situation like this to smooth the discontinuity between the two jump points?You won't be able to jump at random samples, just at the zero crossings. If you jump around randomly, the output data will no longer represent samples of a band-limited signal, and no postfiltering process can remove the influence of the jumps. If you really have to support arbitrary branches, the best approach is probably to continue reading from both the original and destination points and blend the data gradually. -- john, KE5FX

Reply by ●August 9, 20152015-08-09

On 8/9/2015 4:05 PM, John Miles, KE5FX wrote:> On Sunday, August 9, 2015 at 12:02:59 PM UTC-7, bitrex wrote: >> What sort of interpolation algorithm might be appropriate to use in a >> situation like this to smooth the discontinuity between the two jump points? > > You won't be able to jump at random samples, just at the zero crossings. If you jump around randomly, the output data will no longer represent samples of a band-limited signal, and no postfiltering process can remove the influence of the jumps. > > If you really have to support arbitrary branches, the best approach is probably to continue reading from both the original and destination points and blend the data gradually. > > -- john, KE5FX >Yes. I could try the former, but then I guess I'd need to store metadata on where the zero crossings are. I'd like to do this on a little 8 bit microcontroller, and space is kind of limited. And the metadata would have to be regenerated if I were ever to change the original data. Could the latter approach work on a processor with limited resources?

Reply by ●August 9, 20152015-08-09

bitrex wrote:> Suppose I have some sampled signal data in a ROM on a microcontroller or > something, and I'm reading it out to a DAC. Let's say that for some > reason, I'd like to begin reading this data at some random position, go > for a while, and then stop at a random stopping point and jump to > another random position in the ROM and continue reading, and so on, to > obtain pseudorandom variations on the waveform data. > > What sort of interpolation algorithm might be appropriate to use in a > situation like this to smooth the discontinuity between the two jump > points?DAW programs use a "crossfade" - you ramp the first signal down at X db/sec while ramping the second signal up at the same X db/sec. The amount of time for the crossfade would then be determined by the fade-slope - X. If X is 6 db/sec, then 96 dB is 16 seconds. You probably want more slope than that. This to address discontinuities caused by a square "butt splice", just as in tape splicing when you'd use an angled cut. Adding dither may be required, depending. -- Les Cargill

Reply by ●August 9, 20152015-08-09

On Sunday, August 9, 2015 at 1:05:22 PM UTC-7, John Miles, KE5FX wrote:> On Sunday, August 9, 2015 at 12:02:59 PM UTC-7, bitrex wrote: > > What sort of interpolation algorithm might be appropriate to use in a > > situation like this to smooth the discontinuity between the two jump points? > > You won't be able to jump at random samples, just at the zero crossings. If you jump around randomly, the output data will no longer represent samples of a band-limited signal, and no postfiltering process can remove the influence of the jumps. > > If you really have to support arbitrary branches, the best approach is probably to continue reading from both the original and destination points and blend the data gradually. >This is one of the topics that fascinates me most. The Zero-Crossing cut & splice always works. But what about those cases when the waveform crosses Zero, but it happens Between Sample Capture for the actual Zero-Crossing in time? . . . t-3 sample = 0.31 t-2 sample = 0.23 t-1 sample = 0.14 Zero-Crossing's zero point is not in the sample data! t0 sample = -0.02 t1 sample = -0.25 t2 sample = -0.37 . . . Also, how does one calculate the time for a given list of arbitrary Sine wave frequencies for one full cycle to where all oscillators Cross-Zero in true unison again together? For example 100 Hz, SQR(2)*100 Hz, and 200 Hz starting in-phase at zero-crossing. How many seconds does it take for all three tones to cross zero together when all start in-phase at the zero crossing origin? I know you have to multiply all three together and take out common factors if any, but then how to get it to duration in seconds or instead of number of cycles. My brain must be fried in this area as it is coming up a total blank, sorry.

Reply by ●August 9, 20152015-08-09

On Sun, 9 Aug 2015 15:02:56 -0400, bitrex <bitrex@de.lete.earthlink.net> wrote:>Suppose I have some sampled signal data in a ROM on a microcontroller or >something, and I'm reading it out to a DAC. Let's say that for some >reason, I'd like to begin reading this data at some random position, go >for a while, and then stop at a random stopping point and jump to >another random position in the ROM and continue reading, and so on, to >obtain pseudorandom variations on the waveform data. > >What sort of interpolation algorithm might be appropriate to use in a >situation like this to smooth the discontinuity between the two jump points?Assuming that your "position" (ie, time) variable has finer resolution than your lookup table, you can use simple linear interpolation. Linear interpolation between two points can never result in an output bigger than either point, whereas an ideal filter can. So for better approximation of a good sample reconstruction filter, you need to account for more than two table points, and use something like a cubic or higher order spline interpolation. That may not matter in your situation. https://dl.dropboxusercontent.com/u/53724080/Circuits/Filters/Wayback_Machine/Interpolation_Error.JPG -- John Larkin Highland Technology, Inc lunatic fringe electronics jlarkin att highlandtechnology dott com http://www.highlandtechnology.com

Reply by ●August 9, 20152015-08-09

On Sun, 09 Aug 2015 14:36:42 -0700, John Larkin <jlarkin@highlandtechnology.com> wrote:>On Sun, 9 Aug 2015 15:02:56 -0400, bitrex ><bitrex@de.lete.earthlink.net> wrote: > >>Suppose I have some sampled signal data in a ROM on a microcontroller or >>something, and I'm reading it out to a DAC. Let's say that for some >>reason, I'd like to begin reading this data at some random position, go >>for a while, and then stop at a random stopping point and jump to >>another random position in the ROM and continue reading, and so on, to >>obtain pseudorandom variations on the waveform data. >> >>What sort of interpolation algorithm might be appropriate to use in a >>situation like this to smooth the discontinuity between the two jump points? > >Assuming that your "position" (ie, time) variable has finer resolution >than your lookup table, you can use simple linear interpolation. > >Linear interpolation between two points can never result in an output >bigger than either point, whereas an ideal filter can. So for better >approximation of a good sample reconstruction filter, you need to >account for more than two table points, and use something like a cubic >or higher order spline interpolation. That may not matter in your >situation. > >https://dl.dropboxusercontent.com/u/53724080/Circuits/Filters/Wayback_Machine/Interpolation_Error.JPGOr maybe I misunderstood the problem. If you want to smooth the jump between the two waveform segments (and not between points within a waveform) a lowpass filter might work. Or a fader type algorithm, depending on your requirements. The point interpolator would still help, to better map the table output to the time variable. -- John Larkin Highland Technology, Inc lunatic fringe electronics jlarkin att highlandtechnology dott com http://www.highlandtechnology.com