On 09/08/15 23:41, John Larkin wrote:> 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.JPG > > > Or 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. > >A key point, I think, is whether you know about the jumps in advance. If they are predictable, then you can use future jump points in your interpolation for better results. Another issue is whether or not you can use the next point from the first section during the jumps - that will make the crossfade smoother. You (bitrex) say you want to use a small 8-bit micro - unless your frequencies are very low, consider using a small 32-bit micro instead so that you can use cubic interpolation rather than linear. Cubics mean a bit more maths to figure out, and quite a bit more calculation on the processor (and with larger data sizes - hence the recommendation for a 32-bit cpu). But they give smoother outputs and more freedom for optimisation (such as minimising different derivatives) than linear interpolation.
Waveform interpolation
Started by ●August 9, 2015
Reply by ●August 10, 20152015-08-10
Reply by ●August 10, 20152015-08-10
On 2015-08-09, 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.or even to do PSK> What sort of interpolation algorithm might be appropriate to use in a > situation like this to smooth the discontinuity between the two jump points?a sinc filter on the output perhaps? or a cross-fade on some curve, perhps sqrt(cos^2( 0..pi/2)) vs sqrt(sin^2(0..pi/2)) -- \_(ツ)_
Reply by ●August 10, 20152015-08-10
On 8/10/2015 3:26 AM, David Brown wrote:> On 09/08/15 23:41, John Larkin wrote: >> 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.JPG >> >> >> Or 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. >> >> > > A key point, I think, is whether you know about the jumps in advance. > If they are predictable, then you can use future jump points in your > interpolation for better results. Another issue is whether or not you > can use the next point from the first section during the jumps - that > will make the crossfade smoother. > > You (bitrex) say you want to use a small 8-bit micro - unless your > frequencies are very low, consider using a small 32-bit micro instead so > that you can use cubic interpolation rather than linear. Cubics mean a > bit more maths to figure out, and quite a bit more calculation on the > processor (and with larger data sizes - hence the recommendation for a > 32-bit cpu). But they give smoother outputs and more freedom for > optimisation (such as minimising different derivatives) than linear > interpolation. >In the application that I'm thinking of, the output will eventually be driving a fairly large piezoelectric or magnetic transducer. I think it's possible that the inertia of the transducer itself in this case may itself act sufficiently as a low-pass filter that the jump points will not be noticeable in the output even with just some kind of first-order interpolation. We'll see.
Reply by ●August 10, 20152015-08-10
On 8/10/2015 2:45 AM, glen herrmannsfeldt wrote:> In comp.dsp 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. > > You don't say what kind of data, and it might matter. > > Assuming that the full bandwidth is in use, you should be able > to just switch. > > For audio, there is much less at the higher frequencies, which > makes it more noticable when you add high frequencies with a > discontinuous jump. This is also the reason why audio is fairly > compressible. > > To answer the question, you need to know, approximately, the power > spectrum of the signal. That is, how much there is in the high > frequencies to mask the discontinuity.Not much. The physical process that the data is sampled from has a pretty strong 1/f characteristic. But the output is most likely going to be driving some kind of transducer that will have significant inertia, and it's possible that it will act enough as a low-pass filter that I can get away with a minimum of processing.
Reply by ●August 10, 20152015-08-10
On 10/08/15 12:58, bitrex wrote:> On 8/10/2015 3:26 AM, David Brown wrote: >> On 09/08/15 23:41, John Larkin wrote: >>> 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.JPG >>>> >>> >>> >>> Or 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. >>> >>> >> >> A key point, I think, is whether you know about the jumps in advance. >> If they are predictable, then you can use future jump points in your >> interpolation for better results. Another issue is whether or not you >> can use the next point from the first section during the jumps - that >> will make the crossfade smoother. >> >> You (bitrex) say you want to use a small 8-bit micro - unless your >> frequencies are very low, consider using a small 32-bit micro instead so >> that you can use cubic interpolation rather than linear. Cubics mean a >> bit more maths to figure out, and quite a bit more calculation on the >> processor (and with larger data sizes - hence the recommendation for a >> 32-bit cpu). But they give smoother outputs and more freedom for >> optimisation (such as minimising different derivatives) than linear >> interpolation. >> > > In the application that I'm thinking of, the output will eventually be > driving a fairly large piezoelectric or magnetic transducer. I think > it's possible that the inertia of the transducer itself in this case may > itself act sufficiently as a low-pass filter that the jump points will > not be noticeable in the output even with just some kind of first-order > interpolation. We'll see.Mechanics often act as a low-pass filter (and of course you can use a filter in the analogue electronics) - it could well be good enough for the job. But using a 32-bit micro could give you more flexibility - small Cortex M devices are often cheaper than most 8-bit microcontrollers these days, and certainly I find they are now usually a better choice. Of course there could be other concerns - package types, familiarity, existing code bases, peripherals, voltage ranges, etc., that make your 8-bit device a better choice.
Reply by ●August 10, 20152015-08-10
On 8/10/2015 8:31 AM, David Brown wrote:> On 10/08/15 12:58, bitrex wrote: >> On 8/10/2015 3:26 AM, David Brown wrote: >>> On 09/08/15 23:41, John Larkin wrote: >>>> 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.JPG >>>>> >>>> >>>> >>>> Or 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. >>>> >>>> >>> >>> A key point, I think, is whether you know about the jumps in advance. >>> If they are predictable, then you can use future jump points in your >>> interpolation for better results. Another issue is whether or not you >>> can use the next point from the first section during the jumps - that >>> will make the crossfade smoother. >>> >>> You (bitrex) say you want to use a small 8-bit micro - unless your >>> frequencies are very low, consider using a small 32-bit micro instead so >>> that you can use cubic interpolation rather than linear. Cubics mean a >>> bit more maths to figure out, and quite a bit more calculation on the >>> processor (and with larger data sizes - hence the recommendation for a >>> 32-bit cpu). But they give smoother outputs and more freedom for >>> optimisation (such as minimising different derivatives) than linear >>> interpolation. >>> >> >> In the application that I'm thinking of, the output will eventually be >> driving a fairly large piezoelectric or magnetic transducer. I think >> it's possible that the inertia of the transducer itself in this case may >> itself act sufficiently as a low-pass filter that the jump points will >> not be noticeable in the output even with just some kind of first-order >> interpolation. We'll see. > > Mechanics often act as a low-pass filter (and of course you can use a > filter in the analogue electronics) - it could well be good enough for > the job. > > But using a 32-bit micro could give you more flexibility - small Cortex > M devices are often cheaper than most 8-bit microcontrollers these days, > and certainly I find they are now usually a better choice. Of course > there could be other concerns - package types, familiarity, existing > code bases, peripherals, voltage ranges, etc., that make your 8-bit > device a better choice. >Definitely something to keep in mind. In this case it's most likely a one-off job, and I'm familiar with the Atmel toolchain and have the required programming equipment on hand. I've been meaning to get into ARM someday, though.
Reply by ●August 10, 20152015-08-10
On Mon, 10 Aug 2015 09:45:42 -0400, bitrex <bitrex@de.lete.earthlink.net> wrote:>On 8/10/2015 8:31 AM, David Brown wrote: >> On 10/08/15 12:58, bitrex wrote: >>> On 8/10/2015 3:26 AM, David Brown wrote: >>>> On 09/08/15 23:41, John Larkin wrote: >>>>> 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.JPG >>>>>> >>>>> >>>>> >>>>> Or 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. >>>>> >>>>> >>>> >>>> A key point, I think, is whether you know about the jumps in advance. >>>> If they are predictable, then you can use future jump points in your >>>> interpolation for better results. Another issue is whether or not you >>>> can use the next point from the first section during the jumps - that >>>> will make the crossfade smoother. >>>> >>>> You (bitrex) say you want to use a small 8-bit micro - unless your >>>> frequencies are very low, consider using a small 32-bit micro instead so >>>> that you can use cubic interpolation rather than linear. Cubics mean a >>>> bit more maths to figure out, and quite a bit more calculation on the >>>> processor (and with larger data sizes - hence the recommendation for a >>>> 32-bit cpu). But they give smoother outputs and more freedom for >>>> optimisation (such as minimising different derivatives) than linear >>>> interpolation. >>>> >>> >>> In the application that I'm thinking of, the output will eventually be >>> driving a fairly large piezoelectric or magnetic transducer. I think >>> it's possible that the inertia of the transducer itself in this case may >>> itself act sufficiently as a low-pass filter that the jump points will >>> not be noticeable in the output even with just some kind of first-order >>> interpolation. We'll see. >> >> Mechanics often act as a low-pass filter (and of course you can use a >> filter in the analogue electronics) - it could well be good enough for >> the job. >> >> But using a 32-bit micro could give you more flexibility - small Cortex >> M devices are often cheaper than most 8-bit microcontrollers these days, >> and certainly I find they are now usually a better choice. Of course >> there could be other concerns - package types, familiarity, existing >> code bases, peripherals, voltage ranges, etc., that make your 8-bit >> device a better choice. >> > >Definitely something to keep in mind. In this case it's most likely a >one-off job, and I'm familiar with the Atmel toolchain and have the >required programming equipment on hand. I've been meaning to get into >ARM someday, though.So use an Atmel ARM! ;-)
Reply by ●August 10, 20152015-08-10
bitrex <bitrex@de.lete.earthlink.net> wrote:>In the application that I'm thinking of, the output will eventually be >driving a fairly large piezoelectric or magnetic transducer. I think >it's possible that the inertia of the transducer itself in this case may >itself act sufficiently as a low-pass filter that the jump points will >not be noticeable in the output even with just some kind of first-order >interpolation. We'll see.I'd proceed with infinite caution. Blend signals when: (1) there is a same-sense zero crossing and (2) by gradually reducing the previous signal and amplifying the new signal. I do not think it's correct to use a constand dB/second slope on the two signals. Instead, choose a dual-slope that keeps the RMS power constant. Steve
Reply by ●August 10, 20152015-08-10
On Mon, 10 Aug 2015 20:20:06 +0000 (UTC), spope33@speedymail.org (Steve Pope) Gave us:>bitrex <bitrex@de.lete.earthlink.net> wrote: > >>In the application that I'm thinking of, the output will eventually be >>driving a fairly large piezoelectric or magnetic transducer. I think >>it's possible that the inertia of the transducer itself in this case may >>itself act sufficiently as a low-pass filter that the jump points will >>not be noticeable in the output even with just some kind of first-order >>interpolation. We'll see. > >I'd proceed with infinite caution. Blend signals when: (1) there >is a same-sense zero crossing and (2) by gradually reducing the >previous signal and amplifying the new signal. > >I do not think it's correct to use a constand dB/second slope >on the two signals. Instead, choose a dual-slope that keeps the RMS >power constant. > >SteveDriving a piezo stack..... it had better be a pure sine waveform if high power levels are used. Note how speaker assemblies/speaker cones do not like too much mechanical manipulation from distorted waveforms.
Reply by ●August 11, 20152015-08-11
On Mon, 10 Aug 2015 05:02:56 +1000, 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?If it is random data with an equal distribution then no interpolation is needed and will in fact be a bad thing






