Exemple #1
0
JNIEXPORT void JNICALL Java_org_puredata_core_PdBase_initialize
(JNIEnv *env, jclass cls) {
  libpd_queued_init();

  objClass = LIBPD_CLASS_REF("java/lang/Object");
  floatClass = LIBPD_CLASS_REF("java/lang/Float");
  floatInit = (*env)->GetMethodID(env, floatClass, "<init>", "(F)V");

  libpd_set_queued_printhook(libpd_print_concatenator);
  libpd_set_concatenated_printhook(java_printhook);

  libpd_set_queued_banghook(java_sendBang);
  libpd_set_queued_floathook(java_sendFloat);
  libpd_set_queued_symbolhook(java_sendSymbol);
  libpd_set_queued_listhook(java_sendList);
  libpd_set_queued_messagehook(java_sendMessage);

  libpd_set_queued_noteonhook(java_sendNoteOn);
  libpd_set_queued_controlchangehook(java_sendControlChange);
  libpd_set_queued_programchangehook(java_sendProgramChange);
  libpd_set_queued_pitchbendhook(java_sendPitchBend);
  libpd_set_queued_aftertouchhook(java_sendAftertouch);
  libpd_set_queued_polyaftertouchhook(java_sendPolyAftertouch);
  libpd_set_queued_midibytehook(java_sendMidiByte);
}
Exemple #2
0
void PdBase::PdContext::clear() {

    // detach callbacks
    if(bInited) {

        computeAudio(false);

        if(bQueued) {
            libpd_set_queued_printhook(NULL);
            libpd_set_concatenated_printhook(NULL);

            libpd_set_queued_banghook(NULL);
            libpd_set_queued_floathook(NULL);
            libpd_set_queued_symbolhook(NULL);
            libpd_set_queued_listhook(NULL);
            libpd_set_queued_messagehook(NULL);

            libpd_set_queued_noteonhook(NULL);
            libpd_set_queued_controlchangehook(NULL);
            libpd_set_queued_programchangehook(NULL);
            libpd_set_queued_pitchbendhook(NULL);
            libpd_set_queued_aftertouchhook(NULL);
            libpd_set_queued_polyaftertouchhook(NULL);
            libpd_set_queued_midibytehook(NULL);
            
            libpd_queued_release();
        }
        else {
            libpd_set_printhook(NULL);
            libpd_set_concatenated_printhook(NULL);

            libpd_set_banghook(NULL);
            libpd_set_floathook(NULL);
            libpd_set_symbolhook(NULL);
            libpd_set_listhook(NULL);
            libpd_set_messagehook(NULL);

            libpd_set_noteonhook(NULL);
            libpd_set_controlchangehook(NULL);
            libpd_set_programchangehook(NULL);
            libpd_set_pitchbendhook(NULL);
            libpd_set_aftertouchhook(NULL);
            libpd_set_polyaftertouchhook(NULL);
            libpd_set_midibytehook(NULL);
        }
    }

    bInited = false;
    bQueued = false;

    bMsgInProgress = false;
    curMsgLen = 0;
    msgType = MSG;
    midiPort = 0;
}
Exemple #3
0
/// init the pd instance
bool PdBase::PdContext::init(const int numInChannels, const int numOutChannels, const int sampleRate, bool queued) {

    bQueued = queued;

    // attach callbacks
    if(queued) {
        libpd_set_queued_printhook(libpd_print_concatenator);
        libpd_set_concatenated_printhook(_print);

        libpd_set_queued_banghook(_bang);
        libpd_set_queued_floathook(_float);
        libpd_set_queued_symbolhook(_symbol);
        libpd_set_queued_listhook(_list);
        libpd_set_queued_messagehook(_message);

        libpd_set_queued_noteonhook(_noteon);
        libpd_set_queued_controlchangehook(_controlchange);
        libpd_set_queued_programchangehook(_programchange);
        libpd_set_queued_pitchbendhook(_pitchbend);
        libpd_set_queued_aftertouchhook(_aftertouch);
        libpd_set_queued_polyaftertouchhook(_polyaftertouch);
        libpd_set_queued_midibytehook(_midibyte);
        
        // init libpd, should only be called once!
        if(!bLibPdInited) {
            libpd_queued_init();
            init_externals();
            bLibPdInited = true;
        }
    }
    else {
        libpd_set_printhook(libpd_print_concatenator);
        libpd_set_concatenated_printhook(_print);

        libpd_set_banghook(_bang);
        libpd_set_floathook(_float);
        libpd_set_symbolhook(_symbol);
        libpd_set_listhook(_list);
        libpd_set_messagehook(_message);

        libpd_set_noteonhook(_noteon);
        libpd_set_controlchangehook(_controlchange);
        libpd_set_programchangehook(_programchange);
        libpd_set_pitchbendhook(_pitchbend);
        libpd_set_aftertouchhook(_aftertouch);
        libpd_set_polyaftertouchhook(_polyaftertouch);
        libpd_set_midibytehook(_midibyte);
        
        // init libpd, should only be called once!
        if(!bLibPdInited) {
            libpd_init();
            init_externals();
            bLibPdInited = true;
        }
    }
    
    // init audio
    if(libpd_init_audio(numInChannels, numOutChannels, sampleRate) != 0) {
        return false;
    }
    bInited = true;

    return bInited;
}