SoundFont 2: add option to keep length-mismatched stereo-linked samples as mono#169
Conversation
…sub-folder + sample grouping fix (git-moss#170) SoundFont 2: a length mismatch between two samples a SoundFont links as a stereo pair now declines the merge (they are kept as mono), and the pitch/rate/length mismatch notices are gated behind the log-unsupported-attributes option. Synthstrom Deluge: writing into a SYNTHS/KITS sub-folder now writes the preset there and its samples into a matching sub-folder of the card-root SAMPLES, instead of nesting a SYNTHS/SAMPLES pair inside the chosen folder.
|
I have several examples where the left/right channels have different lengths. I suggest to add this as a destination option (which is off by default). |
…es as mono Some SoundFonts - in particular commercial E-mu banks such as the "Orbit" bank - carry unreliable stereo metadata: samples are flagged as left/right and linked to partners they are not the stereo halves of. compareSampleFormat already declines the merge when two samples differ in pitch or sample rate, but a length mismatch only logged a warning and then merged them anyway, welding two unrelated sounds into the left and right channels of a single stereo sample. Add a "Keep mismatched stereo samples as mono" source option (Sf2KeepMismatchedStereoAsMono, off by default) that treats a length mismatch the same way, keeping the two samples as the separate mono samples they actually are. It is off by default because some banks contain genuine stereo pairs whose left/right channels differ slightly in length, so those keep combining unless the option is enabled. Also gate the pitch / sample-rate / length "do not match" notices behind the existing "Log unused SF2 generators" option, so a normal conversion of a quirky bank is no longer flooded with warnings while the detail is still available on request.
89e0c31 to
b9cbdce
Compare
|
Thanks! Updated per your suggestion: this is now an opt-in "Keep mismatched stereo samples as mono" option, off by default, so banks with genuine different-length stereo pairs keep combining exactly as before — only when it's enabled does a length mismatch keep the two samples separate (matching how a pitch or sample-rate mismatch already behaves). Since the stereo-combining happens while reading the SoundFont ( Verified on the E-mu "Orbit" bank: off (the default) combines the 3 length-mismatched pairs as before; on keeps them as their separate full-length mono samples. Rebased onto current |
Problem
Some SoundFonts — in particular commercial E-mu banks such as the "Orbit" bank — carry unreliable stereo metadata: samples are flagged as left/right and linked (
wSampleLink) to partners they are not actually the stereo halves of. When such a bank is converted,combineToStereotries to weld these "pairs" back together.compareSampleFormatalready declines the merge when the two samples differ in pitch or sample rate, but a length mismatch only logged a warning and then merged them anyway — so two unrelated sounds ended up hard-panned into the left and right channels of a single stereo sample (the shorter one truncating the longer). Converting one such bank also produced a wall of warnings.Change (updated per review)
Per @git-moss's feedback that some banks contain genuine stereo pairs whose left/right channels differ in length, the length-mismatch behaviour is now opt-in and off by default:
Sf2KeepMismatchedStereoAsMono, off by default). When enabled, a length mismatch declines the stereo merge just like a pitch/sample-rate mismatch, so the two samples are kept as the separate mono samples they actually are. Off by default a length-mismatched pair still combines, so genuine different-length stereo pairs are unaffected.Since the stereo-combining happens while reading the SoundFont, the checkbox lives in the SF2 source options (next to "Log unused SF2 generators"); happy to move it if you'd prefer it elsewhere.
Rebased onto current
main. The diff is limited toSf2Detector.java,Sf2DetectorUI.java,Strings.properties, and the changelog / format docs.Verification
Tested against a commercial E-mu "Orbit" SoundFont, converting every preset to WAV:
Sf2KeepMismatchedStereoAsMono=1): those 3 pairs are instead kept as their 6 separate full-length mono samples (+3 files); the channel that was previously truncated keeps its full length.Pitch- and sample-rate-mismatched pairs remain mono in both cases (unchanged).