Discussion:
[Audacity-devel] [audacity/audacity] make zoomed in view show evenly-spaced samples (#186)
Steve the Fiddle
2017-04-10 07:20:23 UTC
Permalink
The stem plot reminds me of another option for depicting the wave at high
zoom levels that I thought I might try to implement some rainy day.
That is, to interpolate between samples, not with a piecewise linear curve,
but rather to compute the weighted sum of sinc functions. I understand
that shows the unique band-limited continuous function that fits the given
samples, and is the curve on which new samples will fall if you do a
high-quality resampling to a higher rate.
It's one of those interesting mostly math-y projects that wouldn't upset
large amounts of code.
and a "very nice to have" feature that harks back to the origins of
Audacity as a visualization tool.

Steve
PRL
Hm, I don't think it's antialiasing I want. I tried turning it on and the
lines get significantly blurrier.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/
ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y>
.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292830620>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALI9SfHobw6t9B9wKj-pSR-jmGHVd95jks5ruYmFgaJpZM4MWi4Y>
.
Federico Miyara
2017-04-10 12:28:48 UTC
Permalink
Paul,

I think the stem plot even at high zoom is somewhat confusing, but no
harm done if it is an option (it seems more "natural" to plot the spectrum).

As regards the sinc, yes, it is band-limited, but it is computationaly
costly since you should take a very long sinc tail to ensure no graphic
artifacts. Theoretically, using an N-pixels wide track window, you need
to sum N sincs, but in order that the neglected part of tails do not
affect you need that the sum of N neglected tails be less than a
vertical pixel. If there are M vertical pixels, N*tail should be less
than 2/M, so tail < 2/(N*M).

May be some experimentation reveal this is too conservative, but it is,
a priori, a concern (probably there is some statistical compensation
that reduces the artifacts).

Another possible alternative is to use splines, which are way more
computationally efficient. They are not actually band limited, but this
would be something that a spectrum analysis would detect, not the eye,
and I presume that what we need is an agreable as well as visually
accurate waveform.

Splines do even mimic very well the Gibbs phenomenon close to an abrupt
transition.

As a third alterative, upsampling could be used (and it requires just
recycling code). I think this would show a very accurate plot, and
considering that the amount of signal that fits the window is
comparatively short (less than 2 k samples in most displays), it would
not be computationally prohibitive.

Regards,

Federico
The stem plot reminds me of another option for depicting the wave at high
zoom levels that I thought I might try to implement some rainy day.
That is, to interpolate between samples, not with a piecewise linear curve,
but rather to compute the weighted sum of sinc functions. I understand
that shows the unique band-limited continuous function that fits the given
samples, and is the curve on which new samples will fall if you do a
high-quality resampling to a higher rate.
It's one of those interesting mostly math-y projects that wouldn't upset
large amounts of code.
and a "very nice to have" feature that harks back to the origins of
Audacity as a visualization tool.
Steve
PRL
On Sun, Apr 9, 2017 at 6:43 PM, Brian Armstrong
Hm, I don't think it's antialiasing I want. I tried turning it
on and the
lines get significantly blurrier.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931>>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y>>
.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292830620>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALI9SfHobw6t9B9wKj-pSR-jmGHVd95jks5ruYmFgaJpZM4MWi4Y>.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Chris Cannam
2017-04-10 14:09:34 UTC
Permalink
I experimented with this a bit recently in this fork of this Javascript
audio rendering library: https://github.com/cannam/waves-ui/ (see
src/shapes/waveform.js).

I found that a fixed 8x oversampling of the visible region (plus enough
either side for the sinc tails) using a precomputed windowed sinc kernel
of a few hundred samples was enough to give a good representation for
audible-range signals, given the limited number of vertical pixels
available, without slowing things down all that much even in Javascript.
As you say, you only have to oversample if the user has zoomed in enough
to see it, so there are never all that many points involved. And of
course you could do exactly this using libsamplerate/libresample as
well.

My impression was that it probably isn't worth trying to simulate this
with splines, not least because it's easier to be sure your results make
sense if they arise from oversampling using a standard resampling
filter.

Note that BS1770 for peak detection only specifies 4x oversampling, see
https://techblog.izotope.com/2015/08/24/true-peak-detection/.

It would be very nice to see something like this in Audacity -- one of
the biggest annoyances I have with it is the plainly wrong
representation of interpolated waveforms. I "avoided" this problem in
Sonic Visualiser by making it impossible to zoom in any closer than one
pixel per sample, a decision that I've also since regretted (I'll
probably have to address this there at some point too).


Chris
Post by Federico Miyara
Paul,
I think the stem plot even at high zoom is somewhat confusing, but no
harm done if it is an option (it seems more "natural" to plot the spectrum).
As regards the sinc, yes, it is band-limited, but it is computationaly
costly since you should take a very long sinc tail to ensure no graphic
artifacts. Theoretically, using an N-pixels wide track window, you need
to sum N sincs, but in order that the neglected part of tails do not
affect you need that the sum of N neglected tails be less than a
vertical pixel. If there are M vertical pixels, N*tail should be less
than 2/M, so tail < 2/(N*M).
May be some experimentation reveal this is too conservative, but it is,
a priori, a concern (probably there is some statistical compensation
that reduces the artifacts).
Another possible alternative is to use splines, which are way more
computationally efficient. They are not actually band limited, but this
would be something that a spectrum analysis would detect, not the eye,
and I presume that what we need is an agreable as well as visually
accurate waveform.
Splines do even mimic very well the Gibbs phenomenon close to an abrupt
transition.
As a third alterative, upsampling could be used (and it requires just
recycling code). I think this would show a very accurate plot, and
considering that the amount of signal that fits the window is
comparatively short (less than 2 k samples in most displays), it would
not be computationally prohibitive.
Regards,
Federico
The stem plot reminds me of another option for depicting the wave at high
zoom levels that I thought I might try to implement some rainy day.
That is, to interpolate between samples, not with a piecewise linear curve,
but rather to compute the weighted sum of sinc functions. I understand
that shows the unique band-limited continuous function that fits the given
samples, and is the curve on which new samples will fall if you do a
high-quality resampling to a higher rate.
It's one of those interesting mostly math-y projects that wouldn't upset
large amounts of code.
and a "very nice to have" feature that harks back to the origins of
Audacity as a visualization tool.
Steve
PRL
On Sun, Apr 9, 2017 at 6:43 PM, Brian Armstrong
Hm, I don't think it's antialiasing I want. I tried turning it
on and the
lines get significantly blurrier.

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931>>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y>>
.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292830620>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALI9SfHobw6t9B9wKj-pSR-jmGHVd95jks5ruYmFgaJpZM4MWi4Y>.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Federico Miyara
2017-04-10 21:24:08 UTC
Permalink
Chris,

Thank you for your insight and for sharing your results. Just a note on
BS1770, in that case it is for true peak detection, which allows a
relatively large tolerance since an error of 1 dB is generally
inaudible. But visually it corresponds to 10 %, which is clearly visible
at large zoom.

Using 8x is adequate when, say, there are about N/80 original samples on
the screen, since then each segment will be about 10 pixels long, which
is about the size of a character. But if you try to zoom so much that
there are very few samples, even 8x will present a broken-line aspect.

Taking an average screen 1280 pixels wide, a possible criterion for
dynamic selection of the oversampling factor K could be

K = max(1, 128/S)

Where S is the number of original samples allocated in the track window.

Regards,

Federico
Post by Chris Cannam
I experimented with this a bit recently in this fork of this Javascript
audio rendering library: https://github.com/cannam/waves-ui/ (see
src/shapes/waveform.js).
I found that a fixed 8x oversampling of the visible region (plus enough
either side for the sinc tails) using a precomputed windowed sinc kernel
of a few hundred samples was enough to give a good representation for
audible-range signals, given the limited number of vertical pixels
available, without slowing things down all that much even in Javascript.
As you say, you only have to oversample if the user has zoomed in enough
to see it, so there are never all that many points involved. And of
course you could do exactly this using libsamplerate/libresample as
well.
My impression was that it probably isn't worth trying to simulate this
with splines, not least because it's easier to be sure your results make
sense if they arise from oversampling using a standard resampling
filter.
Note that BS1770 for peak detection only specifies 4x oversampling, see
https://techblog.izotope.com/2015/08/24/true-peak-detection/.
It would be very nice to see something like this in Audacity -- one of
the biggest annoyances I have with it is the plainly wrong
representation of interpolated waveforms. I "avoided" this problem in
Sonic Visualiser by making it impossible to zoom in any closer than one
pixel per sample, a decision that I've also since regretted (I'll
probably have to address this there at some point too).
Chris
Post by Federico Miyara
Paul,
I think the stem plot even at high zoom is somewhat confusing, but no
harm done if it is an option (it seems more "natural" to plot the spectrum).
As regards the sinc, yes, it is band-limited, but it is computationaly
costly since you should take a very long sinc tail to ensure no graphic
artifacts. Theoretically, using an N-pixels wide track window, you need
to sum N sincs, but in order that the neglected part of tails do not
affect you need that the sum of N neglected tails be less than a
vertical pixel. If there are M vertical pixels, N*tail should be less
than 2/M, so tail < 2/(N*M).
May be some experimentation reveal this is too conservative, but it is,
a priori, a concern (probably there is some statistical compensation
that reduces the artifacts).
Another possible alternative is to use splines, which are way more
computationally efficient. They are not actually band limited, but this
would be something that a spectrum analysis would detect, not the eye,
and I presume that what we need is an agreable as well as visually
accurate waveform.
Splines do even mimic very well the Gibbs phenomenon close to an abrupt
transition.
As a third alterative, upsampling could be used (and it requires just
recycling code). I think this would show a very accurate plot, and
considering that the amount of signal that fits the window is
comparatively short (less than 2 k samples in most displays), it would
not be computationally prohibitive.
Regards,
Federico
The stem plot reminds me of another option for depicting the wave at high
zoom levels that I thought I might try to implement some rainy day.
That is, to interpolate between samples, not with a piecewise linear curve,
but rather to compute the weighted sum of sinc functions. I understand
that shows the unique band-limited continuous function that fits the given
samples, and is the curve on which new samples will fall if you do a
high-quality resampling to a higher rate.
It's one of those interesting mostly math-y projects that wouldn't upset
large amounts of code.
and a "very nice to have" feature that harks back to the origins of
Audacity as a visualization tool.
Steve
PRL
On Sun, Apr 9, 2017 at 6:43 PM, Brian Armstrong
Hm, I don't think it's antialiasing I want. I tried turning it
on and the
lines get significantly blurrier.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931
<https://github.com/audacity/audacity/pull/186#issuecomment-292818931>>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y
<https://github.com/notifications/unsubscribe-auth/ALITYWcVI3x7ImGpsqOkFlwCLb6k4vQHks5ruV8NgaJpZM4MWi4Y>>
.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/audacity/audacity/pull/186#issuecomment-292830620>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALI9SfHobw6t9B9wKj-pSR-jmGHVd95jks5ruYmFgaJpZM4MWi4Y>.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
audacity-devel mailing list
https://lists.sourceforge.net/lists/listinfo/audacity-devel
Loading...