I have 100.000 samples long signal I need to present on the display (MS Windows using DirectX). Simple 'use every n-th sample' or downsampling method is not good enough. How to compress signal so it can be presented within few hundred pixels on the screen? If possible algorithm should be quite fast as I need to update several traces (tens) and display them few times per second. Thanks, Damir
How to compress large signal for display
Started by ●November 22, 2005
Reply by ●November 22, 20052005-11-22
in article dm00po$cvq$1@ss405.t-com.hr, damir at dzagar@BRISIsrce.hr wrote on 11/22/2005 15:58:> I have 100.000 samples long signal I need to present on the display (MS > Windows using DirectX).for those of us that are North American bound, the number above is 10^5, not 10^2 . for some reason, we use commas where everyone else uses periods to delimite 1000s.> Simple 'use every n-th sample' or downsampling method is not good enough.correct. it isn't.> How to compress signal so it can be presented within few hundred pixels on > the screen?this is the way most audio editing software does it: for all audio samples that map to a particular pixel, the minimum sample value is determined and the maximum value is determined, and a vertical line is drawn from the minimum value to the maximum value at that pixel location. that way, as you zoom in, the apparent envelope (that might not be symmetric if the waveform is not) actually begins to look like the waveform and does, in the limit, become the waveform when you get to a scale of 1 pixel per sample. if you zoom in even more (more than 1 pixel per sample), if you want the waveform to look nice, you have to interpolate using either some polynomial interpolation (like Hermite or Lagrange) or a windowed sinc().> If possible algorithm should be quite fast as I need to update > several traces (tens) and display them few times per second.it's probably not way too fast, but, if you're doing this real-time, you can always maintain a running maximum value and running minimum value. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●November 22, 20052005-11-22
"damir" <dzagar@BRISIsrce.hr> wrote in message news:dm00po$cvq$1@ss405.t-com.hr...> I have 100.000 samples long signal I need to present on the display (MS > Windows using DirectX). > > Simple 'use every n-th sample' or downsampling method is not good enough.Who not do an average of every n samples?> How to compress signal so it can be presented within few hundred pixels on > the screen? If possible algorithm should be quite fast as I need to update > several traces (tens) and display them few times per second. > > Thanks, > > Damir > >
Reply by ●November 22, 20052005-11-22
damir <dzagar@brisisrce.hr> wrote:> I have 100.000 samples long signal I need to present on the display (MS > Windows using DirectX). > > Simple 'use every n-th sample' or downsampling method is not good enough. > How to compress signal so it can be presented within few hundred pixels on > the screen? If possible algorithm should be quite fast as I need to update > several traces (tens) and display them few times per second.upper and lower envelopes (max & min from every n samples)
Reply by ●November 22, 20052005-11-22
damir wrote:> I have 100.000 samples long signal I need to present on the display (MS > Windows using DirectX). > > Simple 'use every n-th sample' or downsampling method is not good enough. > How to compress signal so it can be presented within few hundred pixels on > the screen? If possible algorithm should be quite fast as I need to update > several traces (tens) and display them few times per second.Compressing 100,000 samples to a few hundred is downsampling by definition I hope it is just that downsampling /the way you went about it/ had problems. You're out of luck if there is no better way. Maybe we can help if you tell us what you tried and why you don't like the result. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●November 22, 20052005-11-22
in article 43838bf4$0$41137$14726298@news.sunsite.dk, Bhaskar Thiagarajan at bhaskart@deja.com wrote on 11/22/2005 16:21:> "damir" <dzagar@BRISIsrce.hr> wrote in message > news:dm00po$cvq$1@ss405.t-com.hr... >> I have 100.000 samples long signal I need to present on the display (MS >> Windows using DirectX). >> >> Simple 'use every n-th sample' or downsampling method is not good enough. > > Wh[y] not do an average of every n samples? >so a sine wave gets displayed as DC or zero? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●November 22, 20052005-11-22
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message news:BFA90CE6.C5D2%rbj@audioimagination.com...> in article 43838bf4$0$41137$14726298@news.sunsite.dk, Bhaskar Thiagarajanat> bhaskart@deja.com wrote on 11/22/2005 16:21: > > > "damir" <dzagar@BRISIsrce.hr> wrote in message > > news:dm00po$cvq$1@ss405.t-com.hr... > >> I have 100.000 samples long signal I need to present on the display (MS > >> Windows using DirectX). > >> > >> Simple 'use every n-th sample' or downsampling method is not goodenough.> > > > Wh[y] not do an average of every n samples? > > > > so a sine wave gets displayed as DC or zero?The OP didn't say what his signal content was. I was going to respond with a whole bunch of choices including the method you suggested but reverted to keeping it simple. This is a common problem in several applications including displaying data in spectrum analyzers, where, the term 'detection' is used for the method of how data gets mapped into display pixels. And in that situation, when 'average' is used, CW or sinusoids suffer from rather inaccurate amplitude information. The choice of 'detection' is left to the user depending on the type of signal he wants to observe (in some cases, modern spectrum analyzers attempt to do some level of automation based on the type of measurement the user is performing). So the question to the OP is, what kind of signals need to be presented on the display and why does 'use every n-th sample' not work for you? Cheers Bhaskar> > -- > > r b-j rbj@audioimagination.com > > "Imagination is more important than knowledge." > >
Reply by ●November 23, 20052005-11-23
> for those of us that are North American bound, the number above is 10^5, > not > 10^2 . for some reason, we use commas where everyone else uses periods to > delimite 1000s.For sure, my intention was not to write 100 using 3 decimal digits :))> this is the way most audio editing software does it: for all audio samples > that map to a particular pixel, the minimum sample value is determined and > the maximum value is determined, and a vertical line is drawn from the > minimum value to the maximum value at that pixel location. that way, as > you > zoom in, the apparent envelope (that might not be symmetric if the > waveform > is not) actually begins to look like the waveform and does, in the limit, > become the waveform when you get to a scale of 1 pixel per sample. if you > zoom in even more (more than 1 pixel per sample), if you want the waveform > to look nice, you have to interpolate using either some polynomial > interpolation (like Hermite or Lagrange) or a windowed sinc(). >I thought about something like that - calculate envelope for min. and max. values. I will look for some algorithm that may be used for "real-time" application. Thanks, Damir
Reply by ●November 23, 20052005-11-23
Jerry Avins wrote:> damir wrote: > > I have 100.000 samples long signal I need to present on the display (MS > > Windows using DirectX). > > > > Simple 'use every n-th sample' or downsampling method is not good enough. > > How to compress signal so it can be presented within few hundred pixels on > > the screen? If possible algorithm should be quite fast as I need to update > > several traces (tens) and display them few times per second. > > Compressing 100,000 samples to a few hundred is downsampling by > definition I hope it is just that downsampling /the way you went about > it/ had problems. You're out of luck if there is no better way.For visual purposes, one probably wants to downsample in two dimensions, not just one. Maybe grayscale representing the number of samples in each volts-seconds plot rectangle, perhaps 2d lowpass filtered. IMHO. YMMV. -- rhn A.T nicholson d.O.t C-o-M
Reply by ●November 26, 20052005-11-26
damir wrote:> I have 100.000 samples long signal I need to present on the display (MS > Windows using DirectX).> Simple 'use every n-th sample' or downsampling method is not good enough. > How to compress signal so it can be presented within few hundred pixels on > the screen? If possible algorithm should be quite fast as I need to update > several traces (tens) and display them few times per second.The usual methods are based on estimates of the second derivative. I first saw this problem in taking data to be sent to a plotter based on stepper motors, where each step was written to a tape, and displaying it on a vector CRT display with limited memory. One I did once, to be as simple as possible to write, was to calculate over the set of points the absolute value of the second difference. Then find the points, possibly interpolated, that divide the area under the curve into equal intervals. It is a few DO loops in Fortran over the arrays. -- glen






