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

replaygain: Assorted refactoring #4851

Merged
merged 6 commits into from
Jul 23, 2023

Conversation

wisp3rwind
Copy link
Member

I'm trying to revive my work on improved parallelization (in particular for replaygain, cf. #3893). A while ago, I've been exploring an alternative approach to the the elaborate async approach of #3893 using beets's pipeline threads + an additional pool of worker threads for CPU intense computation. In this way, no intrusive refactoring of beets' pipeline is required and the resulting code feels easier to understand.

This PR is preparatory work for the new approach, which is however quite independent from the actual rewrite of parallelization; and could be merged already.

Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good from here! I just encountered a couple of extremely tiny suggestions.

beetsplug/replaygain.py Outdated Show resolved Hide resolved
beetsplug/replaygain.py Show resolved Hide resolved
beetsplug/replaygain.py Show resolved Hide resolved
beetsplug/replaygain.py Show resolved Hide resolved
Copy link
Contributor

@ybnd ybnd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much to add to @sampsyo's comments in terms of the refactor itself.

Ran beet replaygain with the command, ffmpeg and gstreamer backends (I could not get audiotools installed for some reason)

Confirmed that all of the track/album gain calculations and write operations remain identical compared to the master branch.

Found a tiny typo with album gain in ffmpeg, see below.

beetsplug/replaygain.py Outdated Show resolved Hide resolved
@wisp3rwind wisp3rwind force-pushed the pr_rg_refactor_2 branch 2 times, most recently from d2c90d9 to fd770ae Compare July 22, 2023 09:54
to check for an optional ThreadPool. Seems more idiomatic and readable.
doesn't seem to be very useful to log the _list of items_ here
...album gains. This is in preparation for parallelizing the track
analysis, and computing the album values in the plugin's "main thread"
once all items are done.
now that we have the `track_results` upfront, some simplifications are
possible
This is a preparation for moving the Gst calculation to multiprocessing
worker threads. Passing only the file paths to the worker threads instead of
synchronizing the entire `Item`s (i.e. minimizing the data that is
shared between the processes) hopefully helps to prevent any issues with
this approach.
…ests

by adding files which are not completely silent, thus hitting a different
code path in some calculations

The sample files were generated using
> sox -n whitenoise.flac synth 00:00:02 whitenoise
> ffmpeg -i whitenoise.flac whitenoise.opus
> ffmpeg -i whitenoise.flac whitenoise.mp3
@wisp3rwind
Copy link
Member Author

Thanks for the feedback! This should be good to go now: I've added a version of the ffmpeg tests with non-silent files (turns out there's SoX which makes it really easy to generate audio files with some synthesized sounds) and addressed all of your comments.

@wisp3rwind wisp3rwind merged commit 87cd387 into beetbox:master Jul 23, 2023
14 checks passed
@wisp3rwind wisp3rwind deleted the pr_rg_refactor_2 branch July 23, 2023 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants