Send SysEx msg
  • Order of the Butterfly
    Order of the Butterfly
    tolkien
    Posts: 372 from 2013/5/29
    Hello mates!
    Im toying with C doing some midi stuff and getting fun. I can play midi notes and so but I'm unable to send a sysex msg.
    I even compiled simple programs from AOS4 that send sysex msg with no success.

    I need some light! :)

    Thanks.
    PowerMac G5 - PowerBook G4 - MacMini with MorphOS. Amiga 1200/060 AmigaOS 3.x
  • »06.12.20 - 21:16
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    tolkien
    Posts: 372 from 2013/5/29
    I post this simple example to see if someone can see the problem. For sure is a stupid error but my device doesnt react to my sysex msgs...


    Code:
    #include <proto/camd.h>
    #include <proto/dos.h>
    #include <proto/exec.h>
    #include <stdlib.h>


    //USB2.0-MIDI.in
    //USB2.0-MIDI.out

    void cleanout(char *); // Exit

    struct Library *CamdBase = NULL;

    struct MidiNode *ournode = NULL;
    struct MidiLink *outLink = NULL;
    BYTE midisig = -1;

    int main(int argc, char **argv)
    {
    MidiMsg midimsg;
    ULONG signal;
    BOOL alive = TRUE;

    CamdBase = OpenLibrary("camd.library", 36L);
    if(NULL == CamdBase) cleanout("Can't open camd.library");

    midisig = AllocSignal(-1);
    if(midisig == -1) cleanout("Cant get a signal");

    // MIDI Node
    ournode = CreateMidi(MIDI_Name, "Our MIDI Node",
    MIDI_MsgQueue, 2048L,
    MIDI_SysExSize, 10000L,
    MIDI_RecvSignal, midisig,
    TAG_END);
    if(!ournode) cleanout("Can't Create MidiNode");

    // MIDI Link
    outLink = AddMidiLink(ournode, MLTYPE_Sender,
    MLINK_Location, "USB2.0-MIDI.out",
    TAG_END);
    if(!outLink) cleanout("Can't Add Output Link");


    //SendSysEx

    //UBYTE reset[] = {0xf0, 0X7d, 0X00, 0Xf7};
    Printf("Send SysEx msgn");
    //Special SysEx to MIDI device
    UBYTE reset[] = {0xf0, 0x7d, 0x03, 0x01, 0xf7};
    PutSysEx(outLink, reset);
    Delay(10);


    // Wait loop
    while(alive)
    { // Wait (Ctrl-C)

    signal = Wait(SIGBREAKF_CTRL_C | 1L << midisig);

    if(signal & SIGBREAKF_CTRL_C)
    alive = FALSE;
    }

    Printf("Closing MIDI Link ....n");

    cleanout(NULL);
    return (0);
    }

    void cleanout(char *txt)
    {
    if(txt)
    {
    Printf("%sn",txt);
    }

    if (outLink) RemoveMidiLink(outLink);
    if (ournode) DeleteMidi(ournode);
    if (midisig) FreeSignal(midisig);
    if (CamdBase) CloseLibrary(CamdBase);

    if(txt) exit(-1);
    }
    PowerMac G5 - PowerBook G4 - MacMini with MorphOS. Amiga 1200/060 AmigaOS 3.x
  • »08.12.20 - 17:27
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 583 from 2007/10/23
    From: Gelsenkirchen,...
    Did you try GetMidiErr()?
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.15
  • »09.12.20 - 08:20
    Profile
  • MorphOS Developer
    Piru
    Posts: 469 from 2003/2/24
    From: finland, the l...
    I dunno why the MIDI part is not working but cleanout has a bug. It is not related to the issue you're having though. Anyway, the code should be:

    Code:
        if (midisig != -1) FreeSignal(midisig);
  • »09.12.20 - 09:40
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    tolkien
    Posts: 372 from 2013/5/29
    ...Repeated message...

    [ Editado por tolkien 09.12.2020 - 18:11 ]
    PowerMac G5 - PowerBook G4 - MacMini with MorphOS. Amiga 1200/060 AmigaOS 3.x
  • »09.12.20 - 10:12
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    tolkien
    Posts: 372 from 2013/5/29
    Quote:

    tolkien escribió:
    Will try getmidierr(). But is funny that I can send midi notes but cant send sysex messages. :)

    Piru: Damn...you are right. I wrote that in a hurry but as you say Its not related to the problem.

    Thanks mates. Will try a few things today.
    PowerMac G5 - PowerBook G4 - MacMini with MorphOS. Amiga 1200/060 AmigaOS 3.x
  • »09.12.20 - 11:03
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    tolkien
    Posts: 372 from 2013/5/29
    Hello again!

    I have a few free days to play with MorphOS and try to resolve this mistery.
    What I have done is to compile this source (with different Midi port of course) in my 1200 and Damn! It works ok in classic but same source compile in MorphOS but it doesnt send any sysexmsg to my device.

    Code:

    #include <proto/camd.h>
    #include <proto/dos.h>
    #include <proto/exec.h>
    #include <stdlib.h>


    //USB2.0-MIDI.in
    //USB2.0-MIDI.out

    void cleanout(char *); // Exit

    struct Library *CamdBase = NULL;

    struct MidiNode *ournode = NULL;
    struct MidiLink *outLink = NULL;
    BYTE midisig = -1;

    int main(int argc, char **argv)
    {
    //MidiMsg midimsg;
    ULONG signal;
    BOOL alive = TRUE;

    CamdBase = OpenLibrary((CONST_STRPTR)"camd.library", 36L);
    if(NULL == CamdBase) cleanout("Can't open camd.library");

    midisig = AllocSignal(-1);
    if(midisig == -1) cleanout("Cant get a signal");

    // MIDI Node
    struct TagItem MidiItems[] =
    {
    MIDI_Name, (LONG)"Our MIDI Node",
    MIDI_MsgQueue, 6048L,
    MIDI_SysExSize, 10000L,
    MIDI_RecvSignal, midisig,
    TAG_DONE
    };

    ournode = CreateMidiA(&MidiItems[0]);
    if(!ournode) cleanout("Can't Create MidiNode");

    // MIDI Link
    struct TagItem MidiLinkTags[] =
    {
    MLINK_Location, (LONG)"USB2.0-MIDI.out",
    TAG_DONE
    };

    outLink = AddMidiLinkA(ournode, MLTYPE_Sender, &MidiLinkTags[0]);
    if(!outLink) cleanout("Can't Add Output Link");

    //SendSysEx
    //UBYTE reset[] = {0xf0, 0x7d, 0x00, 0xf7};
    Printf("Send SysEx msgn");
    //Special SysEx to MIDI device
    UBYTE reset[] = {0xf0, 0x7d, 0x03, 0x01, 0xf7};

    PutSysEx(outLink, reset);

    // Wait loop
    while(alive)
    { // Wait (Ctrl-C)

    signal = Wait(SIGBREAKF_CTRL_C | 1L << midisig);

    if(signal & SIGBREAKF_CTRL_C)
    alive = FALSE;
    }

    Printf("Closing MIDI Link ....n");

    cleanout(NULL);
    return (0);
    }

    void cleanout(char *txt)
    {
    if(txt)
    {
    Printf("%sn",txt);
    }

    if (outLink) RemoveMidiLink(outLink);
    if (ournode) DeleteMidi(ournode);
    if (midisig != -1) FreeSignal(midisig);
    if (CamdBase) CloseLibrary(CamdBase);

    if(txt) exit(-1);
    }


    Can anyone provide me a working example for sending SysEx messages?

    Thanks in advance mates!
    PowerMac G5 - PowerBook G4 - MacMini with MorphOS. Amiga 1200/060 AmigaOS 3.x
  • »28.12.20 - 11:02
    Profile