Sysex dumps, updating controls - what am I missing?

Thanks for the shout out @martin !!

I’m still quite enthusiastic about it, actually, despite not having tinkered with my E1 (or any of my gear) in the past X months. I’m slowly starting to move past some life “complications” and fear of being a bad coder so that I can start fiddling around with the Lua extensions. Seeing that our initial conversations may have influenced you to incorporated Lua, lights a tiny flame under my ass! I will try to dedicate at least an hour a week moving forward. So much yet to learn on this incredible piece of gear you guys have created, Thank you for all your work, brother!

2 Likes

Hi everybody, I am a bit late to this party/thread, but I think I read through most of it and can feel the pain. As the author of the open source sysex librarian KnobKraft Orm I had to tackle exactly the same problems, less that for most synths I do (currently) not extract the individual parameter data.

Years of development of MIDI software can’t be summarized in such a small box, but let me state: I appreciate the Lua possibilities with the Electra, because I believe the JSON version is too limited. Many MIDI librarians try to do a data driven approach, but in the end the code-driven approach is more future proof. In the Orm, I don’t use Lua but Python, but the principle is the same.

I might be missing something, but I wanted to look at the Lua @oldgearguy wrote for the Alesis Micron, but when downloading the preset from the App I always only get the epr file, not the Lua file. Surely I don’t have to pipe it through the E1 to get it?

What I have done in the past is to use BCR2000, but as this is a pain to program and the software editors for it are stone age, I decided to write generators that generate the BCR2000’s peculiar little programming language. Works brilliantly.

Now I want to move my editing to the E1, but have hit multiple roadblocks, the sysex dump parsing being the most important one - I simply want to keep editing from a patch, and when I switch the patch I want the UI to jump and show all current data points. So it seems the Lua onResponse handler is what I need, and it should populate the parameter map.

I appreciate I can read the json epr file (or the instrument file, but those seem to be bit neglected right now as Martin himself wrote above) and get a list of all the parameters a synth offers - to be useful for the librarian I need to be able to decode a dump and show the individual parameters’ values. It would be even better if I could reuse the parsing logic of the preset that populates the parameter map. I can run Lua from within Python, which runs from within a C++/JUCE app :wink:

I would also be willing to try to rewrite my generator for the BCR2000 editor templates for the E1.

Is there an example preset that shows how to do the 100% Lua parsing way?

1 Like

attached is the current LUA (more or less) for the Micron.
Also attached is the more-or-less correct sysex specs so you can see what I was basing it on.

So far, I’ve been doing it 100% with LUA. I’m going to start a thread on a new preset using LUA and JSON to create two (hopefully) equivalent presets for the same piece of gear (tc 2290).

Given the craziness in the Micron data, I don’t think it is doable just using JSON.

Alesis Micron.zip (583.5 KB)

2 Likes

Here is a preset and LUA script for the Microwave – UI is just virtual controls that reflect the parameterMap (but don’t send data) and everything is controlled from LUA. I’m close to having a full editor for the Matrix 6 too, with mod matrix update capability, all in 200 lines of LUA.

Waldorf Microwave.zip (13.6 KB)

EDIT: I’m attaching the Matrix 6 preset too – it’s been a while since I used or worked on it so I’m not sure what state it is exactly in but it’s definitely WIP.

Oberheim Matrix 6.zip (7.4 KB)

6 Likes

Pretty fantastic Presets!

1 Like

Impressive! That is a lot more code than I would have initially expected. But pretty straightforward and even if I haven’t done a Lua script for the Electra before I think I get what it is doing. Thank you!

Interesting! How does the PT_VIRTUAL parameter type work?

1 Like

PT_VIRTUAL parameter does no track any specific MIDI message type. Instead, it just keeps a value. And this value that can be accessed/set with Lua functions.

Recently, I spend some time parsing the undocumented Sysex patch dump of a nord drum 3p and thought I’d chime in here to share a real-world example.

As mentioned in this thread before, there are various ways how different manufacturers are storing data in their Sysex dump. The following steps are meant to give an idea how to approach deciphering an unknown patch dump. The concrete parsing might be different depending on the device.

Most values that we are collecting from a Sysex patch dump are numbers. So before diving into the details of the parsing process, I believe it is a good idea to recap how numbers are composed in a binary bit stream.
When a number is transmitted in more than one byte, you can use Electra’s parameterBitPosition to put the bits back together. When parsing unknown data, it is very helpful to understand how this calculation works.

Let’s start with a simple example. Assumed we have an 8-bit parameter that is transmitted in the first four bits of two bytes %0000yyyy %0000yyyy. Given, we are receiving a Hex value 03 in the first byte and 0A in the second byte, which is 3 in decimal and 111 in binary, or 10 and 1010 respectively. The result of putting the binary back together is really just putting them back together. So 111 and 1010 will be 1111010. But we can also calculate the decimal value from the details we have so far.
To put a parameter part to its corresponding bit position, we just need to multiply it by 2 power ‘length of first parameter part’ and add the multiplied result to the first value. In our example, the first parameter part has a length of 4. 2 power 4 equals 16.
So we can calculate the result like this: 3 * 16 + 10 = 58

Sometimes we also see other types of numbers, like signed, two’s complement or even fractions.
To put a (simple) float back together, we first follow the same steps mentioned above. Then we divide the result by 2 power ‘position of decimal point’.
The nord drum is storing its Delay Rate parameter as float in 16-bits, distributed across 3 bytes. The lowest value as complete binary looks like this 1010101010101001. That is 43689 as decimal. The decimal point position is 15 (from the right). 2 power 15 equals 32768.
Which means we can calculate the float like this : 43689 / 32768 = 1.333 (The correct binary notation would be 1.010101010101001)

Besides a power of 2 table as reference, personally I also find it helpful to have a list at hand to quickly look up the highest number that can be stored in a certain bit length:
2-bit: 3
3-bit: 7
4-bit: 15
5-bit: 31
6-bit: 63
7-bit: 127

Now, let’s dive into the actual parsing workflow.
For the most part, I’m using snoize’s MIDI monitor and the text editor BBEdit, but there are several other tools which get the job done as well.

Note: the following steps only work when the patch dump sends out the current parameter position. Otherwise, it might be necessary to save the patch on the device between sending the patch dumps.

  1. Make sure MIDI monitor is running and listening to incoming MIDI messages

  2. Turn a first parameter on the MIDI device to its minimal position

  3. Trigger a patch dump

  4. Turn the same parameter to its maximum position

  5. Trigger a second patch dump

  6. Create two empty documents in BBedit

  7. In MIDI monitor, double click the first patch response message and copy its content into the first created BBEdit document

  8. Copy the second patch dump message into the second BBEdit document

  9. In the first BBEdit document press [cmd] + [F] to open the Find window

  10. Put a space character into the Find field and a line return \n into the Replace field. Click Replace All. → This will convert all space characters between the Hex values into line returns, meaning that the line number is now equal to the bytes offset

  11. Repeat the same process in BBEdit’s second document

  12. In BBEdit’s sidebar, select both documents and right-click to open the context menu. Select Compare from the context menu.

  13. In the resulting window, you should see the Hex values (bytes) highlighted that are different in the patch dump messages.

  14. If the data type is unknown, I would continue with converting these highlighted Hex values into binary and decimal and check if that already makes sense. To do so, I’m using the following online calculator

  15. When looking at the binary, I’m mostly interested in detecting the boundaries of the parameter. So I’m looking for the highest and lowest bit that are changing. If the parameter is distributed across more than one byte, I would also try putting the binary parts together in the aforementioned calculator and see if the result corresponds with the number of parameter values.

Example:
Many parameters on the nord drum range from 0 to 50. And most of them are distributed across two bytes.
Here is the binary of a parameter at its minimal and maximum position:

00: 0000 0010110
50: 1100 1010110

From the bit length list above, we know that a parameter ranging from 0 to 50 needs at least 6 bits.
In the example, we can see that the first five bits of the second byte (reading from right to right) did not change. The length of the remaining bits is 6. If we remove the unchanged bits and put only these remaining 6 bits of the maximum parameter position again into the online calculator, we will be happy to see that 110010 is the binary representation of 50.

The only missing piece of the puzzle is the byte number required in Electra’s JSON file. All we need to calculate that is the line number of the changed bytes in the BBEdit document and the length of the Sysex response header, defined in the JSON file.
The Sysex response header for the nord drum 3p looks like this:

{
    "responses": [
        {
            "header": [
                "33",
                "7F",
                "1A",
                "08",
                "05",
                "06",
                "00"
             ],

So it has a length of 7 bytes. To complete our calculation, we need to add 2 to the length of the response header. 1 for the unlisted start byte F0 and another 1 because Electra’s byte index is 0 based, but our line numbers in BBEdit start at 1.
Now, we can calculate the byte number by subtracting 9 (the header length + 2 for the start byte and 0 index) from the line number in BBEdit.

With that information, I would move to Electra’s JSON and add it like this:

{
    "type": "sysex",
    "parameterNumber": 1,
    "parameterBitPosition": 2,
    "byte": 41,
    "byteBitPosition": 0,
    "bitWidth": 4
},
{
    "type": "sysex",
    "parameterNumber": 1,
    "parameterBitPosition": 0,
    "byte": 42,
    "byteBitPosition": 5,
    "bitWidth": 2
}

Next, I would load the updated preset into Electra and send the same patch dump messages with the first parameter being at its minimum and maximum position and check if the control is responding correctly.

This is just scratching at the surface, but maybe it helps a bit when starting to parse a Sysex patch dump.

Happy New Year!

5 Likes

Hi @mariankalus,

Thanks for taking time to write all this down. Not only that it explains the general concept but it covers stuff specific to Electra. @Flyweight did quite some work on documenting this in the past too. Both texts provide good foundation for working with electra’s JSON.

I have had some ideas on how to make this more user friendly, but all the suggestions discussed and described here on the forum helped to move it one level up. I used most of the holiday time to build a proof of concept of a visual editor based on those ideas. I must say that I am very happy with that and I’ve already used the tool to reverse engineer DSI Mopho’s patch dumps. With this new tool (that will be part of the app.electra.one), it was easy and actually quite a fun activity.

eg. the blue bits are assigned to the Resonance parameter, and it is actually two nibbles as one nibble is placed at the 0 position of the parameter while the other goes to the 4th position.

The idea is based on having all available preset parameters and patch dump bytes on one screen and being able to link the bits to the parameters by clicking. The patch dump bytes listing is integrated with Electra’s MIDI learn. Therefore twisting the knobs on the synth (or even on Electra) marks the changing bits and give a clear visual indication where and how the parameter value is stored in the patch dump data. Of course this is much inspired by all those howtos and posts from users on the forum. I just wrapped that up to a visual tool.

the green colour marks bits that have changed between individual MIDI learn calls.

There is still stuff to do but I would love to release this some time this week. The JSON text editor works nicely along with this, so it is safe to use even though it is not fully completed.

What I like about that is that it is not only tool to build Electra’s patch dump parsing rules. It actually makes reverse engineering of undocumented sysex implementations possible and easy.

This is taking quite some of my time, so I am not fast in responding to other topics on the forum. I will take care of that once this is out.

7 Likes

Hi @martin, this looks truly amazing!

Just when one thinks Electra can hardly get any better, you’re making it even more incredible! :star_struck:

2 Likes

wow @martin that looks just awesome.

but can you as change a parameter on the synth and then catch the changing bits?

this is useful for synth with remote control or for hidden parameter. like on the yamaha sy22 / tg33 for example. with some secret bits you get full control over the 2 2 operators. while the synths interface only offers a set of predefined settings like piano, bell etc.

anyhow awesome

Hey Marian,

Thanks for sharing this.

Any chance you happened to document the full spec for nd3p dump with parameter byte positions, value ranges, etc. Or was this more of a proof of concept sort of exploration of its dump?..

Hi guy, have you ever actually used a Jazzmutant Lemur - which was killed as a product a few months before iPad hit the market? How about the iOS version that came soon after - and that was recently killed by Lline.com? So I have tried and own both. The short version is that for am musician they offer a novel way of interacting with sound sources, from synths and samplers to plugins. Not exactly what probably was in mind when Electra was born.

Will the Electra ever be able to technically handle the object-oriented mayhem the Lemur offered? And as far as I can tell still offers: just dusted off my Jazzmutant Lemur and while getting the Jazzeditor to work for new patches or changing extant ones represents a hurdle, it appears as capable as ever for controlling MIDI devices (and OSC ones). The differences between the Lemur and an ipad are non-succinctly, but perhaps accurately, touched upon here: JazzMutant Lemur Dead – Did The iPad Kill It, Or Was It Suicide? – Synthtopia

I wonder…

I developed a few editors/patches for the iOS version of the Lemur.
My main disappointment was their lack of significant sysex support for devices.

Oh, and the extremely poor customer service and lack of enthusiasm for fixing bugs. :slight_smile:
I did a TX-802 editor that (IMHO) still gives a very intuitive view of the operators and the envelopes that is hard to duplicate on anything other than a computer.
I also implemented an editor+ for the Roland RSS-10 that added some LFOs and other things that were not in the RSS-10 proper.
However, I could not implement a full surround space path editor since the Lemur didn’t support sysex messages of any decent size.

Now that some drawing/graphics capabilities have been introduced here with the Electra Mk II, there is a promising future of marrying graphics with custom controls with standard controls to create some unique environments.

I just need to either retire or to stop developing presets so I can play with these newer features.

3 Likes

I opt for retiring :wink:

might be sooner than we think. :wink:

1 Like