| 540 | |
| 541 | |
| 542 | ValueBuffer * AutomatableModel::valueBuffer() |
| 543 | { |
| 544 | QMutexLocker m( &m_valueBufferMutex ); |
| 545 | // if we've already calculated the valuebuffer this period, return the cached buffer |
| 546 | if( m_lastUpdatedPeriod == s_periodCounter ) |
| 547 | { |
| 548 | return m_hasSampleExactData |
| 549 | ? &m_valueBuffer |
| 550 | : NULL; |
| 551 | } |
| 552 | |
| 553 | float val = m_value; // make sure our m_value doesn't change midway |
| 554 | |
| 555 | ValueBuffer * vb; |
| 556 | if( m_controllerConnection && m_controllerConnection->getController()->isSampleExact() ) |
| 557 | { |
| 558 | vb = m_controllerConnection->valueBuffer(); |
| 559 | if( vb ) |
| 560 | { |
| 561 | float * values = vb->values(); |
| 562 | float * nvalues = m_valueBuffer.values(); |
| 563 | switch( m_scaleType ) |
| 564 | { |
| 565 | case Linear: |
| 566 | for( int i = 0; i < m_valueBuffer.length(); i++ ) |
| 567 | { |
| 568 | nvalues[i] = minValue<float>() + ( range() * values[i] ); |
| 569 | } |
| 570 | break; |
| 571 | case Logarithmic: |
| 572 | for( int i = 0; i < m_valueBuffer.length(); i++ ) |
| 573 | { |
| 574 | nvalues[i] = logToLinearScale( values[i] ); |
| 575 | } |
| 576 | break; |
| 577 | default: |
| 578 | qFatal("AutomatableModel::valueBuffer() " |
| 579 | "lacks implementation for a scale type"); |
| 580 | break; |
| 581 | } |
| 582 | m_lastUpdatedPeriod = s_periodCounter; |
| 583 | m_hasSampleExactData = true; |
| 584 | return &m_valueBuffer; |
| 585 | } |
| 586 | } |
| 587 | AutomatableModel* lm = NULL; |
| 588 | if( m_hasLinkedModels ) |
| 589 | { |
| 590 | lm = m_linkedModels.first(); |
| 591 | } |
| 592 | if( lm && lm->controllerConnection() && lm->controllerConnection()->getController()->isSampleExact() ) |
| 593 | { |
| 594 | vb = lm->valueBuffer(); |
| 595 | float * values = vb->values(); |
| 596 | float * nvalues = m_valueBuffer.values(); |
| 597 | for( int i = 0; i < vb->length(); i++ ) |
| 598 | { |
| 599 | nvalues[i] = fittedValue( values[i] ); |
no test coverage detected