Exemplo n.º 1
0
bool PianoScene::event(QEvent *event)
{
    switch(event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchEnd:
    case QEvent::TouchUpdate: {
            QTouchEvent *touchEvent = static_cast<QTouchEvent*>(event);
            QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
            foreach(const QTouchEvent::TouchPoint& touchPoint, touchPoints) {
                switch (touchPoint.state()) {
                case Qt::TouchPointReleased: {
                        PianoKey* key = getKeyForPos(touchPoint.scenePos());
                        if (key != NULL && key->isPressed()) {
                            keyOff(key, touchPoint.pressure());
                        }
                        break;
                    }
                case Qt::TouchPointPressed: {
                        PianoKey* key = getKeyForPos(touchPoint.scenePos());
                        if (key != NULL && !key->isPressed()) {
                            keyOn(key, touchPoint.pressure());
                        }
                        break;
                    }
                case Qt::TouchPointMoved: {
                        PianoKey* key = getKeyForPos(touchPoint.scenePos());
                        PianoKey* lastkey = getKeyForPos(touchPoint.lastScenePos());
                        if ((lastkey != NULL) && (lastkey != key) && lastkey->isPressed()) {
                            keyOff(lastkey, touchPoint.pressure());
                        }
                        if ((key != NULL) && !key->isPressed()) {
                            keyOn(key, touchPoint.pressure());
                        }
                        break;
                    }
                default:
                    break;
                }
            }
            break;
        }
    default:
        return QGraphicsScene::event(event);
    }
    event->accept();
    return true;
}
Exemplo n.º 2
0
void PianoScene::keyPressEvent ( QKeyEvent * keyEvent )
{
    if ( !m_rawkbd && !keyEvent->isAutoRepeat() ) { // ignore auto-repeats
        int note = getNoteFromKey(keyEvent->key());
        if (note > -1)
            keyOn(note);
    }
    keyEvent->accept();
}
Exemplo n.º 3
0
void PianoScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent )
{
    PianoKey* key = getKeyForPos(mouseEvent->scenePos());
    if (key != NULL && !key->isPressed()) {
        keyOn(key);
        m_mousePressed = true;
        mouseEvent->accept();
        return;
    }
    mouseEvent->ignore();
}
Exemplo n.º 4
0
void ADSREnvOld::updateEvent( UINT16 inputId, FLOAT value )
{
	if( inputId == MIDI_GATE ) {
		if( value > 0 ) {
			keyOn();
		}
		else {
			keyOff();
		}
	}
}
Exemplo n.º 5
0
SWIGEXPORT jint JNICALL Java_com_dsp_1faust_dsp_1faustJNI_keyOn(JNIEnv *jenv, jclass jcls, jint jarg1, jint jarg2) {
    jint jresult = 0 ;
    int arg1 ;
    int arg2 ;
    int result;

    (void)jenv;
    (void)jcls;
    arg1 = (int)jarg1;
    arg2 = (int)jarg2;
    result = (int)keyOn(arg1,arg2);
    jresult = (jint)result;
    return jresult;
}
Exemplo n.º 6
0
void PianoScene::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent )
{
    if (m_mousePressed) {
        PianoKey* key = getKeyForPos(mouseEvent->scenePos());
        PianoKey* lastkey = getKeyForPos(mouseEvent->lastScenePos());
        if ((lastkey != NULL) && (lastkey != key) && lastkey->isPressed()) {
            keyOff(lastkey);
        }
        if ((key != NULL) && !key->isPressed()) { 
            keyOn(key);
        }
        mouseEvent->accept();
        return;
    }
    mouseEvent->ignore();
}
Exemplo n.º 7
0
void ADSREnv::setParameter( UINT16 paramId, FLOAT value, FLOAT modulation, INT16 voice )
{
    voice = min( numVoices_-1, voice );

    switch( paramId )
    {
    case PARAM_GATE:
        if( voice > -1 )
        {
		    FLOAT velo = value * modulation + ( 1 - modulation );
            value > 0.0f ? keyOn( velo, voice ) : keyOff( voice );
            break;
	    }
	case PARAM_ATTACK:  setAttackRate( value, voice ); break;
	case PARAM_DECAY:   setDecayRate( value, voice ); break;
	case PARAM_SUSTAIN: setSustainLevel( value, voice ); break;
	case PARAM_RELEASE: setReleaseRate( value, voice ); break;
    }
}