konsumer / beatstep

intercept beatstep and make it work in different ways
20 stars 3 forks source link

Presets #10

Open konsumer opened 1 year ago

konsumer commented 1 year ago

I never got getPresets working, and setPresets needs some testing. This would help linux people a lot, since there is no way for them to work with presets.

In addition to getPresets working at all, I need to test both to make sure they basically work, as this is an area I did not do enough experimentation with.

juxibuz commented 1 year ago

Thanks for looking into this after such a while. I'm starting to understand the code and sysex messages now, so I'll be trying things out when I get the chance.

konsumer commented 1 year ago

On my Intel Mac, I ran "Sysex Librarian" and then Arturia's Midi Control Center, and hit "Sync" which I think is the equiv of sending a preset, in my program.

Sysex librarian has a nice browser for the messages, which look like this:

F0 7E 00 06 02 00 20 6B 02 00 06 00 03 00 02 01 F7 - Universal Non-Real Time
F0 7E 00 06 02 00 20 6B 02 00 06 00 03 00 02 01 F7 - Universal Non-Real Time

F0 00 20 6B 7F 42 02 00 52 00 3C F7 - Arturia

The first 2 message I think put it in "sync mode" and then there are many more like the 12 byte Arturia message, that set things.

My guess is that setPresets probly works ok (in my code, it does essentially what the sysex file shows, but needs more testing) but not getPresets (currently it doesn't do anything.)

Here is the sysex for sending a preset to the device (setPreset), the format is just the bytes, so you can help analyze, if you like: Beatstep-sync.syx.zip

Here is the sysex from "Recall From" which I think is the equivalent of getPreset: Beatstep "Recall From" (get preset).syx.zip

Here is the JSON (when you choose "Export" in MIDI Manager) which should help us verify it is sending what we think it is, and you should be able to use it with my program: Default.beatstep.zip

konsumer commented 1 year ago

@juxibuz I started working on a C++ CLI program to do presets & firmware & LEDs. I am a bit slower with C++, but I think I have the basic parts to work it out (CLI arg-parsing, basic send/receive sysex, etc.) I will probably end up wrapping the BeatStep class from that with NAPI for the node-module, since the current native node stuff in C is really flakey and old (uses gyp, etc) but should get you a nice & small CLI program even before that. If you are good with C, I could use help to speed up the process, but if not, that's fine.

Currently, it seems to send sysex fine, but not receive it, so looking up presets from device is not currently doable. I also discovered a nice console view in Arturia's program, which clearly shows in/out messages, so that might help with the actual bytes, but I still think something might be wrong with how I am using rtmidi.

juxibuz commented 1 year ago

@konsumer I don't really know any programming language that well, but my idea was to reverse the setPresets code.

In the post at untergeek.de I read:

To find out about the actual value for this parameter, you can send a request string:

F0 00 20 6B 7F 42 01 00 pp cc F7

The BeatStep will answer with a Sysex string in the format mentioned above. AFAIK you’ll have to wait for the BeatStep to respond before sending the next request, or the poor thing will be rather confused and ignore some messages.

I still didn't have time to sit down and try it in js, but in pseudo code I would do something like

# get pad presets
for i = 0 to 15 {
  cc = 0x70 + i
  for pp = 1 to 6 {
    send sysex "F0 00 20 6B 7F 42 01 00 pp cc F7"
    wait for sysex string
    parse sysex string for values PP CC VV
    append values to .beatstep file in format " 'CC_PP': VV, "
  }
}

and go through every set of controllers on the Beatstep. Do you think that would be a reasonable approach?

konsumer commented 1 year ago

Yeh, that is essentially what this library does. I think I have the code worked out, it's basically just translating it to C++ I am a bit slow with, but now I have basic set/get and am working on the JSON part, so it should be done, soon.

If you want to play with my rudimentary beginnings, clone beatstep-cli, and compile it (instructions in README.)

beatstep set 0x52 0x00 0x01
beatstep get 0x52 0x00

It can do other things too:

beatstep --help
Use sysex to control BeatStep
Usage: ./build/beatstep [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit

Subcommands:
  list                        List available MIDI devices
  load                        Load a .beatstep preset file on device
  save                        Save a .beatstep preset file from device
  update                      Install a .led firmware file on device
  color                       Change color of an LED
  fw                          Get the firmware version on the device
  get                         Get a param-value
  set                         Set a param-value

update, save, and load are still WIP, though.

Even before it's finished, you could use this to set or get any values you want (by reading the preset.)

Here is an example snippet of a preset:

{
{ "device", "BeatStep" },
{ "112_1", 9 },
{ "112_2", 65 },
{ "112_3", 44 },
{ "112_4", 0 }
}

which translates to

beatstep set 112 1 9
beatstep set 112 2 65
beatstep set 112 3 44
beatstep set 112 4 0

And you can do the opposite to read your beatstep's values:

beatstep get 112 1
beatstep get 112 2
beatstep get 112 3
beatstep get 112 4
konsumer commented 1 year ago

Actually, those examples don't work, so I don't think 112 is right, which is maybe part of my prob with format of the JSON.

This works though:

beatstep get 0x52 0x00

or same thing with decimals:

beatstep get 82 0
konsumer commented 1 year ago

Ok, I think it's all working. There are even automated releases

konsumer commented 1 year ago

@juxibuz If you could test that project out on your setup, it would be helpful.

juxibuz commented 1 year ago

@konsumer thanks, I'll have time next week