Remove unused weights

This commit is contained in:
Geraint 2022-11-29 10:43:36 +00:00
parent 8787460488
commit 901df7bf97

View File

@ -35,13 +35,8 @@ struct SignalsmithStretch {
/// Configures using a default preset /// Configures using a default preset
void presetDefault(int nChannels, Sample sampleRate) { void presetDefault(int nChannels, Sample sampleRate) {
configure(nChannels, sampleRate*0.12, sampleRate*0.03); configure(nChannels, sampleRate*0.12, sampleRate*0.03);
freqWeight = 1;
timeWeight = 2;
} }
// manual parameters
Sample freqWeight = 1, timeWeight = 2, maxWeight = 2;
/// Manual setup /// Manual setup
void configure(int nChannels, int blockSamples, int intervalSamples) { void configure(int nChannels, int blockSamples, int intervalSamples) {
channels = nChannels; channels = nChannels;
@ -245,7 +240,7 @@ private:
int outputInterval = stft.interval(); int outputInterval = stft.interval();
int bands = stft.bands(); int bands = stft.bands();
Sample rate = Sample(inputInterval)/outputInterval; Sample rate = outputInterval/std::max<Sample>(1, inputInterval);
if (inputInterval > 0) { if (inputInterval > 0) {
for (int c = 0; c < channels; ++c) { for (int c = 0; c < channels; ++c) {
@ -321,54 +316,28 @@ private:
auto &outputBin = bins[b]; auto &outputBin = bins[b];
auto mapPoint = outputMap[b]; auto mapPoint = outputMap[b];
Complex phase = prediction.freqPrediction*freqWeight; Complex phase = 0;
// Track the strongest prediction
Complex maxPrediction = prediction.freqPrediction;
Sample maxPredictionNorm = std::norm(maxPrediction);
// Short steps // Short steps
if (b > 0) { if (b > 0) {
auto &otherBin = bins[b - 1]; auto &otherBin = bins[b - 1];
Complex newPrediction = otherBin.output*prediction.shortVerticalTwist; phase += otherBin.output*prediction.shortVerticalTwist;
phase += newPrediction*timeWeight;
if (std::norm(newPrediction) > maxPredictionNorm) {
maxPredictionNorm = std::norm(newPrediction);
maxPrediction = newPrediction;
}
} }
if (b < stft.bands() - 1) { if (b < stft.bands() - 1) {
auto &otherBin = bins[b + 1]; auto &otherBin = bins[b + 1];
auto &otherPrediction = predictions[b + 1]; auto &otherPrediction = predictions[b + 1];
Complex newPrediction = otherBin.output*std::conj(otherPrediction.shortVerticalTwist); phase += otherBin.output*std::conj(otherPrediction.shortVerticalTwist);
phase += newPrediction*timeWeight;
if (std::norm(newPrediction) > maxPredictionNorm) {
maxPredictionNorm = std::norm(newPrediction);
maxPrediction = newPrediction;
}
} }
// longer verticals // longer verticals
if (b > longVerticalStep) { if (b > longVerticalStep) {
auto &otherBin = bins[b - longVerticalStep]; auto &otherBin = bins[b - longVerticalStep];
Complex newPrediction = otherBin.output*prediction.longVerticalTwist; phase += otherBin.output*prediction.longVerticalTwist;
phase += newPrediction*timeWeight;
if (std::norm(newPrediction) > maxPredictionNorm) {
maxPredictionNorm = std::norm(newPrediction);
maxPrediction = newPrediction;
}
} }
if (b < stft.bands() - longVerticalStep) { if (b < stft.bands() - longVerticalStep) {
auto &otherBin = bins[b + longVerticalStep]; auto &otherBin = bins[b + longVerticalStep];
auto &otherPrediction = predictions[b + longVerticalStep]; auto &otherPrediction = predictions[b + longVerticalStep];
Complex newPrediction = otherBin.output*std::conj(otherPrediction.longVerticalTwist); phase += otherBin.output*std::conj(otherPrediction.longVerticalTwist);
phase += newPrediction*timeWeight;
if (std::norm(newPrediction) > maxPredictionNorm) {
maxPredictionNorm = std::norm(newPrediction);
maxPrediction = newPrediction;
} }
}
phase += maxPrediction*maxWeight;
Sample phaseNorm = std::norm(phase); Sample phaseNorm = std::norm(phase);
if (phaseNorm > 1e-15) { if (phaseNorm > 1e-15) {