Unlimited Drum Randomizer#955
Conversation
|
Hey thanks for the PR! I'm slightly concerned about performance impacts if someone tries to use this while a song is playing, since the 25 item limit exists to prevent hiccups in audio rendering. While this PR is better designed and removes the need for the file name array, I think the worst case execution could slow down audio rendering. Some of our users seem to keep multiple hundreds of samples in the same folder so that case needs to be handled Before merging I'd like sanity checks on the max number of files to read. One approach would be a max of say 50 files, and then cheating a bit by starting the next randomization reads from the current sample instead of the first file in the dir alternatively you might be able to call the audio routine from here in the case of a long loop, but it's better to avoid that if possible since it makes audio execution more difficult to trace Thanks! |
sapphire-arches
left a comment
There was a problem hiding this comment.
Thanks for the contribution! A few style nits, but this looks like a nice improvement overall.
I tried it with a few hundred sample files, and a number of tracks playing. I turned the volume of the drumset down to only hear the other tracks, and randomized the complete kit. Although it took about a second to randomize, I could not hear any dropouts of the other tracks in this time (TBH, I have no Idea how this can work, but it does). What happens if you have a few thousand files in each samples directory? Good question!
This is not trivial... because if one were to use only the filename (that is currently stored with the sample), one would have to search the directory for that file entry next time round, which is exactly the operation making the whole thing slow. So one would have to remember the directory offset somewhere (where?) and then go to that offset directly using the low-level fs functions... I will look into it.
I agree that the code is confusing enough as it is... |
|
Ya store the pointer to the SD location, not finding the name again |
|
Disregard my performance comments - the sd dma complete interrupt calls the audio rendering so this shouldn't interfere Sample streaming should be fine too with the calls to load enqueued clusters |
|
Ok, that explains some things (including why the randomizing gets slower when tracks are playing). I will look into your and boib's suggestions during the weekend, and mark the PR as draft until then. Cheers, |
|
OK:
From my standpoint this seems suitable for release. I would be willing to revisit this at a later stage if people discover bugs or lots of people think the performance is too bad |
sapphire-arches
left a comment
There was a problem hiding this comment.
A couple of other small tweaks and this is probably good to merge. Thanks again!
|
LGTM now, nice work! |
Please test!
Drum randomizer now does not have a limit on number of files to randomize, and is more efficient by pulling code outside of loops.
Also, SHIFT+(random pad) now randomizes ALL non-muted kit rows.
It uses "Reservoir Sampling with k=1" for randomly choosing from a previously unknown number of files in the directory without a second pass. This gets rid of the need to allocate a list of N filenames for choosing from N files.