PC message to CC3 127 / Sysex conversion

Hi there

Me again. I hope somehow you can help me out with these scriptlets.
I would like to migrate some BOME Midi Translator presets directly to Gig Performer as scriptlets. I would need the following translators:

  1. Scriptlet to translate any Program Change message on CH 16 which is sent by the electronic organ to a CC3 message with the value 127. (PC 1 → CC3 127 on midi Ch. 1 / PC 2 → CC3 127 on midi Ch. 1, etc.). Then I would use CC3 127 on midi Ch. 1 to trigger a Next Song Part message within GP.

  2. Scriptlet to translate the Sysex message “F0 43 70 78 44 13 00 10 01 F7” to CC9 with the value 127 on midi ch 1 (drum button for Prev Song Part with the same idea as described in 1).

  3. Scriptlet to translate the Sysex message “F0 43 70 70 40 45 7F F7” to CC 65 with value 127 on ch. 1. This is a Foot Switch message: ON

  4. Scriptlet to translate the Sysex message “F0 43 70 70 40 45 00 F7” to CC 65 with value 0 on ch. 1. This is a Foot Switch message: OFF

  5. Scriptlet to translate the Sysex message “F0 43 70 70 40 47 7F F7” to CC 66 with value 127 on ch. 1. This is a Knee Lever message: ON

  6. Scriptlet to translate the Sysex message “F0 43 70 70 40 47 00 F7” to CC 66 with value 0 on ch. 1. This is a Knee Lever message: OFF

  7. Scriptlet to translate the Sysex message “F0 43 70 78 44 14 05 12 7F F7” to CC 67 with value 127 on ch. 1. This is a Sustain pedal message: ON

  8. Scriptlet to translate the Sysex message “F0 43 70 78 44 14 05 12 00 F7” to CC 67 with value 127 on ch. 1. This is a Sustain pedal message: OFF

I use a Mac Studio M2 with GP 5.1.1, Bome Translator, Divisimate 2.0.6 and mainly Spitfire Audio BBCSO Pro

Thank you so much for helping me out.
I apologize if the topic is covered in other threads.

mvc82

Regarding your SysEx translation scriptlet requests. Are you truly wanting each of these as an individual ‘modular’ scriptlet so that you can choose only the ones you want in any given midi chain, or would you want all of these at the same time in most if not all instances?

If you’re always going to use all of them (which I think is what essentially would happen with rules in BOME), I would approach it as a single scriptlet with a single On SysexEvent callback, then implement a select statement to handle each of these cases. If you’re always going to use all or most of these in a given rackspace, building them as multiple scriptlets and pulling each one into its own block is going to get very messy, bloated and confusing in your rackspace view.

X

As these are instrument specific then you should consider adding the translation script into the gigscript file or the Include “$rig$” file.

I think that because you are using PC messages then the only place you can acheive this is in the gig/$rig$ files.

Hello X
Thanks for your reply!
I think best would be an all-in-one scriptlet with the lever translations (CC65 to CC67) and one scriptlet for the CC3 and CC9 messages. This would be as you described and how I use it with BOME at this point.

1 Like

Hi Spav
Thank you! I didn’t know about this. I should have a look at it!
Cheers!

Set up an alias in Rig Manager called Yamaha_Organ and associate it with the MIDI input from the organ.

image

In a new blank gig file, copy the following code into the Rig Script file and it should do what you need. Use the global MIDI monitor to see the data, or add a MIDI In (Yamaha_Organ) block to the wiring view with a MIDI Monitor on the output.

/**
 * This script is only loaded when a Yamaha whatever organ is used.
 * The translation must be done before before the Rig Manager.
 */

const YAMAHA_ID : Integer = 0x43
const HASH_1 : Integer = 1849408    // Rollup of 70 70 40
const HASH_2 : Integer = 1850436    // Rollup of 70 78 44
const HASH_3 : Integer = 2565       // Rollup of 14 05
const HASH_4 : Integer = 2432       // Rollup of 13 00

const FOOT : Integer = 0x45         // Control ID
const KNEE : Integer = 0x47         // Control ID
const SUSTAIN : Integer = 0x12      // Control ID
const PREVIOUS : Integer = 0x10     // Control ID

const CC_SUS : Integer = 64         // MIDI Sustain is normaly 64
const CC_FOOT : Integer = 65
const CC_KNEE : Integer = 66
const CC_PREV : Integer = 9
const CC_NEXT : Integer = 3

var Yamaha_Organ : MidiInDevice

//Called when a program change message is received
On ProgramChangeEvent(m : ProgramChangeMessage) From Yamaha_Organ
    If GetChannel(m) == 16 Then
        InjectMidiEventViaRigManager(Yamaha_Organ, MakeControlChangeMessage(CC_NEXT,127))
    End
End

//Called when a MIDI System Exclusive (sysex) message is received
On SysexEvent(s : SysexMessage) From Yamaha_Organ
    var hash : Integer
    var length : Integer
    var cntl : Integer
    
    // Check for correct sysex message
    If SM_GetValue(s,1) == YAMAHA_ID Then
        hash = SM_GetValues(s,2,4)
            
        Select
            hash == HASH_1 Do
                length = SM_Length(s)
                cntl = SM_GetValue(s,length-3)
                if cntl == FOOT Then
                    InjectMidiEventViaRigManager(Yamaha_Organ, MakeControlChangeMessage(CC_FOOT,SM_GetValue(s,length-2)))

                Elsif cntl == KNEE Then
                    InjectMidiEventViaRigManager(Yamaha_Organ, MakeControlChangeMessage(CC_KNEE,SM_GetValue(s,length-2)))
                End
            
            hash == HASH_2 Do
                hash = SM_GetValues(s,5,6) 
                if hash == HASH_3 Then
                    length = SM_Length(s)
                    cntl = SM_GetValue(s,length-3)
                    If cntl == SUSTAIN Then
                        InjectMidiEventViaRigManager(Yamaha_Organ, MakeControlChangeMessage(CC_SUS,SM_GetValue(s,length-2)))
                    End
                    
                Elsif hash == HASH_4 Then
                    length = SM_Length(s)
                    cntl = SM_GetValue(s,length-3)
                    if cntl == PREVIOUS And SM_GetValue(s,length-2) == 1 Then
                        InjectMidiEventViaRigManager(Yamaha_Organ, MakeControlChangeMessage(CC_PREV,127))
                    End
                End    
        End
    End
End

Initialization
    Print("Adding Yamaha Organ Support")
End

@spav

Hmm I wonder if hashing short strings as you did is really faster than just doing a string compare. Did you do a time comparison?

Steve Caldwell

Ohh — this remember me the Gig GPScript I made for a Yamaha Electone user who never gave any feedback :

Dear all
I really apologise for this inconvenience and for having forgotten about testing the script provided by David-san.
I will pn some more details about what happened at the time.

About the script provided by Spav: Thank you so much! I could compile it but with the testing something went wrong. The descibed input still sends Sysex data. I have to find out why. I will have access to the d-deck on monday morning and i will do a short vid. Maybe I have done a mistake somewhere.
I will also try the part of David-san’s scriptlet with the lever inputs. As soon as I can again work on my ELS-02X, I will test the bank select part also, which brings very interesting options.

Cheers mvc82

You don’t need to, I suppose the GOScript provided by @Spav does the job for you.

The above is probably the part you need to focus on.

Hi
It did the job perfectly
Re 2020
I said
Thanks for help, the midi in block worked a treat, not tried script yet
Cheers

Hello

I did a short video. But it still sends sysex data. PC sends nothing.

Thank you for your suggestions!

Can you upload your gig file?

Morning Mood_core-version_inst1_script.gig (2.6 MB)
Thanks!