Send SysEx msg
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    tolkien
    Posts: 502 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.
    MorphOS: PowerMac G5 - PowerBook G4 - MacMini.
    Classic: Amiga 1200/060 - A500 PiStorm
  • »06.12.20 - 22:16
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    tolkien
    Posts: 502 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);
    }
    MorphOS: PowerMac G5 - PowerBook G4 - MacMini.
    Classic: Amiga 1200/060 - A500 PiStorm
  • »08.12.20 - 18:27
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    polluks
    Posts: 779 from 2007/10/23
    From: Gelsenkirchen,...
    Did you try GetMidiErr()?
    Pegasos II G4: MorphOS 3.9, Zalman M220W · iMac G5 12,1 17", MorphOS 3.18
    Power Mac G3: OSX 10.3 · PowerBook 5,8: OSX 10.5, MorphOS 3.18
  • »09.12.20 - 09:20
    Profile
  • MorphOS Developer
    Piru
    Posts: 576 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 - 10:40
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    tolkien
    Posts: 502 from 2013/5/29
    ...Repeated message...

    [ Editado por tolkien 09.12.2020 - 18:11 ]
    MorphOS: PowerMac G5 - PowerBook G4 - MacMini.
    Classic: Amiga 1200/060 - A500 PiStorm
  • »09.12.20 - 11:12
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    tolkien
    Posts: 502 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.
    MorphOS: PowerMac G5 - PowerBook G4 - MacMini.
    Classic: Amiga 1200/060 - A500 PiStorm
  • »09.12.20 - 12:03
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    tolkien
    Posts: 502 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!
    MorphOS: PowerMac G5 - PowerBook G4 - MacMini.
    Classic: Amiga 1200/060 - A500 PiStorm
  • »28.12.20 - 12:02
    Profile