Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make zoomed in view show evenly-spaced samples #186

Closed
wants to merge 6 commits into from

Conversation

@brian-armstrong
Copy link

@brian-armstrong brian-armstrong commented Mar 8, 2017

Hi,

I love Audacity. Awesome stuff 👍

I have been using Audacity to debug my modem library. I was thinking how much I'd love to be able to inspect individual samples as a stem plot, so I took a whack at implementing it.

You'd probably want these changes behind some user preference toggle. I'm more than happy to make those changes, if you do think this would be something you'd want.

Here's a screenshot of what it looks like http://i.imgur.com/Dqe2ds5.png

I've had to change the zoom behavior a little. This looks weird when the horizontal spacing between samples varies, so this locks the zoom in to be a multiple of the project sample rate.

Cheers!

@SteveDaulton
Copy link
Member

@SteveDaulton SteveDaulton commented Mar 8, 2017

Related discussion on Audacity forum: http://forum.audacityteam.org/viewtopic.php?f=28&t=94931
As previously discussed, I like the general idea of having "stem plots" as an option, but restricting zoom levels to integer multiples of pixels per sample, looks broken. Until audio tracks have sub-pixel rendering (or similar), rounding sample positions to pixels is the lesser evil imo. Please feel free to come and discus this on the developer's mailing list (see: http://www.audacityteam.org/community/developers/)

@JamesCrook
Copy link
Contributor

@JamesCrook JamesCrook commented Apr 9, 2017

Love the idea, and I agree with Steve's point that we need sub-pixel resolution for the vertical lines. That shouldn't slow plotting noticeably, because we are drawing fewer lines than in a zoomed out view. May be able to use http://docs.wxwidgets.org/3.1.0/classwx_graphics_context.html for it. I also have fast code for sub pixel resolution based on antigrain library.

The code here is proof of concept, so we will close this one shortly unless it is progressed as described by Steve.

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 9, 2017

Sounds good 👍

Can you help me with what specifically this would need to land? Is it just a matter of enabling Anti-aliasing in WxWidgets?

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 9, 2017

Hm, I don't think it's antialiasing I want. I tried turning it on and the lines get significantly blurrier.

@Paul-Licameli
Copy link
Member

@Paul-Licameli Paul-Licameli commented Apr 10, 2017

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 10, 2017

@Paul-Licameli Although it's true that you could represent the signal in multiple ways, I believe the one I have provided is considered to be canonical within DSP.

For example, the following two pages appear in Richard Lyon's Understanding Digital Signal Processing
http://i.imgur.com/Y1JMH5g.jpg
http://i.imgur.com/T0GVbRB.jpg

On the second page, it explicitly says "Do not be tempted to draw lines between the dots in Figure 1-1(b). For some reason, people ... want to connect the dots with straight lines, or the stairstep lines shown in Figure 1-1(c). Don't fall into this innocent-looking trap."

Or to use another example, we can look at some arbitrarily-chosen plots from Proakis and Manolakis's Digital Signal Processing
http://i.imgur.com/KR8qA9r.jpg
http://i.imgur.com/7kSKGXp.jpg

It seems all of the plots in this book are rendered this way when they contain discrete-time signals. And as far as I know, this stem method is also commonly chosen for DSP plots generated by MATLAB.

I think given the abundance of this particular plot, it would be handy to be able to render this way in Audacity as well, at least as an option :) After all, what is 44.1kHz audio if not discrete samples?

@JamesCrook
Copy link
Contributor

@JamesCrook JamesCrook commented Apr 10, 2017

Can you share a screenshot of the 'blurrier' lines? When anti-aliasing works well the lines ARE blurrier, and the overall effect (from screen distance) is better. Have a look at the ruler lines in the 'zoomable ruler' section of http://wiki.audacityteam.org/wiki/Proposal_TrackPanel_Evolution . Have a look up close, and then from normal distance. Those ruler lines are drawn with anti-aliasing in order to be able to draw them at any spacing. They look evenly spaced and of even width.

+ change engagement for stem plot
@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 16, 2017

@JamesCrook Ok, I've pushed an update with AA turned on. Your explanation makes sense, thanks!

Here's a preview
http://i.imgur.com/SKPAwF7.png
http://i.imgur.com/w8lCH6V.png

@SteveDaulton
Copy link
Member

@SteveDaulton SteveDaulton commented Apr 17, 2017

Unfortunately I'm getting a segmentation fault when zooming in.
Tested with debug build on Linux.
I've not yet had chance to investigate further but will post on devel@ when I have.

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 17, 2017

@SteveDaulton I'm guessing that wxGraphicsContext is not always available. I pushed a change that should skip setting AA if it isn't.

@SteveDaulton
Copy link
Member

@SteveDaulton SteveDaulton commented Apr 17, 2017

I'd just quickly tested with pretty much the same:
if (dc.GetGraphicsContext()) {
and that works.

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Apr 17, 2017

@SteveDaulton Ok, that makes sense. I'm not so familiar with wxWidgets. Just from what I can tell from some googling, it seems that AA won't be an option for OSes without a GraphicsContext then.

If that's a blocker, that may require a fairly substantial amount of work unless @JamesCrook's antigrain code can be used here?

@SteveDaulton
Copy link
Member

@SteveDaulton SteveDaulton commented Apr 20, 2017

I've started a thread to discus this on devel@ mailing list.
https://sourceforge.net/p/audacity/mailman/message/35797568/
Please join the discussion by registering on the mailing list: https://lists.sourceforge.net/lists/listinfo/audacity-devel

@JamesCrook
Copy link
Contributor

@JamesCrook JamesCrook commented Jul 16, 2017

Stem plots are in now, and may not always have even spacing, but that is OK. So I am closing this pull request, which had some work on even spacing too.

@brian-armstrong
Copy link
Author

@brian-armstrong brian-armstrong commented Jul 16, 2017

Thank you all for helping to land this one, and for the thoughtful discussion. I'm really excited that this made it 👍

@Paul-Licameli
Copy link
Member

@Paul-Licameli Paul-Licameli commented Jul 18, 2017

Brian, thank you for this contribution. We wish to credit your contribution in the About Audacity... dialog of the next version, if you have no objections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants