hydrogen-music / hydrogen

The advanced drum machine for Linux, macOS, and Windows
http://www.hydrogen-music.org
GNU General Public License v2.0
1.03k stars 172 forks source link

Add DrumkitMap class and associated .h2map files #1850

Closed theGreatWhiteShark closed 10 months ago

theGreatWhiteShark commented 11 months ago

First part of implementing #1691

A new class called DrumkitMap was introduced which is the internal representation of a .h2map file. This will map an instrument (using its ID) to a general property (called Type) on a per-drumkit basis. (In the proposal this property was called GID. But I renamed it to (Instrument) Type because I think this is more accessible.)

In #1068 I mentioned to make an exhaustive list of possible Types. This idea was dropped. Instead, arbitrary values can be used and it is the responsibility of a drumkit creator to pick sane values (matching those already provided by us).

The .h2map files are gathered from three different locations (with decreasing priority)

  1. ~/.hydrogen/data/drumkit_maps/KIT_NAME.h2map
  2. A *.h2map file in the drumkit folder itself (default: drumkit.h2map)
  3. /usr/share/hydrogen/data/drumkit_maps/KIT_NAME.h2map

The first map found is used as the main/default drumkit map. If present, the first matching map from the remaining options will be used as a fallback map. Incentive is as follows:

Whenever the user alters the mapping - using the dedicated dialog (below) or a future "wiring dialog" when switching kits or importing patterns - they will be stored in the _drumkitmaps folder in the user data directory. Options 2. and 3. are read-only. 2. is provided by the person creating a kit and 3. is provided by us as part of the installation. The fallback map can be used to restore (or check on) the original mapping. Else this could be pretty easily be lost when toying with configurations/mappings.

The mappings can be altered in either Drumkits > Properties for the current drumkit or right-click > Properties in the Sound Library. This dialog is now tabbed with one dedicated tab for the mapping and another for the license table. Editing is done using an editable combo box. As options of the combo boxes all Type found in drumkits currently loaded in the SoundLibraryDatabase are available sorted by decreasing number of occurrence.

For now just a handful of .h2map files are provided. I will add the others later on. Also, the dialog for switching kits and importing patterns will be done at a later point. I have to address #1849 first.

In addition, the clang format files as well as the language server support was tweaked.