Пример #1
0
Synth::Synth(QDeclarativeContext* context, QObject *parent) :
    QObject(parent), m_pressedKeys(), m_octaveFactor(8), m_pitchBend(false)
{
    m_operators[0] = new Operator(this);
    m_operators[1] = new Operator(this);
    m_operators[2] = new Operator(this);
    m_operators[3] = new Operator(this);

    m_operators[1]->setFollowsKeys(true);
    m_operators[2]->setFollowsKeys(true);
    m_operators[3]->setFollowsKeys(true);

    m_loopBuffer.data = new float[LOOP_BUFFER_SIZE];
    m_loopBuffer.state = LoopBuffer::EMPTY;
    m_loopBuffer.index = m_loopBuffer.data;
    m_loopBuffer.size = sizeof(LOOP_BUFFER_SIZE);

    //qDebug("Synth::setting context properties for operators&effects");
    context->setContextProperty("Operator1", m_operators[0]);
    context->setContextProperty("Operator2", m_operators[1]);
    context->setContextProperty("Operator3", m_operators[2]);
    context->setContextProperty("Operator4", m_operators[3]);

    m_effects = new Effects(context, this);
    context->setContextProperty("Effects", m_effects);

    m_lfo = new LFO(this);
    context->setContextProperty("LFO", m_lfo);

    m_pressedKeys[0].key = KEY_NONE;
    m_pressedKeys[0].index = 0;
    m_pressedKeys[0].freq = 0.00;
    m_pressedKeys[0].periodInSamples = 0;
    m_pressedKeys[1].key = KEY_NONE;
    m_pressedKeys[1].index = 1;
    m_pressedKeys[1].freq = 0.00;
    m_pressedKeys[1].periodInSamples = 0;

    connect(m_operators[0], SIGNAL(soundDone(uint)), this, SLOT(freeKey(uint)));
}
Пример #2
0
void destroy_tree_nodes(BtreeNode_t * root, void freeRecord(void *), void freeKey(void *)) {
    int i;
    if (root == NULL) return;
    if (root->is_leaf) {
        for (i = 0; i < root->num_keys; i++) {
            if (freeRecord != NULL) {
                freeRecord(((BtreeRecord_t*) root->pointers[i])->value);
            }
            free(root->pointers[i]);
            if (freeKey != NULL) {
                freeKey(root->keys[i]);
            }
        }
    } else {
        for (i = 0; i < root->num_keys + 1; i++) {
            destroy_tree_nodes(root->pointers[i], freeRecord, freeKey);
        }
    }
    free(root->pointers);
    free(root->keys);
    free(root);
}
Пример #3
0
void bNodeDestroy(BNode *n, void (*freeKey)(void *key),
                   void (*freeData)(void *data)){
    freeKey(n->key);
    freeData(n->data);
    free(n);
}