Tuesday, April 3, 2012

Hydrogen drumkit creator script


Some time ago we (the Hydrogen team) launched the first edition of the 'Hydrogen Spring Drumkit Contest'.
The goal of this contest is to encourage the Hydrogen users to contribute new drumkits.

The goal of the 'Hydrogen drumkit creator' script is to make it easier to make these drumkits.



Although creating a new multilayered drumkit isnt all that complicated it can be quite time consuming:

  1. setup your mic
  2. record your instruments (at different velocity's)
  3. cut out and normalize the good parts (using Audacity for example)
  4. import and organize all your samples into H2 one by one
  5. set the velocity ranges
  6. test and export your drumkit


Setting up your mic and recording the samples will probably take up most of you time but it's rather hard to skip this stage ;-)
However, importing and organising the samples you have recorded can be really tedious and time consuming too.  Luckally this can be automated :

Inspired by a perl script written by Freqrush I started writing my own 'H2 drumkit creator'.  I did this for several reasons :

  1. the perl script doesnt handle multilayerd drumkits
  2. it doesnt really create a .h2drumkit file, but only a drumkit.xml file (the 'descriptor' of the drumkit)
  3. it doesnt auto-set the layer min/max velocity levels
  4. it doesnt allow you to assign an instrument to a specific position in the kit 
  5. I have no experience at coding in Perl :-P
  6. I wanted to make a universal tool (Linux / OSX / Windows) to reach as many possible drumkit contributors as possible (currently only for Linux)


How it works : 


Step1 : File names
To be able to use this script you still need to record your sounds first, so step 1-3 remain the same.


Once you start to save the individual hits you do however need to make sure that you name your samples according to this naming scheme :
InstrumentID-LayerID instrument name.wav   (or .flac)
Note the dash between InstrumentID and LayerID and the space behind the LayerID

An example :
Say you have recorded a 'Ludwig kick' at 4 different velocity levels and you want your kick to be instrument nr 2 in the drumkit.
In this examlpe you will need to use the following names for the 4 files :
  • 2-1 ludwig kick.wav   (lowest velocity recording)
  • 2-2 ludwig kick.wav   (mid-low velocity recording)
  • 2-3 ludwig kick.wav   (mid-hi velocity recoding)
  • 2-4 ludwig kick.wav   (max velocity recording)

For one of your toms you might have only 2 samples, and you want the tom to be instrument 5 of the kit :
  • 5-1 tom1.wav
  • 5-2 tom1.wav

Step 2 : Action !
Place all of your sample files into a directory, open a terminal window, cd into the dir where the script is located and run the script.  The script only takes 1 argument and that is the name of the dir where your sample files are located:
./createH2kit.py ~/temp/my drumkit
The script will ask you for some basic info about the kit :

Please enter the drumkit name: My new drumkit
Please enter the name of the author: thijs
Please enter any extra info you want to add: hydrogen rocks !
Please enter the drumkit license type: CC
(Note that you can still change this info once you import the kit in Hydrogen.)


If all goes well you will see this in your terminal window:
Kit info :
Drumset name      : My new drumkit
Author name       : thijs
Info              : hydrogen rocks !
License           : CC
Drumkit Path      : /home/thijs/temp/my drumkit/
Instruments found : 2
.wav files found  : 6
.flac files found : 0
- - - - - - - - - - - - - - - - - - - -
add instrument 2 : ludwig kick
    add layer 1 (2-1 ludwig kick.wav)
       velocity range : 0.0 - 0.25
    add layer 2 (2-2 ludwig kick.wav)
       velocity range : 0.25 - 0.5
    add layer 3 (2-3 ludwig kick.wav)
       velocity range : 0.5 - 0.75
    add layer 4 (2-4 ludwig kick.wav)
       velocity range : 0.75 - 1.0
- - - - - - - - - - - - - - - - - - - -
add instrument 5 : tom1
    add layer 1 (5-1 tom1.wav)
       velocity range : 0.0 - 0.5
    add layer 2 (5-2 tom1.wav)
       velocity range : 0.5 - 1.0
- - - - - - - - - - - - - - - - - - - -
Your Hydrogen drumkit file is available at /home/thijs/temp/my drumkit/My new drumkit.h2drumkit

... and that's it !


Now open hydrogen and import the kit via 'Instruments - Import library - Local file' browse to your kit directory, select your drumkit and click Install.
Your kit will now be available under User Drumkits in the Sound library


Step 3 : tweak and save
Once you have loaded the kit you will see that the Kick is on instrument position 2 and the Tom on position 5:

The Kick has 4 layers and the min/max velocity of these layers has automatically been set so that all layers have an equal part of the velocity range:


Note that these velocity settings are just a starting point for you to tweak your instrument.


Get the script:
You can download the script here
(don forget to make the script executable after download: chmod +x createH2kit.py )




Some final notes:
This is the first version of this script.  There will be bugs (report bugs as a comment to this blogpost)
The name of the instrument will be derived from the file name of the first sample file (=the low velocity sample).  If you use different names for the other samples (eg 2-1 kick.wav and 2-2 foo.wav) only the name of the first sample will be used.



That's it :-)

I hope you enjoy this little script and feel free to post remaks or bug reports below

UPDATE 25/4/2012 : script version 2 is available here

11 comments:

  1. Tip :
    The GM midi mapping can be found here : http://www.mindwaremusic.com/SoundsetterHelp/scr/GMDrumMap.html
    The Hydrogen midi mapping can be found in the manual : http://www.hydrogen-music.org/hcms/node/5#sect.pattern_editor.drumkit

    thanks for the tip Emanuel Rumpf !

    ReplyDelete
  2. i should have seen this earlier O.O! i have just expend the entire past month making from scartch an AC guitar and a muted AC guitar and they weigth a lot hahahah, 800mb and 300mb :P i was planning to upload it once a get my website running but, as now there is the spring contest :D i will upload it soon ;)
    awesome job!
    greetings from Chile!

    ReplyDelete
  3. Well this script is really very new so it's normal that you found it just now. I had been thinking about this script for some time but just didnt get round to making it.
    Next time i'll be quicker ;-)

    Oh, and good luck with the H2 drumkit contest !

    grtz
    Thijs

    ReplyDelete
  4. The script rocks! :D just made one :) thank you!!

    ReplyDelete
  5. Hi Gabriel, nice to hear that you enjoy the script :-)
    dont forget to submit your kit to the Hydrogen drumkit contest !

    ReplyDelete
  6. i´m improving it :p, because the issue of the loaded samples with sthe same name, but that it will not save both samples, was present :p, so... and also i have to make the songs, i have one ready, but i want to upload everything at once, and there will be 4 drumkits, ac guitar- normal, ac guitar-muted, ac guitar-normal-strums, and one eclectic drumkit of fruits, cans, books, and others :)

    ReplyDelete
  7. Alright, that sounds promising !
    looking forward to hearing your drumkit! i mean kitS ;-)

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
  8. Hi Thijs, Arthur here.

    Have a problem with converting. Scrpit reports an error. Have no idea what i doing wrong.

    "E:\TEST>createH2kit_V5.1.py -i "e:/test/"
    input is path > assuming this dir contains audio files

    Please enter the drumkit info:
    Please enter the drumkit name: Test
    Please enter the name of the author: AL
    Please enter any extra info you want to add:
    Please enter the drumkit license type: c

    filename : 1-0 Kick.wav
    no instr layer supplied
    filename : 1-1 Kick.wav
    filename : 1-10 KickRFRR1_97_127.wav
    filename : 1-11 KickRFRR2_97_127.wav
    filename : 1-12 KickRFRR3_97_127.wav
    filename : 1-3 KickRFRR3_1_32.wav
    filename : 1-4 KickRFRR1_33_64.wav
    filename : 1-5 KickRFRR2_33_64.wav
    filename : 1-6 KickRFRR3_33_64.wav
    filename : 1-7 KickRFRR1_65_96.wav
    filename : 1-8 KickRFRR2_65_96.wav
    filename : 1-9 KickRFRR3_65_96.wav
    filename : 2-1 SnareDynL.wav
    filename : 2-2 SnrDRRR1_65_127.wav
    filename : createH2kit_V5.1.py
    Kit info :
    Drumset name : Test
    Author name : AL
    Info :
    License : c
    Drumkit Path : e:/test/
    Instruments found : 2
    .wav files found : 14
    .flac files found : 0
    .ogg files found : 0
    - - - - - - - - - - - - - - - - - - - -
    add instrument 1 : Kick
    add layer 1 (1-0 Kick.wav)
    velocity range : 0.0 - 0.08
    add layer 2 (1-1 Kick.wav)
    velocity range : 0.08 - 0.17
    add layer 3 (1-3 KickRFRR3_1_32.wav)
    velocity range : 0.17 - 0.25
    add layer 4 (1-4 KickRFRR1_33_64.wav)
    velocity range : 0.25 - 0.33
    add layer 5 (1-5 KickRFRR2_33_64.wav)
    velocity range : 0.33 - 0.42
    add layer 6 (1-6 KickRFRR3_33_64.wav)
    velocity range : 0.42 - 0.5
    add layer 7 (1-7 KickRFRR1_65_96.wav)
    velocity range : 0.5 - 0.58
    add layer 8 (1-8 KickRFRR2_65_96.wav)
    velocity range : 0.58 - 0.67
    add layer 9 (1-9 KickRFRR3_65_96.wav)
    velocity range : 0.67 - 0.75
    add layer 10 (1-10 KickRFRR1_97_127.wav)
    velocity range : 0.75 - 0.83
    add layer 11 (1-11 KickRFRR2_97_127.wav)
    velocity range : 0.83 - 0.92
    add layer 12 (1-12 KickRFRR3_97_127.wav)
    velocity range : 0.92 - 1.0
    - - - - - - - - - - - - - - - - - - - -
    add instrument 2 : SnareDynL
    add layer 1 (2-1 SnareDynL.wav)
    velocity range : 0.0 - 0.5
    add layer 2 (2-2 SnrDRRR1_65_127.wav)
    velocity range : 0.5 - 1.0
    Traceback (most recent call last):
    File "E:\TEST\createH2kit_V5.1.py", line 795, in
    RetValue = main()
    File "E:\TEST\createH2kit_V5.1.py", line 279, in main
    return CreateDrumkit(Input)
    File "E:\TEST\createH2kit_V5.1.py", line 784, in CreateDrumkit
    except IOError as (errno, strerror):
    ValueError: need more than 1 value to unpack"

    Any idea ?
    I am using Python 2.7.8 under Windows 7 from command line.

    Thank you in advice.

    Arthur

    ReplyDelete
    Replies
    1. Hi Arthur

      The script was never tested on windows (i'm a linux geek ;-)
      Looks like the errors you get are caused by the script adding forward slashes to the path (linux style) iso backslashes (Win style)

      I can have a go at making the script OS agnostic, but i'm afraid that wont be easy :-S
      I'll see what i can do but i cant promise anything

      grtz
      Thijs

      Delete
    2. Hi Thijs !

      Thank you very much for the answer.

      So i will try it on Linux. That will be not easy for me :)

      Thanks again for your "diagnostic" ;) and for your script - it will be really great for me in the future.

      Arthur

      Delete