* Add OptionThreadingAlways

This commit is contained in:
Chris Cannam
2007-11-26 11:50:29 +00:00
parent 48d640f696
commit 065cc29e5c
3 changed files with 40 additions and 17 deletions

View File

@@ -122,10 +122,15 @@ public:
* *
* OptionThreadingAuto - Permit the stretcher to determine its * OptionThreadingAuto - Permit the stretcher to determine its
* own threading model. Usually this means using one processing * own threading model. Usually this means using one processing
* thread per audio channel in offline mode, and one thread only * thread per audio channel in offline mode if the stretcher is
* in realtime mode. * able to determine that more than one CPU is available, and
* one thread only in realtime mode.
* *
* OptionThreadingNone - Never use more than one thread. * OptionThreadingNever - Never use more than one thread.
*
* OptionThreadingAlways - Use multiple threads in any situation
* where OptionThreadingAuto would do so, except omit the check
* for multiple CPUs and instead assume it to be true.
* *
* 6. Options prefixed OptionWindow control the window size for * 6. Options prefixed OptionWindow control the window size for
* FFT processing. The window size actually used will depend on * FFT processing. The window size actually used will depend on
@@ -162,7 +167,8 @@ public:
static const int OptionPhaseIndependent = 0x00002000; static const int OptionPhaseIndependent = 0x00002000;
static const int OptionThreadingAuto = 0x00000000; static const int OptionThreadingAuto = 0x00000000;
static const int OptionThreadingNone = 0x00010000; static const int OptionThreadingNever = 0x00010000;
static const int OptionThreadingAlways = 0x00020000;
static const int OptionWindowStandard = 0x00000000; static const int OptionWindowStandard = 0x00000000;
static const int OptionWindowShort = 0x00100000; static const int OptionWindowShort = 0x00100000;

View File

@@ -119,16 +119,19 @@ RubberBandStretcher::Impl::Impl(RubberBandStretcher *stretcher,
if (m_channels > 1) { if (m_channels > 1) {
if (!m_realtime && m_threaded = true;
!(m_options & OptionThreadingNone) &&
Thread::threadingAvailable() &&
system_is_multiprocessor()) {
m_threaded = true; if (m_realtime) {
m_threaded = false;
if (m_debugLevel > 0) { } else if (m_options & OptionThreadingNever) {
cerr << "Going multithreaded..." << endl; m_threaded = false;
} } else if (!(m_options & OptionThreadingAlways) &&
!system_is_multiprocessor()) {
m_threaded = false;
}
if (m_threaded && m_debugLevel > 0) {
cerr << "Going multithreaded..." << endl;
} }
} }

View File

@@ -38,7 +38,7 @@ int main(int argc, char **argv)
int debug = 0; int debug = 0;
bool realtime = false; bool realtime = false;
bool precise = false; bool precise = false;
bool threaded = true; int threading = 0;
bool peaklock = true; bool peaklock = true;
bool longwin = false; bool longwin = false;
bool shortwin = false; bool shortwin = false;
@@ -83,6 +83,7 @@ int main(int argc, char **argv)
{ "thresh2", 1, 0, '7' }, { "thresh2", 1, 0, '7' },
{ "bl-transients", 0, 0, '8' }, { "bl-transients", 0, 0, '8' },
{ "no-softening", 0, 0, '9' }, { "no-softening", 0, 0, '9' },
{ "threads", 0, 0, '@' },
{ "quiet", 0, 0, 'q' }, { "quiet", 0, 0, 'q' },
{ 0, 0, 0 } { 0, 0, 0 }
}; };
@@ -99,7 +100,8 @@ int main(int argc, char **argv)
case 'd': debug = atoi(optarg); break; case 'd': debug = atoi(optarg); break;
case 'R': realtime = true; break; case 'R': realtime = true; break;
case 'P': precise = true; break; case 'P': precise = true; break;
case '0': threaded = false; break; case '0': threading = 1; break;
case '@': threading = 2; break;
case '1': transients = NoTransients; break; case '1': transients = NoTransients; break;
case '2': peaklock = false; break; case '2': peaklock = false; break;
case '3': longwin = true; break; case '3': longwin = true; break;
@@ -143,7 +145,8 @@ int main(int argc, char **argv)
cerr << endl; cerr << endl;
cerr << " -P, --precise Aim for minimal time distortion (implied by -R)" << endl; cerr << " -P, --precise Aim for minimal time distortion (implied by -R)" << endl;
cerr << " -R, --realtime Select realtime mode (implies -P --no-threads)" << endl; cerr << " -R, --realtime Select realtime mode (implies -P --no-threads)" << endl;
cerr << " --no-threads No extra threads regardless of cpus/channel count" << endl; cerr << " --no-threads No extra threads regardless of CPU and channel count" << endl;
cerr << " --threads Assume multi-CPU even if only one CPU is identified" << endl;
cerr << " --no-transients Disable phase resynchronisation at transients" << endl; cerr << " --no-transients Disable phase resynchronisation at transients" << endl;
cerr << " --bl-transients Band-limit phase resync to extreme frequencies" << endl; cerr << " --bl-transients Band-limit phase resync to extreme frequencies" << endl;
cerr << " --no-peaklock Disable phase locking to peak frequencies" << endl; cerr << " --no-peaklock Disable phase locking to peak frequencies" << endl;
@@ -217,10 +220,21 @@ int main(int argc, char **argv)
if (precise) options |= RubberBandStretcher::OptionStretchPrecise; if (precise) options |= RubberBandStretcher::OptionStretchPrecise;
if (!peaklock) options |= RubberBandStretcher::OptionPhaseIndependent; if (!peaklock) options |= RubberBandStretcher::OptionPhaseIndependent;
if (!softening) options |= RubberBandStretcher::OptionPhasePeakLocked; if (!softening) options |= RubberBandStretcher::OptionPhasePeakLocked;
if (!threaded) options |= RubberBandStretcher::OptionThreadingNone;
if (longwin) options |= RubberBandStretcher::OptionWindowLong; if (longwin) options |= RubberBandStretcher::OptionWindowLong;
if (shortwin) options |= RubberBandStretcher::OptionWindowShort; if (shortwin) options |= RubberBandStretcher::OptionWindowShort;
switch (threading) {
case 0:
options |= RubberBandStretcher::OptionThreadingAuto;
break;
case 1:
options |= RubberBandStretcher::OptionThreadingNever;
break;
case 2:
options |= RubberBandStretcher::OptionThreadingAlways;
break;
}
switch (transients) { switch (transients) {
case NoTransients: case NoTransients:
options |= RubberBandStretcher::OptionTransientsSmooth; options |= RubberBandStretcher::OptionTransientsSmooth;