hydrogen-music / hydrogen

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

Midi: set default MIDI out channel & note #449

Open mendomusic opened 7 years ago

mendomusic commented 7 years ago

Under Pattern Editor Drumkit there is the table with the default incoming MIDI routings by instrument position.

I would like to suggest the following improvement to enable quick set-up of midi routing to external programs:

Since MIDI out channel & MIDI out note are hard-coded in the drumkit XML file, this change would require to recode all drumkit XML. But instead, hydrogen could run the two checks on top when reading the drumkits. Maybe enabled/disabled by a setting.

Unfortunately, I do not understand cpp files.

but some pseudo code would come in here: https://github.com/hydrogen-music/hydrogen/blob/master/src/core/src/basics/instrument.cpp#L250

   if ( __midi_out_channel == -1)
        pInstrument->set_midi_out_channel( node->read_int( "midiOutChannel", 9, true, false ) );
    pInstrument->set_midi_out_note( node->read_int( "midiOutNote", pInstrument->__midi_out_note, true, false ) );
    if ( __midi_out_note == 60)
        MIDI_NOTE = MIDI_NOTE_OF_CURRENT_POSITION
        pInstrument->set_midi_out_note( MIDI_NOTE, pInstrument->__midi_out_note, true, false ) );    

I think this small change would improve the midi setup. Thanks for considering.

mauser commented 7 years ago

Hi!

In general, i'm also thinking that there is the need for a more user-friendly midi handling in hydrogen.

But coming to your use-case, i don't think that re-interpreting the values from the drumkit xml is a good idea. First of all, the value "-1" has a special meaning: "do not output anything". This is sth. of course different to channel 9.. So re-interpreting this value in hydrogen seems to be not a good thing to me. It is questionable if it is a good default value to turn off the midi output by default (by setting the channel to -1), but on the other hand, there are many people who do not use the midi output at all and who want to minimize overhead and turn off the generation of midi out notes. In addition, it is quite easy for people to set their own values - just adjust the channels of your favourite drumkit and save that drumkit.

About your second point: Midi Note 60 "seems" to be the standard note, but if you look at the MIDI table which you referenced in your link, then Midi Note 36 is listed as the first note. (see also http://computermusicresource.com/GM.Percussion.KeyMap.html). The fact that all instruments were mapped to note 60 was a bug and was not intended. If you're building a fresh version of hydrogen from our git repository, you will see that the default song (empty song) is now consistent with the GM Kit note values (those which are set in Hydrogen's own GMKit drumkit). In my opinion this is a good starting point and does not need any re-interpretation.

elpescado commented 7 years ago

Hi, I've been thinking about the same issue lately.

Problem with your solution is that note 60 is a legitimate note value. In General MIDI spec note 60 maps to Hi Bongo drum, so changing this may upset some Cuban musicians:)

Instead, I proposed pull request that assigns default note values when all instruments use the same MIDI note.

thijz commented 6 years ago

related to https://github.com/hydrogen-music/hydrogen/issues/63 https://github.com/hydrogen-music/hydrogen/wiki/MIDI-implementation