hydrogen drumkits for composite sampler

Composite is will be a software application/system for real-time, in-performance sequencing, sampling, and looping. …” [Composite web site]. It comes with a LV2 plugin (called composite sampler) that allows to use its drumkits in zynjacku (“zynjacku is a nunchaku weapon for JACK audio synthesis. …” [zynjacku web site]), which means that you can use the sounds alone without running the whole sequencer. The drumkits are compatible to the ones used by hydrogen (“Hydrogen is an advanced drum machine for GNU/Linux. …” [hydrogen web site]).

The composite sampler documentation says that one needs to put the drumkits (or symlinks) into the according path and adjust the default.xml file in the composite presets (see manual). Then it is possible to change through the drumkits with MIDI program change messages. I thought an automated way of preparing this setup would be useful, so I wrote the following python script. Feel free to use/alter it, no guarantee is given for anything. Comments are welcome.


Generates symlinks in the composite drumkit path that point 
to the hydrogen drumkits. Creates an according xml-file with 
all drumkits with GMkit as the first entry.
__author__ = "https://linuxaudiolive.wordpress.com"

from glob import glob
from os import system, path

xmlstart = "<?xml version=\"1.0\"?>\n\
<T:tritium xmlns:T=\"http://gabe.is-a-geek.org/tritium/xml/1/\">\n\
\t<T:presets>\n\\t\t<T:bank coarse=\"0\" fine=\"0\">"
xmlend = "\t\t</T:bank>\n\\t</T:presets>\n\</T:tritium>"

hydrogenDrumkitPath = "/usr/share/hydrogen/data/drumkits/"
compositeDrumkitPath = path.expanduser("~/.composite/data/drumkits/")
newDefaultFilename = "newDefault.xml"

def makeDrumkitSymlinks(hydrogenPath, compositePath):
    """Puts symlinks for all entries in hydrogenPath into compositePath"""
    print "Creating symlinks..."
    names = glob(hydrogenPath+"*")
    for n in names:
        system("ln -s '"+n+"' '"+compositePath+n.split("/")[-1]+"'")

def drumKitField(name, MIDIdevice):
    """Returns the complete xml-entry for one drumkit"""
    drumKitString = "\t\t\t<T:program>\n"
    drumKitString += "\t\t\t\t<T:midi_number>" 
    drumKitString += str(MIDIdevice) 
    drumKitString += "</T:midi_number>\n"
    drumKitString += "\t\t\t\t<T:resource>tritium:drumkits/"
    drumKitString += name
    drumKitString += "</T:resource>\n\t\t\t</T:program>"
    return drumKitString

if __name__ == '__main__':
    if path.exists(newDefaultFilename):
        print "The file '",newDefaultFilename,"' already exists."
        print "Not deleting anything."
        print "Aborting!"
        #uncomment the following to create the symlinks
        #makeDrumkitSymlinks(hydrogenDrumkitPath, compositeDrumkitPath)
        print "Creating new default file."
        drumkitnames = glob(compositeDrumkitPath+"*")
        f = open(newDefaultFilename,'w')
        f.write(drumKitField("GMkit",0)) #the default entry
        counter = 1
        for kit in drumkitnames:
            name = kit.split("/")[-1]
            if name!="GMkit": #default entry is already the first
                f.write(drumKitField(name, counter))
        print "Done. Now copy",newDefaultFilename,
        print "to your .composite/data/presets/default.xml"

1 Response to “hydrogen drumkits for composite sampler”

  1. 1 update on composite sampler | linux audio live Trackback on May 6, 2014 at 3:17 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: