Hydrogen is a software drum machine and pattern editor.

While it can export and play through MIDI, which is enough to play through my SR-16, it is not clear how one could record patterns and songs from Hydrogen.

As Hydrogen is much more comfortable for editing I'd like to explore the idea of using the SysEx MIDI extensions of the device in order to save patterns and songs into it.

Originally, I was thinking in converting the Hydrogen XML into sysex MIDI commands, however, after looking at the source code of the exporters to MIDI and Lilypond, it seems much easier to iterate over the in-memory song model.

Day 1

  • Spent on a different Hackweek project
  • Bought MIDI USB Adapter

Day 2

  • Spent on a different Hackweek project
  • Received MIDI USB Adapter

Day 3

Sending Pattern data from the SR-16

(from manual)

  • The source SR-16 should be in User Pattern mode and stopped. Connect the source SR-16 MIDI out to the destination SR-16 MIDI in.
  • Select the Pattern to be copied.
  • Press and hold the COPY button, and keep holding it down until step (5). The display says COPY TO PATT.
  • Do not enter any destination Pattern number—just press PLAY to send the data out over MIDI. The display says PATT OUT MIDI. The source SR-16's Pattern will end up in the receiving SR-16's currently selected Pattern location.

Testing it out

  • Change to pattern 6 in user mode

    amidi --port=hw:1,0,0 -r pat.syx
    139 bytes read
    
  • Change to pattern 7 in user mode

    amidi --port=hw:1,0,0 -s pat.syx
    

Restore works. It goes in the current selected pattern.

Interpreting the received data

    00000000  f0 00 00 0e 05 05 00 02  6e 00 36 40 07 10 00 21  |........n.6@...!|
    00000010  0c 20 29 1b 6c 36 59 00  6e 20 40 1c 0c 2b 02 4a  |. ).l6Y.n @..+.J|
    00000020  60 70 31 1d 36 05 15 41  60 62 58 14 56 07 03 55  |`p1.6..A`bX.V..U|
    00000030  07 30 21 2c 0e 06 15 41  25 30 38 18 4e 5b 02 0a  |.0!,...A%08.N[..|
    00000040  60 70 31 2c 0a 2b 03 41  6a 43 58 18 76 0f 7c 01  |`p1,.+.AjCX.v.|.|
    00000050  60 6a 58 10 56 07 03 09  6b 30 21 28 0a 29 03 40  |`jX.V...k0!(.).@|
    00000060  67 30 31 2c 0e 07 13 55  77 30 21 2c 0e 06 15 41  |g01,...Uw0!,...A|
    00000070  25 30 38 10 4e 5b 02 4e  40 51 48 1c 36 07 35 41  |%08.N[.N@QH.6.5A|
    00000080  6a 77 58 16 16 0f 78 78  00 13 f7                 |jwX...xx...|
    0000008b
  • SysEx Header f0 00 00 0e 05
  • Code for Copy Pattern, Drum or song 05
  • 00 02 6e 000000xxB x: MSB of number of unpacked bytes of data after header 0xxxxxxyB y: LSB of number of unpacked bytes of data after header 0yyyyyyyB if y_0, then x=x+1
  • Copy mode (pattern, in this case) 00
  • Data, packed as 8 MIDI bytes per 7 data bytes
  • Here should be a 0, for proper operation, but it is not
  • F7 (EOX)

  • Can't figure the number of unpacked bytes. I should have 16 blocks of 8 bytes (128) which should pack 16x7 bytes = 119 6e is 110 -> 1101110, but if I add the 0x2 of the next significant part I already get 101101110 -> 366 So definitely I am not getting it right

Day 4

  • Managed to unpack data

    // unpack data
    uint64_t block = 0;
    uint64_t block_decoded = 0;
    
    while (!is.eof()) {
        is.read((char*)&block, sizeof(uint64_t));
        block_decoded = block;
        // shift the most significant 64-k blocks to the right
        for (int k=7; k <= 49; k=k+7) {
            uint64_t mask = (((uint64_t)1 << k) - (uint64_t)1);
            block_decoded = ((block_decoded >> 1) & ~mask) | (block_decoded & mask);
        }
        cout << "enc: " << block << endl << "dec: " << block_decoded << endl;
        // now for each block:
        for (int i=0; i < 7; i++) {
            char byte = (block_decoded >> 8*i) & 0xFF;
            cout << bitset<8>(byte) << endl;
        }
        cout << endl;
    }
    
  • Unfortunately, still stuck with the data length encoding I should see 128 bytes (16 blocks) packaed -> 112 unpacked bytes But I am seeing a completely different number

Looking for hackers with the skills:

drums midi music qt qt5

This project is part of:

Hack Week 19


Comments

Be the first to comment!

Similar Projects

Make Ruqola Rocket.Chat client useable / submit to openSUSE Tumbleweed by zbenjamin

Update: Ruqola ('zypper in ruqola') is now in T...


Properly package Quick Event orienteering management software by LPechacek

It ain't rocket science, it ain't thrilling, it...


Advanced online payment app for desktop by MDoucha

There are mobile payment apps which allow you t...