void SuperColliderLoopElement::beginRecording() {
    setRecording(true);
    buffer->alloc();
    bufWriter->create();
    toRecord = false;
    t0 = 0;
}
QmlProfilerTraceClient::~QmlProfilerTraceClient()
{
    //Disable profiling if started by client
    //Profiling data will be lost!!
    if (isRecording())
        setRecording(false);
    delete d;
}
SuperColliderLoopElement::SuperColliderLoopElement(SuperCollider * sc3, int numBeats, int index){
    int BPM = 120;
    
    this->numBeats = numBeats;
    this->volume = 1.0;
    this->skip = 1;
    this->count = 0;
    this->solo = false;
    this->mute = false;
    
    // supercollider stuff
    buffer = sc3->addBuffer("buffer"+ofToString(ofRandom(10000)), 44100 * (numBeats * 60.0f / BPM), 1);
    bufWriter = sc3->addSynth("buf_recorder");
    bufReader = sc3->addSynth("buf_player");
    bufWriter->set("bufnum", buffer->index);
    bufReader->set("bufnum", buffer->index);
    
    // create gui
    vector<string> inputItems, skipItems;
    inputItems.push_back("1");
    inputItems.push_back("2");
    skipItems.push_back("1");
    skipItems.push_back("2");
    skipItems.push_back("4");
    skipItems.push_back("8");
    gui = new ofxUICanvas("Track");
    gui->setPosition(5, 55 + 32 * index);
    gui->clearWidgets();
    gui->addLabel("Channel:");
    gui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT);
    gui->addRadio("BusIn", inputItems, OFX_UI_ORIENTATION_HORIZONTAL)->getToggles()[0]->setValue(true);
    gui->addLabel("Play:");
    gui->addLabelToggle("Play", &isPlay, 42.0f);
    gui->addLabelToggle("Rec", &toRecord, 42.0f);
    gui->addLabelToggle("Solo", &solo, 42.0f);
    gui->addLabelButton("Del", false, 42.0f);
    gui->addLabel("Each:");
    gui->addRadio("Skip", skipItems, OFX_UI_ORIENTATION_HORIZONTAL)->getToggles()[0]->setValue(true);
    gui->addMinimalSlider("Volume", 0.0f, 1.0f, &volume, 60.0f, 16.0f);
    gui->addLabel("Time:");
    progressSlider = gui->addMinimalSlider("", 0.0, 1.0, 0.0);
    progressSlider->getRect()->setWidth(20 * numBeats);
    gui->autoSizeToFitWidgets();
    gui->getRect()->setWidth(ofGetWidth()-10);
    ofAddListener(gui->newGUIEvent, this, &SuperColliderLoopElement::guiEvent);
    setPlaying(false);
    setRecording(false);
}
void SuperColliderLoopElement::setBeat(int beat) {
    this->beat = beat;
    if (beat % getNumBeats() == 0 && getPlaying())
    {
        count = (count + 1) % getSkip();
        if (count % (numBeats * getSkip()) == 0) {
            if (!mute) play();
            count = 0;
        }
    }
    
    if (beat == 0 && getToRecord()) {
        beginRecording();
    }
    else if (isRecord && (beat >= numBeats || beat == 0)) {
        setRecording(false);
    }
}
Esempio n. 5
0
void GLWidget::initializeGL()
{
    Color clearColor(0,0,0,0);

    OpenGL::clearColor(clearColor);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_COLOR_MATERIAL);

    // Depth buffer setup
    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    glEnable(GL_ALPHA_TEST);

    glEnable(GL_CULL_FACE);

    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

    // Initialize lighting
    glEnable(GL_LIGHTING);
    glShadeModel(GL_SMOOTH);

    glEnable(GL_LIGHT0);

    OpenGL::lightColor(GL_LIGHT0,GL_AMBIENT,Color(0.2,0.2,0.2));
    OpenGL::lightColor(GL_LIGHT0,GL_DIFFUSE,Color(1,1,1));
    OpenGL::lightColor(GL_LIGHT0,GL_SPECULAR,Color(1,1,1));

    setRecording(false);

    glPointSize(10);
    glLineWidth(3);

    _planarChain = new PlanarChain();
    _humanHand = new HumanHand();
    _walkingBug = new WalkingBug();

    _character = _planarChain;
}
Esempio n. 6
0
void GLWidget::keyPressEvent(QKeyEvent * event)
{
    Character *oldCharacter = _character;

    switch (event->key()) {
    // Camera controls
    case Qt::Key_W:
        _camera.moveUp();
        break;
    case Qt::Key_S:
        _camera.moveDown();
        break;
    case Qt::Key_A:
        _camera.moveLeft();
        break;
    case Qt::Key_D:
        _camera.moveRight();
        break;
    case Qt::Key_Q:
        _camera.moveFront();
        break;
    case Qt::Key_Z:
        _camera.moveBack();
        break;

    // Toggle forward/inverse kinematics
    case Qt::Key_Space:
        setAnimationEnabled(!_animationEnabled);
        break;

    // Record
    case Qt::Key_R:
        setRecording(!_isRecording);
        break;
    case Qt::Key_T:
        cycleIKMethod();
        break;

    //case Qt::Key_C: enableUserControl = !enableUserControl; break;

    // Change character views
    case Qt::Key_1:
        _character = _planarChain;
        _endEffectorsTarget.clear();
        break;
    case Qt::Key_2:
        _character = _humanHand;
        _endEffectorsTarget.clear();
        break;
    case Qt::Key_3:
        _character = _walkingBug;
        _endEffectorsTarget.clear();
        break;
    case Qt::Key_4:
        break;
    }

    // Restart animation when switching characters with animation enabled
    if(_animationEnabled && (oldCharacter != _character)) {
        _character->startAnimation();
    }

    update(); // update the screen
}