MiniDexed icon indicating copy to clipboard operation
MiniDexed copied to clipboard

Sys ex control

Open BenZonneveld opened this issue 3 years ago • 20 comments

Several improvement in sysex control. All instances get a fixed sysex channel as not to cause any conflicts.

BenZonneveld avatar Jun 19 '22 19:06 BenZonneveld

Hi @BenZonneveld, thank you very much. I am a bit puzzled by the build error. Can you build it locally for the Raspberry Pi 4?

probonopd avatar Jun 20 '22 17:06 probonopd

Replace my build.sh with the original. For testing I removed the extracting of the arm compiler and rebuilds of circle

BenZonneveld avatar Jun 20 '22 18:06 BenZonneveld

Can you please change that in https://github.com/BenZonneveld/MiniDexed/tree/SysExControl? Then the build in this Pull Request should "magically" start working. Thanks!

probonopd avatar Jun 20 '22 18:06 probonopd

Something weird is going on with the git submodules:

Cloning into '/home/runner/work/MiniDexed/MiniDexed/CMSIS_5'...
Cloning into '/home/runner/work/MiniDexed/MiniDexed/Synth_Dexed'...
Cloning into '/home/runner/work/MiniDexed/MiniDexed/circle-stdlib'...
Submodule path 'CMSIS_5': checked out '8a64562247485159a090ec4a01588f44f8d10311'
fatal: remote error: upload-pack: not our ref a3a696b003ef76f79dbd91ff8188a[12](https://github.com/probonopd/MiniDexed/runs/6975070899?check_suite_focus=true#step:3:13)3b74e5e17
fatal: Fetched in submodule path 'Synth_Dexed', but it did not contain a3a696b003ef76f79dbd91ff8188a123b74e5e17. Direct fetching of that commit failed.
Error: Process completed with exit code 128.

probonopd avatar Jun 20 '22 22:06 probonopd

@BenZonneveld would this fix https://github.com/asb2m10/dexed/discussions/352?

probonopd avatar Jun 20 '22 23:06 probonopd

No...actually I removed the sending of sysex voices and only send the sysex on a patch request sysex, as it should be. A program change shouldn't send a sysex with a voice dump.

BenZonneveld avatar Jun 21 '22 00:06 BenZonneveld

No...actually I removed the sending of sysex voices and only send the sysex on a patch request sysex, as it should be. A program change shouldn't send a sysex with a voice dump.

I had added this because then the editors immediately display the correct data. Maybe this should be made configurable via minidexed.ini, because I found it a great help so far.

dcoredump avatar Jun 21 '22 05:06 dcoredump

Yes, we should definitely not remove this feature!

probonopd avatar Jun 28 '22 17:06 probonopd

No...actually I removed the sending of sysex voices and only send the sysex on a patch request sysex, as it should be. A program change shouldn't send a sysex with a voice dump.

I had added this because then the editors immediately display the correct data. Maybe this should be made configurable via minidexed.ini, because I found it a great help so far.

Still, the normal way for an editor would be to do a patch request. It is what my MiniDexed master does: receive pgm change, request voice data.

If you always send the sysex voicedump it would mean I can never use MiniDexed with for example my DX7

BenZonneveld avatar Jul 05 '22 13:07 BenZonneveld

It could be made configurable.

probonopd avatar Jul 05 '22 16:07 probonopd

And there we have a building branch with my patches.

BenZonneveld avatar Jul 05 '22 21:07 BenZonneveld

It builds! :+1:

Can you describe what exactly this PR fixes/improves?

I figured out:

  • More MIDI commands received via serial are interpreted
  • More MIDI control change messages are sent via serial
  • Convert NL+CR to NL on serial output

probonopd avatar Jul 06 '22 22:07 probonopd

Would https://github.com/probonopd/MiniDexed/pull/311 do the same job instead of having a private copy of Circle's serial.h? If possible I would like to avoid a private copy of that file, in order not to have the burden of maintenance. It looks to me like #311 also converts NL+CR to NL on serial output, but without the need for a patched serial.h.

probonopd avatar Jul 17 '22 18:07 probonopd

I had added this because then the editors immediately display the correct data. Maybe this should be made configurable via minidexed.ini, because I found it a great help so far.

...or we ask editors (yes I am thinking of you, Dexed) to send a patch request, like @BenZonneveld is saying? This is probably the way it should be done in MIDI.

probonopd avatar Jul 17 '22 18:07 probonopd

I tracked down the reason that my M-Audio Oxygen49 quits working after a program change to: receiving the sysex data afterwards, so +1 for configuration parameter, at least!

My keyboard probably shouldn't crash, but, well, it does. Probably something to do with its own memory dump feature.

psethwick avatar Sep 22 '22 20:09 psethwick

The description I wish this PR would have had to begin with:

Add support for

  • Configuration dumps
  • Bank name requests
  • Improved alignment between SysEx messages and tone generators
  • Enhanced debugging and logging
  • Streamlined SysEx voice dumping and parameter updates

1. Changes to src/mididevice.cpp

a. Updated SysEx Handling

The HandleSystemExclusive method in CMIDIDevice now includes:

  • Instance ID Validation: Ensures that the SysEx messages align with the correct tone generator (TG) by comparing the SysEx instance ID (pMessage[2] & 0x0F) with the TG (nTG). A warning is logged if they do not match:
    uint8_t instanceID = pMessage[2] & 0xF;
    if (instanceID != nTG) {
        printf("WARNING instanceID and nTG do not match!!!!!\n");
    }
    
  • Support for New SysEx Requests:
    • Config Request: When SysEx ID 0x30 is received, it triggers a configuration dump.
    • Bank Name Request: When SysEx ID 0x40 is received, it sends the name of the current bank.

b. New SysEx Responses

  • Configuration Request (SendSystemExclusiveConfig):

    • Assembles a detailed configuration dump containing various tone generator parameters, including:
      • Compressor enable/disable.
      • Reverb settings (size, damp, low-pass, diffusion, level).
      • Volume, pan, master tune, cutoff, resonance, reverb send, pitch bend, portamento mode, time, etc.
    • Sends this configuration as a SysEx message to all MIDI devices.
  • Bank Name Request (SendBankName):

    • Constructs a SysEx message containing the bank name for a specific tone generator.
    • Extracts the bank name using:
      m_pSynthesizer->GetSysExFileLoader()->GetBankName(...)
      
    • Sends the message to all MIDI interfaces.
  • Voice Dump (SendSystemExclusiveVoice):

    • Refactored to use the instance ID instead of the TG directly, ensuring better alignment with SysEx messages.

2. Changes to src/mididevice.h

a. New SysEx-Related Methods

The following methods were added to the CMIDIDevice class:

  • SendSystemExclusiveConfig(): Sends a SysEx message containing the configuration of the synthesizer and tone generators.
  • SendBankName(uint8_t nTG): Sends the name of the current bank via SysEx.
  • Updated SendSystemExclusiveVoice to take only nVoice and nTG as parameters (removes nCable).

3. Changes to src/minidexed.cpp

a. SysEx Enhancements

  • Updated SysEx-related methods to ensure consistency with the new instance ID approach:
    • The getSysExVoiceDump method now sets the instance ID (nTG) in the SysEx message instead of the MIDI channel:
      dest[2] = nTG; // Sub-status and MIDI channel/Instance ID
      
  • Improved parameter change handling to trigger corresponding SysEx updates:
    • For example, when the volume is updated, a MIDI Control Change (CC) message is sent:
      m_SerialMIDI.SendCtrlChange(MIDI_CC_VOLUME, m_nVolume[nTG], nTG);
      

4. New MIDI Control Codes

Defined in src/mididevice.h:

  • Added new constants for MIDI Control Change (CC) messages:
    #define MIDI_CC_BANK_SELECT_MSB    0
    #define MIDI_CC_MODULATION         1
    #define MIDI_CC_VOLUME             7
    #define MIDI_CC_PAN_POSITION       10
    #define MIDI_CC_BANK_SELECT_LSB    32
    #define MIDI_CC_REVERB_LEVEL       91
    #define MIDI_CC_DETUNE_LEVEL       94
    

5. Logging and Debugging

  • Enhanced debugging information for SysEx handling:
    • Logs the return value from the SysEx handler:
      LOGDBG("SYSEX handler return value: %d", sysex_return);
      
    • Logs the details of the SysEx messages being processed, including the TG and instance ID.

probonopd avatar Apr 22 '25 18:04 probonopd

@diyelectromusic @soyersoyer what do you think about the proposed changes?

probonopd avatar Apr 22 '25 18:04 probonopd

I think we need to isolate the key changes in this PR and show them applied to the latest code base - I'm struggling to see what depends on what... I mean what is with that serial.h for example? And all those build changes.

Also, I don't think we should be changing how the SysEx device number is interpreted without some discussion. We don't really have the concept in MiniDexed atm. I think we map it over to TG MIDI channel (rightly or wrongly).

Kevin

diyelectromusic avatar Apr 22 '25 19:04 diyelectromusic

Added new constants for MIDI Control Change (CC) messages:

These have since been implemented.

Is there any documentation on SysEX somewhere?

soyersoyer avatar Apr 22 '25 20:04 soyersoyer

Is there any documentation on SysEX somewhere?

You mean, like, in the DX7 manual?

probonopd avatar Apr 22 '25 23:04 probonopd