Find referenced sample files ignoring the upper/lower case (#342) - #345
Open
douglas-carmichael wants to merge 1 commit into
Open
Find referenced sample files ignoring the upper/lower case (#342)#345douglas-carmichael wants to merge 1 commit into
douglas-carmichael wants to merge 1 commit into
Conversation
Sampler file systems are case-insensitive and their CD-ROMs store all names in upper case, but a preset may reference them in lower case - or the other way round. On a case-sensitive file system, which is the normal case on Linux, none of those samples could be found: Analyzing: /tmp/Strings/STEREO STRS2.AKP Detected Akai Preset (S5000/S6000). Sample file does not exist: /tmp/Strings/STR SEC.6 -L.wav Add AbstractDetector.findFileIgnoreCase, which returns the exact file if it exists and otherwise looks for a sibling whose name only differs in its case. If there is none either it returns the requested file, so all callers keep reporting a missing file exactly as before. On a case-insensitive file system the exact match always hits, therefore the directory is never even read there. The detectors which built the path themselves now use it: Akai AKP (both the sample lookup, which hard-coded '.wav', and the AKM lookup of its programs, which hard-coded '.AKP'), Akai MESA, Akai MPC (which hard-coded '.WAV', so it failed the other way round) and MPC1000 (whose manual '.wav'/'.WAV' fallback this replaces), FL Studio DirectWave, Teenage Engineering OP-XY and Synclavier Regen. The common search of findFile only tried the file ending in all upper and all lower case, so a mixed case ending or a base name differing in case was still not found; it now falls back to the case-insensitive lookup, which also applies to the recursive search. That covers the Ableton, Deluge, EXS24, Kontakt, Maschine, 1010music, SXT and TX16Wx detectors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #342.
Sampler file systems are case-insensitive and their CD-ROMs store all names in upper case, but a preset may reference them in lower case - or the other way round. On a case-sensitive file system, which is the normal case on Linux, none of those samples are found:
The reporter guessed that other formats are affected as well, and they are - 10 places in 7 format families build the path themselves and then only check
exists (). Two of them fail the other way round, because they hard-code the upper case ending.The fix
AbstractDetector.findFileIgnoreCasereturns the exact file if it exists, otherwise a sibling whose name only differs in its case, otherwise the requested - non-existing - file. That last part keeps every caller reporting a missing file exactly as before, so the change is a drop-in replacement fornew File (folder, name)at each site. On a case-insensitive file system the exact match always hits, so the directory is never even read there.Detectors which built the path themselves:
.wav.AKP.wav.WAV, so it failed on lower case.wav/.WAVfallback, replacedThe common search in
findFileneeded it too:getCaseVariantsonly flips the file ending when it is already all upper or all lower case, so a mixed case ending or a base name differing in case was still not found. It now falls back to the case-insensitive lookup, andfindFileRecursivelyuses it as well. That covers the Ableton, Deluge, EXS24, Kontakt, Maschine, 1010music, SXT and TX16Wx detectors.Tonverk already did this with its own
findTolerantand is unchanged.Verification
macOS is case-insensitive, so the bug cannot reproduce on it. I created a case-sensitive APFS volume and ran everything against both a stock build of
mainand this branch.There was no AKP file to be had here, so I generated one from the offsets in
AkpFile/AkpKeygroupand gave it the sample names from the report. It reproduces the reported output onmain, and on this branch:A full conversion writes both samples. Two more end-to-end cases on the same volume:
mainreports 3 files it could not find, this branch converts all 3.mainreports "The file does not references any samples", this branch finds all 3. This is the casegetCaseVariantscannot handle, since the base name differs too.No regression on a case-insensitive file system: reading SFZ, Deluge, OP-XY, Bitwig and DecentSampler presets and converting them produces byte-identical output on both builds.
One caveat on the test corpus, for whoever repeats this: the brute-force upward search in
findFilehappily finds an identically named sample in a neighbouring test folder and reports success, so each case needs unique sample names to mean anything.