[Help] GPScript Runtime Exception: Invalid sysex: C000


a bit of context first, in order to learn the basics of GP scripts I have created a simple panel with some buttons to send sysex values to my Juno 106 hardware synth in order to remotely change patches . The juno 106 is expecting sysex in the format C0 vv (vv being the patch number value from 0 to 127 / 0x7F)
I have also checked that sending these sysex messages with the Bome SendSX tool is indeed changing patches on the harrdware.
Here is the GP panel, in order to help understand what I am trying to describe with my terrible English :

Here is my question:
I do not understand how to initialize a SysexMessage. I thought that simply assigning it to a string would do the trick as the compilation went right but it gaves me the following error message when I am simply assigning the “C000” string to the sysex variable at runtime :
GPScript Runtime Exception: Invalid sysex: C000

I am pretty sure it is something trivial but I could not figure out yet the mistake I am doing => so I need your help. here is the function script I wrote:

Function EvaluatePatchNumber() Autotype
    decimalValue: integer
    sysex  : SysexMessage
    // Update patch name in the display
    SetWidgetLabel(PATCH_DISPLAY, ToPatchName())  
    // calculate pach decimal value based on teh selected GROUP + BANK + PATCH number   
    decimalValue=groupWeight + (bankWeight - 1) * 8 + (patchWeight - 1)
    Print("Value="+decimalValue+ " | hex="+ToUppercase(IntToHexString(decimalValue)))
   // the folowing line is compiling but gives runtime error
    //SM_ChangeValue(sysex, 1, decimalValue)
    //SendSysexExternal(JUNO106_IN, sysex)

Many thanks in advance for our help or any suggestions.

Cheers, Eric

Well, the error message is correct……C000 is not a valid sysex message

Sysex messages always start with F0 and end with F7
All the bytes in between must have values less than hex 80 (i.e., less than 128)
Hex C0 is not less than 128

I would be curious to see the MIDI implementation chart of this model. Not sure if it is the original one or a newer version of this synth…

Hello DHJ
thanks a lof for your answer.
I understand now… sh!it it means that I won’t be able to use GP to send these values to the Juno 106 unfortunately. :pensive: This is a pity as I mainly purchased GP as I wanted to create some tools to interract with my old good Juno…

It is already a miracle that the Juno is supporting MIDI but as the Roland hardware is suporting these C0xx hexa decimal values via MIDI connection it seems that they are not “real” sysex message but proprietary stuff.

Therfore I have another question while I am here:
Do you know if there is another way then to send any hexa decimal values via MIDI from a GP script please ? (but not as “sysex” then) Thanks

Cheers, Eric

Huh? They sound like regular channel messages to me….why do you think they are Sysex messages?

Why can’t you just use the regular SendNow function? It sounds like you’re just trying to send regular MIDI messages.

In fact I am rather “new” to all these MIDI considerations. Therfore I think I have to dive in the GPScript documentation first.

I see that there is indeed a MakeMidiMessage2 function using 2 bytes as arguments and with the help of either InjectMidiEvent(physicalDeviceName, m) or the InjectMidiEventViaRigManager(rmDeviceAliasName, m ) function I should be able to send these 2 Hexadecimal values to the Juno 106.

Thanks a lot for your suggestions DHJ I think you will solved my problem. :+1:

I am wishing you an excellent end of weekend.

In fact if someone of the GP team is reading this message:
I guess it could greatly impove the scripting developement (especially for newbies like me :wink:) if this kind of error was detected during compile time instead of runtime :

    sysex  : SysexMessage
    sysex="C000" <= this could fail at compile time perhaps

I was typing the next mesage while you sent this one and I hevent seen that I coudl use this SendNow function (thanks)

It does fail at compile time. You can’t assign strings directly to a sysex object. In version 4.5 of Gig Performer, you have to use the SM_CreateSysex function or SM_CreateSysexFromString to create a sysex message

Well, I’m not sure we can handle every possible error that someone could make. It seems to me that it’s reasonable to assume anybody who is working directly with MIDI needs to understand the format of MIDI messages so as to know that a program change message is not a sysex message.

More relevantly, in GP Script, it’s not necessary to know anything about MIDI format if all you’re trying to do is send out program change messages. E.g, in a scriptlet you could just write the following and let GPScript take care of the structure of the MIDI message:

   // Create a program change message for program number 42
   pc : ProgramChangeMessage = MakeProgramChangeMessage(42) 

and then use SendNow to send out that message.

Hello @David-san ,
sorry for the delay but I could not found anymore my Juno 106 service manual. I got it with from a friend of mine who was repairing synths in the shop where I purchased my Juno in 1986, it is dated of July 1984 so I guess it is corresponding to my model .

Here is the serial number of my Juno if it can answer to your question:

Here is also a picture of the MIDI description extracted from the service manual regarding this program change :

The hexa values received from SendSX when pressing a button to select patches from the JUNO:

PN => patch number
PN  Hexa   Decimal   PN  Hexa   Decimal
A11 C0 00  000       B11 C0 40  064
A12 C0 01  001       B12 C0 41  065
A13 C0 02  002       B13 C0 42  066
A14 C0 03  003       B14 C0 43  067
A15 C0 04  004       B15 C0 44  068
A16 C0 05  005       B16 C0 45  069
A17 C0 06  006       B17 C0 46  070
A18 C0 07  007       B18 C0 47  071
A21 C0 08  008       B21 C0 48  072
A22 C0 09  009       B22 C0 49  073
A23 C0 0A  010       B23 C0 4A  074
A24 C0 0B  011       B24 C0 4B  075
A25 C0 0C  012       B25 C0 4C  076
A26 C0 0D  013       B26 C0 4D  077
A27 C0 0E  014       B27 C0 4E  078
A28 C0 0F  015       B28 C0 4F  079
A31 C0 10  016       B31 C0 50  080
A32 C0 11  017       B32 C0 51  081
A33 C0 12  018       B33 C0 52  082
A34 C0 13  019       B34 C0 53  083
A35 C0 14  020       B35 C0 54  084
A36 C0 15  021       B36 C0 55  085
A37 C0 16  022       B37 C0 56  086
A38 C0 17  023       B38 C0 57  087
A41 C0 18  024       B41 C0 58  088
A42 C0 19  025       B42 C0 59  089
A43 C0 1A  026       B43 C0 5A  090
A44 C0 1B  027       B44 C0 5B  091
A45 C0 1C  028       B45 C0 5C  092
A46 C0 1D  029       B46 C0 5D  093
A47 C0 1E  030       B47 C0 5E  094
A48 C0 1F  031       B48 C0 5F  095
A51 C0 20  032       B51 C0 60  096
A52 C0 21  033       B52 C0 61  097
A53 C0 22  034       B53 C0 62  098
A54 C0 23  035       B54 C0 63  099
A55 C0 24  036       B55 C0 64  100
A56 C0 25  037       B56 C0 65  101
A57 C0 26  038       B57 C0 66  102
A58 C0 27  039       B58 C0 67  103
A61 C0 28  040       B61 C0 68  104
A62 C0 29  041       B62 C0 69  105
A63 C0 2A  042       B63 C0 6A  106
A64 C0 2B  043       B64 C0 6B  107
A65 C0 2C  044       B65 C0 6C  108
A66 C0 2D  045       B66 C0 6D  109
A67 C0 2E  046       B67 C0 6E  110
A68 C0 2F  047       B68 C0 6F  111
A71 C0 30  048       B71 C0 70  112
A72 C0 31  049       B72 C0 71  113
A73 C0 32  050       B73 C0 72  114
A74 C0 33  051       B74 C0 73  115
A75 C0 34  052       B75 C0 74  116
A76 C0 35  053       B76 C0 75  117
A77 C0 36  054       B77 C0 76  118
A78 C0 37  055       B78 C0 77  119
A81 C0 38  056       B81 C0 78  120
A82 C0 39  057       B82 C0 79  121
A83 C0 3A  058       B83 C0 7A  122
A84 C0 3B  059       B84 C0 7B  123
A85 C0 3C  060       B85 C0 7C  124
A86 C0 3D  061       B86 C0 7D  125
A87 C0 3E  062       B87 C0 7E  126
A88 C0 3F  063       B88 C0 7F  127

Yep - those are standard Program Change messages — just use the example script and don’t try to do your own MIDI formatting

Yes, thank you. In the meantime it was clear that it is a regular PC MIDI message. Everything is clear now.

Thanks a lot for your detailed answers and the time spent to help me :+1:

Hello @dhj ,
sorry to disturb you again but I still not managed to make these simple PC things working. There is something I do not understand in the MIDI input/output logic

Here is my wiring, I got a MIDI IN block called JUNO106_OUT in the script as it is the out port of the JUNO 106 and a MIDI OUT port called JUNO106-IN as it is the MIDI input connector of the juno:
When pressing any preset button in the JUNO it is sending the sysex patch contents to the GP MIDI IN port (JUNO106-OUT) and I can see this incomming data in the GP MIDI IN monitor window:

Until here everything is logical to me

But in the script when I am using the JUNO106_IN (therfore the GP MidiOutBlock) in the SendNow() function the compilation fails as the SendNow() function strangely expects a MidiInBlock as argument:

How is it possible that we have to SEND something to a GP IN port from where I am RECEIVING sysex values as it is the hardware MIDI OUT connection ?

By the way , when I am using the MIDI IN port (so the JUNO106-OUT) it compiles fine but the JUNO does not react to the sent program changes which is normal to me as we are sending data to the JUNO 106 MIDI IN connector port. And I can see in the same MIDI monitor window displaying the patch values SENT by the JUNO 106 when pressing a patch button on the JUNO the program changes values I am sending … to the JUNO OUTPUT connector/ GP MIDI IN.

I have to say that I do not understand the logic of the SendNow() function if we have to send stuff to an hardware OUTPUT port/ GP MidiInBlock to me it cannot work…

Cheers, eric

Use this function

SendNowExternal(<p : MidiOutBlock>, <m : midiMessage>)

I know you’re interested in learning GPScript but it seems to me that everything you’re trying to do so far can be done without GPScript at all. You could just attach a widget to the PC parameter of a MIDI Out plugin and be done.
Or if you want to use individual buttons, the. Just scale the values and attach to the PC parameter

Hey, I have just used the SendNowToMidiOutDevice(“iRig MIDI 2”, pc) using the MIDI device name / interface where my JUNO is connected and the script is working perfectly now:

the PC messages are well received by the JUNO and clicking button on the GP panel is changing the JUNO patches arccordingly. Yes… finally. :wink:

The SendNow(MidiInBlock) is nevertheless weird to me.

Thanks @dhj , I will try that too then if it is simpler.

Hello @pianopaul ,

I am confirming you that the SendNowExternal(JUNO106_IN, pc) function using logically a MidiOutBlock is working fine as well , the JUNO is well receiving my PCs

Therfore I am wondering even more if there could be a mistake in the SendNow( MidiInBlock, MidiMessage ) function…

Thanks a lot for your suggestion. :+1: