Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi exported file has an offset of +24 on Midi notes #411

Closed
jduemes opened this issue Sep 26, 2016 · 17 comments
Closed

Midi exported file has an offset of +24 on Midi notes #411

jduemes opened this issue Sep 26, 2016 · 17 comments

Comments

@jduemes
Copy link

jduemes commented Sep 26, 2016

(Note: message edited by @trebmuh for better readability using the so-called "Insert code" tag)

Hi Folks,

I manually edited the GMKit drumkit.xml file adding midi notes to the instruments. This way I connect (via Jack audio connection Kit) Hydrogen to a keyboard(1) and - as expected - Hydrogen sends the notes to the keyboard.

Now, if I export my song to a Midi file, open this Midi file with Drumstick MIDI Player connected to that same keyboard, it plays very different notes.

I did a test connecting Drumstick MIDI Player to QMidiRoute and QMidiRoute to the keyboard. Then changing the "Note Offset" option on QMidiRoute to -24. Surprise !!! It plays exactly the same notes as using Hydrogen. As I understand the Hydrogen Midi export is buggy.

(1) I used a keyboard but the same happens if I use another midi synthetizer like Qsynth (a Fluydsynth GUI).

$ hydrogen --version
0.9.7-'2a5e0cb'
$ uname -a
Linux myhostname 4.7.4-1-ARCH #1 SMP PREEMPT Thu Sep 15 15:24:29 CEST 2016 x86_64 GNU/Linux

Can somebody confirm this or point me an option or workaround to get a correct midi file ?

Cheers,
Jeff

@mauser
Copy link
Member

mauser commented Oct 3, 2016

Hi!

I've tried to reproduce the problem, but i couldn't find any issues with the export. Attached is a screenshot of a minimal example, just a fresh song with GMKit and the result in Bitwig. The same note is shown in Hydrogen and Bitwig.

Nevertheless, the hydrogen midi out / midi export handling can be confusing: #307 has more informations about possible problems. Does your problem persist with every song (even new songs)`or is it affecting only some songs?

hydromidiexport

@elpescado
Copy link
Contributor

I vaguely remember encountering the same problem. As far as I remember, MIDI defines note 60 to middle C, but does not define "middle C", so different software use C3, C4 and C5 as "middle C" (C3 being most common), and I'm not sure whether Hydrogen is consistent with this.

@elpescado
Copy link
Contributor

Hydrogen seems to offset notes by 36 and 60 in different places (60 - 36 = 24 which explains two octave difference):

, __midi_out_note( 36 + id )

int key = (pNote->get_octave() +3 ) * 12 + pNote->get_key() + pNote->get_instrument()->get_midi_out_note() -60;

key = (pNote->get_octave() +3 ) * 12 + pNote->get_key() + pNote->get_instrument()->get_midi_out_note() - 60;

@mauser
Copy link
Member

mauser commented Oct 30, 2016

Hi,

in addition, the alsa midi driver sends out 'note on' midi messages for the first instrument with midi note 36 but 'note off' messages with mide note 60. What a mess..

@mauser
Copy link
Member

mauser commented Nov 22, 2016

@jduemes (or everyone else who can reproduce the behaviour): Can you provide me with a midi file and the corresponding song file which shows the incorrect behaviour?

I've tried to export different songs yesterday, but in all cases, the note values which are displayed in hydrogen matched the note values in the exported midi file. I've checked the note values in the midi file by looking at the output of the program midicsv.

@jduemes
Copy link
Author

jduemes commented Dec 5, 2016

(Note: message edited by @trebmuh to fix a code typo in the link)

Hi Mauser,

your are right about "the note values which are displayed in hydrogen matched the note values in the exported midi file". I see the same behavior here. The thing is, H2 does not "speaks" those values when talking to a sequencer. That sequencer can be the Fluydsynth software or a external hardware like a music keyboard.
songs.zip

@mauser
Copy link
Member

mauser commented Dec 7, 2016

Hi Jeff!

Thanks, this makes it clear. Then the problem can be boiled down to the lines which @elpescado has identified earlier. So the core of the problem is in the code of hydrogen's midi drivers.

Thanks for reporting the issue and sending the example song!

@jduemes
Copy link
Author

jduemes commented Dec 11, 2016

Hi Sebastian,

I'm happy to help. Is there a chance to link this issue to the release announcement of the version where this problem is already resolved ?

@jduemes
Copy link
Author

jduemes commented Apr 20, 2017

#450

@thijz
Copy link
Member

thijz commented Mar 5, 2018

@trebmuh
Copy link
Member

trebmuh commented Mar 23, 2018

Hi @jduemes : reading at this thread, it looks to me that @elpescado and @mauser fixed the issue with #450 .

Could you please re-test it with the beta release 1.0.0-beta1 and report back here confirming us that the issue is gone?

Thanks.

@JosteinAndersen
Copy link

JosteinAndersen commented Apr 20, 2018

Hi folks,

There are also offset problems for sending MIDI note number out when hitting a drum or just playing: This makes problems when using Hydrogen as a drum sequencer and triggering a drum sound elsewhere via MIDI. I write this here because I guess that this is related to this thread and I just compiled and tested the 1.0.0-beta1. When enabling MIDI out and hitting a note, the offsets are +232 or -24 depending on which note Hydrogen tries to send out. Here is a list containing the note numbers Hydrogen believes to send and what actually is sent (hydrogen=actual):

0=232
.
23=255
24=0
.
127=103

So if Hydrogen believes it sends MIDI note 22, then it actually sends MIDI note 254 and if Hydrogen believes it sends MIDI note 25, it sends MIDI note 1.

I can't say I find the solution for this and hope that someone skilled in C++ resolves it. :-)

EDIT: I do after browsing the GIT repo and the issue system, see that my posting was not needed, sorry.

Jostein

@elpescado
Copy link
Contributor

I hope this is fixed by me in #666.

@jduemes
Copy link
Author

jduemes commented Jan 10, 2019

Using my Achlinux laptops I just tested Hydrogen 1.0.0.beta1.r3322.538eaeb9-1 using the GMRockKit as it comes with H2.
With a new project (Ctrl+N) without any adjustments but setting the channel of the instrument (Kick) to something different than 'off'.

My test setup is easy to reproduce.
Using Jack:

  • connect Hydrogen-midi TX port to Midi-Through capture port;
  • Watch the Midi-Through playback port with "aseqdump -p <X:Y>"
    Obs: to get X:Y of the Midi-Through playback port use "aseqdump -l"

Using only alsa:

  • Watch the Hydrogen midi out port with "aseqdump -p $(aseqdump -l | grep Hydrogen | cut -c-6)"

Using jack or alsa, Hydrogen still sends out the notes 2 octaves under what is defined for the instrument. An offset off -24. In my test with Kick which has the default note 36 aseqdump shows note 12.

$ aseqdump -p 14:0
Waiting for data. Press Ctrl+C to end.
Source  Event                  Ch  Data
  0:1   Port subscribed        129:0 -> 131:0
 14:0   Note off                8, note 12, velocity 0
 14:0   Note on                8, note 12, velocity 78
 14:0   Note off                8, note 12, velocity 0

Another observation: When SENDING midi notes to Hydrogen, GMRockKit seems to be very GM compatible, so to speak, and Hydrogen seems to work as expected. What I mean is, sending note 39 plays Hand Clap, sending 44 plays Hat Pedal and so on.

I hope this is fixed by me in #666.

Hi @jduemes : reading at this thread, it looks to me that @elpescado and @mauser fixed the issue with #450 .

Could you please re-test it with the beta release 1.0.0-beta1 and report back here confirming us that the issue is gone?

@elpescado
Copy link
Contributor

Hi,

Unfortunately, fix #666 hasn't made its way to 1.0.0 branch yet.

Could you please test it on my branch? I'd appreciate if you post test results in that thread, as I need some help with testing.

@JosteinAndersen
Copy link

JosteinAndersen commented Jan 11, 2019

Oh, sorry, I thought I reported it months ago! I have tested it and it works great as far as I can see. Well done and thank you very much for doing it.

I wonder something: Why does one hit on an instrument trigger three events? It's a note off-on-off sequence. A note off first will make for example cymbals sound unnatural in for example Superior Drummer or other players that strive to behave like real drummers. A note on event only should be sufficient in most cases.

@mauser
Copy link
Member

mauser commented Mar 19, 2020

Hi,

the fix from @elpescado is since march 2019 part of our master branch and this problem seems to be solved from me (tested for alsa with aseqdump as shown above), so i think that the issue can be closed.

If someone still experiences problems, just comment here and the issue will be re-opened.

@mauser mauser closed this as completed Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants