MCPcopy Create free account
hub / github.com/audacity/audacity / Invert

Method Invert

src/effects/EqualizationBandSliders.cpp:541–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541void EqualizationBandSliders::Invert() // Inverts any curve
542{
543 auto &parameters = mCurvesList.mParameters;
544 auto &linEnvelope = parameters.mLinEnvelope;
545 auto &logEnvelope = parameters.mLogEnvelope;
546
547 if (!parameters.mDrawMode) // Graphic (Slider) mode. Invert the sliders.
548 {
549 for (size_t i = 0; i < mBandsInUse; i++)
550 {
551 mEQVals[i] = -mEQVals[i];
552 int newPosn = (int)mEQVals[i];
553 mSliders[i]->SetValue( newPosn );
554 mSlidersOld[i] = newPosn;
555
556 wxString tip;
557 if( kThirdOct[i] < 1000.)
558 tip.Printf( wxT("%dHz\n%.1fdB"), (int)kThirdOct[i], mEQVals[i] );
559 else
560 tip.Printf( wxT("%gkHz\n%.1fdB"), kThirdOct[i]/1000., mEQVals[i] );
561 mSliders[i]->SetToolTip(tip);
562 }
563 GraphicEQ(logEnvelope);
564 }
565 else // Draw mode. Invert the points.
566 {
567 bool lin = parameters.IsLinear(); // refers to the 'log' or 'lin' of the frequency scale, not the amplitude
568 size_t numPoints; // number of points in the curve/envelope
569
570 // determine if log or lin curve is the current one
571 // and find out how many points are in the curve
572 if(lin) // lin freq scale and so envelope
573 {
574 numPoints = linEnvelope.GetNumberOfPoints();
575 }
576 else
577 {
578 numPoints = logEnvelope.GetNumberOfPoints();
579 }
580
581 if( numPoints == 0 )
582 return;
583
584 Doubles when{ numPoints };
585 Doubles value{ numPoints };
586
587 if(lin)
588 linEnvelope.GetPoints( when.get(), value.get(), numPoints );
589 else
590 logEnvelope.GetPoints( when.get(), value.get(), numPoints );
591
592 // invert the curve
593 for (size_t i = 0; i < numPoints; i++)
594 {
595 if(lin)
596 linEnvelope.Reassign(when[i] , -value[i]);
597 else
598 logEnvelope.Reassign(when[i] , -value[i]);

Callers 1

OnInvertMethod · 0.45

Calls 8

GetNumberOfPointsMethod · 0.80
GetPointsMethod · 0.80
ReassignMethod · 0.80
EnvelopeUpdatedMethod · 0.80
SetValueMethod · 0.45
SetToolTipMethod · 0.45
IsLinearMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected