MCPcopy Create free account
hub / github.com/LMMS/lmms / scaleTimemapToFit

Method scaleTimemapToFit

src/gui/AutomationPatternView.cpp:483–508  ·  view source on GitHub ↗

* @brief Preserves the auto points over different scale */

Source from the content-addressed store, hash-verified

481 * @brief Preserves the auto points over different scale
482 */
483void AutomationPatternView::scaleTimemapToFit( float oldMin, float oldMax )
484{
485 float newMin = m_pat->getMin();
486 float newMax = m_pat->getMax();
487
488 if( oldMin == newMin && oldMax == newMax )
489 {
490 return;
491 }
492
493 for( AutomationPattern::timeMap::iterator it = m_pat->m_timeMap.begin();
494 it != m_pat->m_timeMap.end(); ++it )
495 {
496 if( *it < oldMin )
497 {
498 *it = oldMin;
499 }
500 else if( *it > oldMax )
501 {
502 *it = oldMax;
503 }
504 *it = (*it-oldMin)*(newMax-newMin)/(oldMax-oldMin)+newMin;
505 }
506
507 m_pat->generateTangents();
508}

Callers 1

disconnectObjectMethod · 0.95

Calls 3

generateTangentsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected