ConvertWithMoss icon indicating copy to clipboard operation
ConvertWithMoss copied to clipboard

DecentSampler dsbundles

Open BrokenGravityMusic opened this issue 9 months ago • 4 comments

Feature Suggestion.

I've recently used your immensely useful tool to convert 70 Sample-packs from "Samples From Mars", from Kontakt into DecentSampler.

ConvertWithMoss makes either dslibraries or dspresets. I prefer the latter. But using dspresets makes a messy file listing in the file browser, since it shows all the sample-subfolders also. image

To fix this, i convert them to "dsbundles" and now they look pretty:

image

The conversion is as simple as:

  • Rename the category folder to .dsbundle (ie Bass.dsbundle)
  • add a DSLibraryInfo.xml inside the .dsbundle folder

the xml file contains:

<?xml version="1.0" encoding="UTF-8"?>
<DecentSamplerLibraryInfo name="Bass"/>

Where "Bass" i just the folder name in my case. And thats it.

I've created a python script to do this locally, after conversion, but i think it would be cool for everybody to have this ability, which is why i write this. Maybe as an option under DecentSampler Preset Output Format. "[x] Make Preset Bundles (.dsbundle)".

Heres the script for reference:

import os
# run from the root of your converted stuff. Ie, the "output" dir from ConvertWithMoss

dryrun = 1  # Set to 0 to make changes to the filesystem

def create_ds_library_info_xml(dir_name):
    xml_content = f'''<?xml version="1.0" encoding="UTF-8"?>
<DecentSamplerLibraryInfo name="{dir_name}"/>'''
    return xml_content

def process_directory(directory):
    print(f"Checking directory: {directory}")
    for root, dirs, files in os.walk(directory, topdown=True):
        # Skip .dsbundle directories
        dirs[:] = [d for d in dirs if not d.endswith('.dsbundle')]
        
        has_dspreset = any(file.endswith('.dspreset') for file in files)
        has_dslibrary_info_xml = 'DSLibraryInfo.xml' in files

        if has_dslibrary_info_xml:
            print(f"Found DSLibraryInfo.xml in {root}, stopping further search in this directory.")
            dirs[:] = []  # Stop delving deeper into this directory
        elif has_dspreset:
            new_xml_path = os.path.join(root, 'DSLibraryInfo.xml')
            new_xml_content = create_ds_library_info_xml(os.path.basename(root))
            new_dir_name = f"{root}.dsbundle"
            
            if dryrun:
                print(f"+ Would create {new_xml_path}")
                print(f"+ Would rename {root} to {new_dir_name}")
            else:
                with open(new_xml_path, 'w') as f:
                    f.write(new_xml_content)
                os.rename(root, new_dir_name)
                print(f"+ Created {new_xml_path} and renamed {root} to {new_dir_name}")
                
            dirs[:] = []  # Stop delving deeper into this branch

if __name__ == "__main__":
    base_directory = '.' # Change this to the path you want to search
    process_directory(base_directory)

I've only tried converting these "Samples From Mars" libraries, so forgive my ignorance if the fix isn't as straightforward as I currently think. :)

BrokenGravityMusic avatar May 14 '24 06:05 BrokenGravityMusic