Ejemplo n.º 1
0
int rtmidi_out_send_message (RtMidiOutPtr device, const unsigned char *message, int length)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidiOut* rtm = (RtMidiOut*) device->ptr;
    rtm->resetError();
    rtm->sendMessage (message, length);
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return -1;
    }
    return 0;
#else
    try {
        ((RtMidiOut*) device->ptr)->sendMessage (message, length);
        return 0;
    }
    catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();
        return -1;
    }
    catch (...) {
        device->ok  = false;
        device->msg = "Unknown error";
        return -1;
    }
#endif
}
Ejemplo n.º 2
0
RtMidiOutPtr rtmidi_out_create (enum RtMidiApi api, const char *clientName)
{
    RtMidiWrapper* wrp = new RtMidiWrapper;
    std::string name = clientName;

#if defined(__NO_EXCEPTIONS__)
    RtMidiOut* rOut = new RtMidiOut ((RtMidi::Api) api, name);
    if (rOut->isError()) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = rOut->getError().what ();
    }
    else {
        wrp->ptr = (void*) rOut;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    }
#else
    try {
        RtMidiOut* rOut = new RtMidiOut ((RtMidi::Api) api, name);
        
        wrp->ptr = (void*) rOut;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    
    } catch (const RtMidiError & err) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = err.what ();
    }
#endif


    return wrp;
}
Ejemplo n.º 3
0
/* RtMidiOut API */
RtMidiOutPtr rtmidi_out_create_default ()
{
    RtMidiWrapper* wrp = new RtMidiWrapper;

#if defined(__NO_EXCEPTIONS__)
    RtMidiOut* rOut = new RtMidiOut ();
    if (rOut->isError()) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = rOut->getError().what ();
    }
    else {
        wrp->ptr = (void*) rOut;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    }
#else
    try {
        RtMidiOut* rOut = new RtMidiOut ();
        
        wrp->ptr = (void*) rOut;
        wrp->data = 0;
        wrp->ok  = true;
        wrp->msg = "";
    
    } catch (const RtMidiError & err) {
        wrp->ptr = 0;
        wrp->data = 0;
        wrp->ok  = false;
        wrp->msg = err.what ();
    }
#endif

    return wrp;
}
Ejemplo n.º 4
0
enum RtMidiApi rtmidi_out_get_current_api (RtMidiPtr device)
{
#if defined(__NO_EXCEPTIONS__)
    RtMidiOut* rtm = (RtMidiOut*) device->ptr;
    rtm->resetError();
    RtMidiApi curApi = (RtMidiApi) rtm->getCurrentApi ();
    if (rtm->isError()) {
        device->ok  = false;
        device->msg = rtm->getError().what ();
        return RT_MIDI_API_UNSPECIFIED;
    }
    return curApi;
#else
    try {
        return (RtMidiApi) ((RtMidiOut*) device->ptr)->getCurrentApi ();

    } catch (const RtMidiError & err) {
        device->ok  = false;
        device->msg = err.what ();

        return RT_MIDI_API_UNSPECIFIED;
    }
#endif
}