From a96c85befca3a1041a27d2ff45f561f7a94e5439 Mon Sep 17 00:00:00 2001 From: Chris Cannam Date: Tue, 8 Jul 2008 16:32:52 +0000 Subject: [PATCH] * Change terminology: peak locking -> lamination (we no longer do peak locking) * Adjustments to lamination code --- README | 8 ++++---- src/StretcherProcess.cpp | 12 ++++++++++-- src/main.cpp | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/README b/README index 4fda3de..0c471a6 100644 --- a/README +++ b/README @@ -19,10 +19,10 @@ Attractive features * High quality results suitable for musical use Rubber Band is a phase-vocoder-based frequency domain time - stretcher with partial phase locking to peak frequencies and phase - resynchronisation at noisy transients. It is suitable for most - musical uses with its default settings, and has a range of options - for fine tuning. + stretcher with phase resynchronisation at noisy transients and a + phase lamination technique to reduce phasiness. It is suitable for + most musical uses with its default settings, and has a range of + options for fine tuning. * Real-time capable diff --git a/src/StretcherProcess.cpp b/src/StretcherProcess.cpp index 033e5c8..7c3f1e7 100644 --- a/src/StretcherProcess.cpp +++ b/src/StretcherProcess.cpp @@ -697,6 +697,8 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel, const int lookback = 1; + double distacc = 0.0; + for (int i = count; i >= 0; i -= lookback) { bool resetThis = phaseReset; @@ -748,9 +750,11 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel, if (inherit) { double inherited = cd.unwrappedPhase[i + lookback] - cd.prevPhase[i + lookback]; - advance = ((advance * distance) + (inherited * (mi - distance))) - / mi; + advance = ((advance * distance) + + (inherited * (maxdist - distance))) + / maxdist; outphase = p + advance; + distacc += distance; distance += 1.0; } else { outphase = cd.unwrappedPhase[i] + advance; @@ -770,6 +774,10 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel, cd.unwrappedPhase[i] = outphase; } + if (m_debugLevel > 1) { + cerr << "mean inheritance distance = " << distacc / count << endl; + } + if (fullReset) unchanged = true; cd.unchanged = unchanged; diff --git a/src/main.cpp b/src/main.cpp index d814840..ea55b77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,7 +72,7 @@ int main(int argc, char **argv) bool realtime = false; bool precise = false; int threading = 0; - bool peaklock = true; + bool lamination = true; bool longwin = false; bool shortwin = false; bool hqpitch = false; @@ -110,7 +110,7 @@ int main(int argc, char **argv) { "formant", 0, 0, 'F' }, { "no-threads", 0, 0, '0' }, { "no-transients", 0, 0, '1' }, - { "no-peaklock", 0, 0, '2' }, + { "no-lamination", 0, 0, '2' }, { "window-long", 0, 0, '3' }, { "window-short", 0, 0, '4' }, { "bl-transients", 0, 0, '8' }, @@ -138,7 +138,7 @@ int main(int argc, char **argv) case '0': threading = 1; break; case '@': threading = 2; break; case '1': transients = NoTransients; crispchanged = true; break; - case '2': peaklock = false; crispchanged = true; break; + case '2': lamination = false; crispchanged = true; break; case '3': longwin = true; crispchanged = true; break; case '4': shortwin = true; crispchanged = true; break; case '8': transients = BandLimitedTransients; crispchanged = true; break; @@ -189,7 +189,7 @@ int main(int argc, char **argv) cerr << " --threads Assume multi-CPU even if only one CPU is identified" << endl; cerr << " --no-transients Disable phase resynchronisation at transients" << endl; cerr << " --bl-transients Band-limit phase resync to extreme frequencies" << endl; - cerr << " --no-peaklock Disable phase locking to peak frequencies" << endl; + cerr << " --no-lamination Disable phase lamination" << endl; cerr << " --window-long Use longer processing window (actual size may vary)" << endl; cerr << " --window-short Use shorter processing window" << endl; cerr << " --pitch-hq In RT mode, use a slower, higher quality pitch shift" << endl; @@ -202,29 +202,29 @@ int main(int argc, char **argv) cerr << " -h, --help Show this help" << endl; cerr << endl; cerr << "\"Crispness\" levels:" << endl; - cerr << " -c 0 equivalent to --no-transients --no-peaklock --window-long" << endl; - cerr << " -c 1 equivalent to --no-transients --no-peaklock" << endl; + cerr << " -c 0 equivalent to --no-transients --no-lamination --window-long" << endl; + cerr << " -c 1 equivalent to --no-transients --no-lamination" << endl; cerr << " -c 2 equivalent to --no-transients" << endl; cerr << " -c 3 equivalent to --bl-transients" << endl; cerr << " -c 4 default processing options" << endl; - cerr << " -c 5 equivalent to --no-peaklock --window-short (may be suitable for drums)" << endl; + cerr << " -c 5 equivalent to --no-lamination --window-short (may be good for drums)" << endl; cerr << endl; return 2; } if (crispness >= 0 && crispchanged) { - cerr << "WARNING: Both crispness option and transients, peaklock or window options" << endl; + cerr << "WARNING: Both crispness option and transients, lamination or window options" << endl; cerr << " provided -- crispness will override these other options" << endl; } switch (crispness) { case -1: crispness = 4; break; - case 0: transients = NoTransients; peaklock = false; longwin = true; shortwin = false; break; - case 1: transients = NoTransients; peaklock = false; longwin = false; shortwin = false; break; - case 2: transients = NoTransients; peaklock = true; longwin = false; shortwin = false; break; - case 3: transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false; break; - case 4: transients = Transients; peaklock = true; longwin = false; shortwin = false; break; - case 5: transients = Transients; peaklock = false; longwin = false; shortwin = true; break; + case 0: transients = NoTransients; lamination = false; longwin = true; shortwin = false; break; + case 1: transients = NoTransients; lamination = false; longwin = false; shortwin = false; break; + case 2: transients = NoTransients; lamination = true; longwin = false; shortwin = false; break; + case 3: transients = BandLimitedTransients; lamination = true; longwin = false; shortwin = false; break; + case 4: transients = Transients; lamination = true; longwin = false; shortwin = false; break; + case 5: transients = Transients; lamination = false; longwin = false; shortwin = true; break; }; if (!quiet) { @@ -285,7 +285,7 @@ int main(int argc, char **argv) RubberBandStretcher::Options options = 0; if (realtime) options |= RubberBandStretcher::OptionProcessRealTime; if (precise) options |= RubberBandStretcher::OptionStretchPrecise; - if (!peaklock) options |= RubberBandStretcher::OptionPhaseIndependent; + if (!lamination) options |= RubberBandStretcher::OptionPhaseIndependent; if (longwin) options |= RubberBandStretcher::OptionWindowLong; if (shortwin) options |= RubberBandStretcher::OptionWindowShort; if (formant) options |= RubberBandStretcher::OptionFormantPreserved;