-
-
Notifications
You must be signed in to change notification settings - Fork 994
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
Add sample thumbnails #7366
base: master
Are you sure you want to change the base?
Add sample thumbnails #7366
Conversation
… refactor some loops
Factory samples would like to have a word with you |
As long as the factory sample paths remain unique for each sample (which I believe they do) then it won't break. I'm mostly concerned with when the sample name is just the filename. (also changed the PR description a bit) |
You've got some code that is commented out, is it supposed to stay or to be erased? Since this change is also visual, could you provide a screenshot of what it looks like? |
@zachtyll Oh right they were supposed to be removed but I forgot to. Will make a commit to clear them out Here are some pictures and videos (left is the old code and right is the new code): slicert.mp4samples2.mp4The sample in this video is 11 minutes long: automation.mp4 |
I see a number of style issues/some code that can be cleaned up. Instead of making a huge review for style, do I have permission to go in and fix it myself? I want to focus on the implementation here (the design/visualization code), not too much of the style, but its an important problem here still. Edit: But if you would prefer a review, then I don't mind. |
@sakertooth Feel free to push commits to adjust the style. For the implementation adjustments, I think it can benefit from a bit of discussion/reviewing before commits are pushed |
This is an attempt in adding sample thumbnails in order to speed up rendering (mainly) in the song editor and other places (currently being Audio File Processor, SlicerT and the Automation editor).
Brief summary of the PR and explanation of names:
SampleThumbnailBit
: a thumbnail sample, here being a struct whose fields are max min and rms.SampleThumbnail
: a thumbnail.SampleThumbnailList
: a vector of thumbnails. All thumbnails in this list come from the same sample.SharedSampleThumbnailList
: shared_ptr to a thumbnail list, used to track the usage of the thumbnail list.SampleThumbnailListManager
: class to manage the operations of creating, deleting, selecting and rendering thumbnails/thumbnail lists.SampleThumbnailVisualizeParameters
: contains information for rendering. See comments inSampleThumbnail.h
for documentation.SAMPLE_THUMBNAIL_LIST_MAP
is anstd::map
with keys being the sample file path and the value being aSharedSampleThumbnailList
. All thumbnail lists are stored here. This variable exists as a private static member ofSampleThumbnailListManager
.This implementation assumes that a unique sample has a unique full file path. If this is violated or the file path is just the file name, the implementation may break completely.
When a sample is loaded into the song editor, the constructor of
SampleThumbnailListManager
looks intoSAMPLE_THUMBNAIL_LIST_MAP
to find the thumbnail list for this sample. If the sample is new, it proceeds to generate a new thumbnail list for this sample and insert it into the map. In other places like AFP, SlicerT, when loading a preexisting preset or project, the thumbnail lists might not be generated until you open the plugin GUI, which triggers the paintEvents.The
SampleThumbnailListManager
class contains a non-static memberlist
of typeSharedSampleThumbnailList
. The class attaches itself to classes that uses thumbnails, such as SampleClipView. This ensures that thumbnail list that is being used will have a use_count() of 2 or more (one in thestd::map
and others in the objects) . A use_count() of 1 indicates the sample is out of use and the thumbnail list will be deleted. Cleaning operations is done when loading new samples or closing LMMS.This implementation uses powers of 32 for thumbnail size with the largest being 32768, and minimum being 1.