@@ -32,10 +32,9 @@ namespace yup
3232/* *
3333 FIR-based upsampler for high-quality sample rate conversion.
3434
35- This implementation provides efficient upsampling using FIR filters with
36- optimized polyphase structure. It avoids computing zero-stuffed samples
37- by using a specialized algorithm that only calculates non-zero coefficients.
38-
35+ This implementation provides efficient upsampling using FIR filters with optimized polyphase structure. It avoids
36+ computing zero-stuffed samples by using a specialized algorithm that only calculates non-zero coefficients.
37+
3938 Key Features:
4039 - **Template-based optimization**: Compile-time constants for maximum performance
4140 - **Polyphase structure**: Efficient implementation avoiding zero computation
@@ -230,10 +229,9 @@ class FirUpsampler
230229/* *
231230 FIR-based downsampler for high-quality sample rate conversion.
232231
233- This implementation provides efficient downsampling using FIR anti-aliasing
234- filters. It processes input samples continuously but only computes outputs
235- at the decimation intervals for maximum efficiency.
236-
232+ This implementation provides efficient downsampling using FIR anti-aliasing filters. It processes input samples
233+ continuously but only computes outputs at the decimation intervals for maximum efficiency.
234+
237235 Key Features:
238236 - **Anti-aliasing filtering**: Prevents aliasing artifacts during decimation
239237 - **Efficient decimation**: Only computes outputs when needed
@@ -421,24 +419,14 @@ class FirDownsampler
421419 int bufferIndex;
422420 int decimationPhase;
423421 int decimationRate;
424-
425- // ==============================================================================
426- static constexpr int nextPowerOfTwo (int value)
427- {
428- int result = 1 ;
429- while (result < value)
430- result <<= 1 ;
431- return result;
432- }
433422};
434423
435424// ==============================================================================
436425/* *
437426 Complete FIR-based resampling system with upsampling and downsampling.
438427
439- This class combines FIR upsampling and downsampling to provide arbitrary
440- rational sample rate conversion (L/M where L and M are integers). It
441- automatically designs Kaiser-windowed anti-aliasing filters and manages
428+ This class combines FIR upsampling and downsampling to provide arbitrary rational sample rate conversion
429+ (L/M where L and M are integers). It automatically designs Kaiser-windowed anti-aliasing filters and manages
442430 the coefficient storage.
443431
444432 Features:
@@ -586,7 +574,7 @@ class FirResampler : public FilterBase<SampleType, CoeffType>
586574 filterLength,
587575 cutoffFreq,
588576 this ->sampleRate * static_cast <double > (upsampleRatio),
589- " kaiser" ,
577+ WindowType:: kaiser,
590578 stopbandAttenuation);
591579 }
592580
@@ -596,13 +584,17 @@ class FirResampler : public FilterBase<SampleType, CoeffType>
596584 {
597585 case Quality::draft:
598586 return 32 ;
587+
599588 case Quality::normal:
600589 return 64 ;
590+
601591 case Quality::high:
602592 return 128 ;
593+
603594 case Quality::perfect:
604595 return 256 ;
605596 }
597+
606598 return 64 ;
607599 }
608600
@@ -612,13 +604,17 @@ class FirResampler : public FilterBase<SampleType, CoeffType>
612604 {
613605 case Quality::draft:
614606 return static_cast <CoeffType> (40.0 );
607+
615608 case Quality::normal:
616609 return static_cast <CoeffType> (60.0 );
610+
617611 case Quality::high:
618612 return static_cast <CoeffType> (80.0 );
613+
619614 case Quality::perfect:
620615 return static_cast <CoeffType> (100.0 );
621616 }
617+
622618 return static_cast <CoeffType> (60.0 );
623619 }
624620
0 commit comments