@@ -57,7 +57,7 @@ struct SignalsmithStretch {
5757 stashedOutput = stft.output ;
5858
5959 prevInputOffset = -1 ;
60- channelBands .assign (channelBands .size (), Band ());
60+ _channelBands .assign (_channelBands .size (), Band ());
6161 silenceCounter = 0 ;
6262 didSeek = false ;
6363 blockProcess = {};
@@ -66,10 +66,10 @@ struct SignalsmithStretch {
6666
6767 // Configures using a default preset
6868 void presetDefault (int nChannels, Sample sampleRate, bool splitComputation=false ) {
69- configure (nChannels, sampleRate*0.12 , sampleRate*0.03 , splitComputation);
69+ configure (nChannels, static_cast < int >( sampleRate*0.12 ), static_cast < int >( sampleRate*0.03 ) , splitComputation);
7070 }
7171 void presetCheaper (int nChannels, Sample sampleRate, bool splitComputation=true ) {
72- configure (nChannels, sampleRate*0.1 , sampleRate*0.04 , splitComputation);
72+ configure (nChannels, static_cast < int >( sampleRate*0.1 ), static_cast < int >( sampleRate*0.04 ) , splitComputation);
7373 }
7474
7575 // Manual setup
@@ -78,13 +78,13 @@ struct SignalsmithStretch {
7878 channels = nChannels;
7979 stft.configure (channels, channels, blockSamples, intervalSamples + 1 );
8080 stft.setInterval (intervalSamples, stft.kaiser );
81- stft.reset (0.1 );
81+ stft.reset (Sample ( 0.1 ) );
8282 stashedInput = stft.input ;
8383 stashedOutput = stft.output ;
8484 tmpBuffer.resize (blockSamples + intervalSamples);
8585
8686 bands = int (stft.bands ());
87- channelBands .assign (bands*channels, Band ());
87+ _channelBands .assign (bands*channels, Band ());
8888
8989 peaks.reserve (bands/2 );
9090 energy.resize (bands);
@@ -193,7 +193,7 @@ struct SignalsmithStretch {
193193 silenceFirst = false ;
194194 // stft.reset();
195195 blockProcess = {};
196- for (auto &b : channelBands ) {
196+ for (auto &b : _channelBands ) {
197197 b.input = b.prevInput = b.output = 0 ;
198198 b.inputEnergy = 0 ;
199199 }
@@ -235,7 +235,7 @@ struct SignalsmithStretch {
235235 blockProcess.samplesSinceLast = 0 ;
236236
237237 // Time to process a spectrum! Where should it come from in the input?
238- int inputOffset = std::round (outputIndex*Sample (inputSamples)/outputSamples);
238+ int inputOffset = static_cast < int >( std::round (outputIndex*Sample (inputSamples)/outputSamples) );
239239 int inputInterval = inputOffset - prevInputOffset;
240240 prevInputOffset = inputOffset;
241241
@@ -259,7 +259,7 @@ struct SignalsmithStretch {
259259
260260 blockProcess.processFormants = formantMultiplier != 1 || (formantCompensation && blockProcess.mappedFrequencies );
261261
262- blockProcess.timeFactor = didSeek ? seekTimeFactor : stft.defaultInterval ()/std::max<Sample> (1 , inputInterval);
262+ blockProcess.timeFactor = didSeek ? seekTimeFactor : stft.defaultInterval ()/static_cast <Sample>( std::max (1 , inputInterval) );
263263 didSeek = false ;
264264
265265 updateProcessSpectrumSteps ();
@@ -271,7 +271,7 @@ struct SignalsmithStretch {
271271 size_t processToStep = newBlock ? blockProcess.steps : 0 ;
272272 if (_splitComputation) {
273273 Sample processRatio = Sample (blockProcess.samplesSinceLast + 1 )/stft.defaultInterval ();
274- processToStep = std::min< size_t > (blockProcess.steps , ( blockProcess.steps + 0 .999f )*processRatio);
274+ processToStep = std::min (blockProcess.steps , static_cast < size_t >(( blockProcess.steps + 0 .999f )*processRatio) );
275275 }
276276
277277 while (blockProcess.step < processToStep) {
@@ -480,7 +480,7 @@ struct SignalsmithStretch {
480480 } blockProcess;
481481
482482 using Complex = std::complex <Sample>;
483- static constexpr Sample noiseFloor{1e-15 };
483+ static constexpr Sample noiseFloor{Sample ( 1e-15 ) };
484484 static constexpr Sample maxCleanStretch{2 }; // time-stretch ratio before we start randomising phases
485485 size_t silenceCounter = 0 ;
486486 bool silenceFirst = true ;
@@ -515,14 +515,14 @@ struct SignalsmithStretch {
515515 Complex output{0 };
516516 Sample inputEnergy;
517517 };
518- std::vector<Band> channelBands ;
518+ std::vector<Band> _channelBands ;
519519 Band * bandsForChannel (int channel) {
520- return channelBands .data () + channel*bands;
520+ return _channelBands .data () + channel*bands;
521521 }
522522 template <Complex Band::*member>
523523 Complex getBand (int channel, int index) {
524524 if (index < 0 || index >= bands) return 0 ;
525- return channelBands [index + channel*bands].*member;
525+ return _channelBands [index + channel*bands].*member;
526526 }
527527 template <Complex Band::*member>
528528 Complex getFractional (int channel, int lowIndex, Sample fractional) {
@@ -532,14 +532,14 @@ struct SignalsmithStretch {
532532 }
533533 template <Complex Band::*member>
534534 Complex getFractional (int channel, Sample inputIndex) {
535- int lowIndex = std::floor (inputIndex);
535+ int lowIndex = static_cast < int >( std::floor (inputIndex) );
536536 Sample fracIndex = inputIndex - lowIndex;
537537 return getFractional<member>(channel, lowIndex, fracIndex);
538538 }
539539 template <Sample Band::*member>
540540 Sample getBand (int channel, int index) {
541541 if (index < 0 || index >= bands) return 0 ;
542- return channelBands [index + channel*bands].*member;
542+ return _channelBands [index + channel*bands].*member;
543543 }
544544 template <Sample Band::*member>
545545 Sample getFractional (int channel, int lowIndex, Sample fractional) {
@@ -609,7 +609,7 @@ struct SignalsmithStretch {
609609 Sample timeFactor = blockProcess.timeFactor ;
610610
611611 Sample smoothingBins = Sample (stft.fftSamples ())/stft.defaultInterval ();
612- int longVerticalStep = std::round (smoothingBins);
612+ int longVerticalStep = static_cast < int >( std::round (smoothingBins) );
613613 timeFactor = std::max<Sample>(timeFactor, 1 /maxCleanStretch);
614614 bool randomTimeFactor = (timeFactor > maxCleanStretch);
615615 std::uniform_real_distribution<Sample> timeFactorDist (maxCleanStretch*2 *randomTimeFactor - timeFactor, timeFactor);
@@ -675,7 +675,7 @@ struct SignalsmithStretch {
675675 auto *predictions = predictionsForChannel (c);
676676 for (int b = 0 ; b < bands; ++b) {
677677 auto mapPoint = outputMap[b];
678- int lowIndex = std::floor (mapPoint.inputBin );
678+ int lowIndex = static_cast < int >( std::floor (mapPoint.inputBin ) );
679679 Sample fracIndex = mapPoint.inputBin - lowIndex;
680680
681681 Prediction &prediction = predictions[b];
@@ -780,7 +780,7 @@ struct SignalsmithStretch {
780780
781781 if (blockProcess.newSpectrum ) {
782782 if (step-- == 0 ) {
783- for (auto &bin : channelBands ) {
783+ for (auto &bin : _channelBands ) {
784784 bin.prevInput = bin.input ;
785785 }
786786 }
@@ -862,7 +862,7 @@ struct SignalsmithStretch {
862862 return ;
863863 }
864864 Sample bottomOffset = peaks[0 ].input - peaks[0 ].output ;
865- for (int b = 0 ; b < std::min< int > (bands, std::ceil (peaks[0 ].output )); ++b) {
865+ for (int b = 0 ; b < std::min (bands, static_cast < int >( std::ceil (peaks[0 ].output ) )); ++b) {
866866 outputMap[b] = {b + bottomOffset, 1 };
867867 }
868868 // Interpolate between points
@@ -872,8 +872,8 @@ struct SignalsmithStretch {
872872 Sample outOffset = prev.input - prev.output ;
873873 Sample outScale = next.input - next.output - prev.input + prev.output ;
874874 Sample gradScale = outScale*rangeScale;
875- int startBin = std::max< int > (0 , std::ceil (prev.output ));
876- int endBin = std::min< int > (bands, std::ceil (next.output ));
875+ int startBin = std::max (0 , static_cast < int >( std::ceil (prev.output ) ));
876+ int endBin = std::min (bands, static_cast < int >( std::ceil (next.output ) ));
877877 for (int b = startBin; b < endBin; ++b) {
878878 Sample r = (b - prev.output )*rangeScale;
879879 Sample h = r*r*(3 - 2 *r);
@@ -886,7 +886,7 @@ struct SignalsmithStretch {
886886 }
887887 }
888888 Sample topOffset = peaks.back ().input - peaks.back ().output ;
889- for (int b = std::max< int > (0 , peaks.back ().output ); b < bands; ++b) {
889+ for (int b = std::max (0 , static_cast < int >( peaks.back ().output ) ); b < bands; ++b) {
890890 outputMap[b] = {b + topOffset, 1 };
891891 }
892892 }
@@ -928,14 +928,14 @@ struct SignalsmithStretch {
928928 int diff = std::abs (peakEstimate - peakIndices[1 ]);
929929 if (diff > peakEstimate/8 && diff < peakEstimate*7 /8 ) peakEstimate = peakEstimate%diff;
930930 if (formantMetric[peakIndices[0 ]] > formantMetric[peakIndices[2 ]]*0.01 ) {
931- int diff = std::abs (peakEstimate - peakIndices[0 ]);
931+ diff = std::abs (peakEstimate - peakIndices[0 ]);
932932 if (diff > peakEstimate/8 && diff < peakEstimate*7 /8 ) peakEstimate = peakEstimate%diff;
933933 }
934934 }
935935 Sample weight = formantMetric[peakIndices[2 ]];
936936 // Smooth it out a bit
937- freqEstimateWeighted += (peakEstimate*weight - freqEstimateWeighted)*0.25 ;
938- freqEstimateWeight += (weight - freqEstimateWeight)*0.25 ;
937+ freqEstimateWeighted += (peakEstimate*weight - freqEstimateWeighted)*Sample ( 0.25 ) ;
938+ freqEstimateWeight += (weight - freqEstimateWeight)*Sample ( 0.25 ) ;
939939
940940 return freqEstimateWeighted/(freqEstimateWeight + Sample (1e-30 ));
941941 }
@@ -961,7 +961,7 @@ struct SignalsmithStretch {
961961 formantMetric[b] = std::sqrt (formantMetric[b]);
962962 }
963963 } else if (step-- == 0 ) {
964- Sample slew = 1 /(freqEstimate*0.5 + 1 );
964+ Sample slew = 1 /(freqEstimate*Sample ( 0.5 ) + 1 );
965965 Sample e = 0 ;
966966 for (size_t repeat = 0 ; repeat < 2 ; ++repeat) {
967967 for (int b = bands - 1 ; b >= 0 ; --b) {
@@ -976,15 +976,15 @@ struct SignalsmithStretch {
976976 } else {
977977 auto getFormant = [&](Sample band) -> Sample {
978978 if (band < 0 ) return 0 ;
979- band = std::min<Sample> (band, bands);
979+ band = std::min (band, static_cast <Sample>( bands) );
980980 int floorBand = std::floor (band);
981981 Sample fracBand = band - floorBand;
982982 Sample low = formantMetric[floorBand], high = formantMetric[floorBand + 1 ];
983983 return low + (high - low)*fracBand;
984984 };
985985
986986 for (int b = 0 ; b < bands; ++b) {
987- Sample inputF = bandToFreq (b );
987+ Sample inputF = bandToFreq (static_cast <Sample>(b) );
988988 Sample outputF = formantCompensation ? mapFreq (inputF) : inputF;
989989 outputF = invMapFormant (outputF);
990990
0 commit comments