Minor tidy

This commit is contained in:
Chris Cannam
2024-06-13 13:16:34 +01:00
parent da9c586745
commit b4b11d451f
3 changed files with 24 additions and 40 deletions

View File

@@ -30,10 +30,9 @@
using namespace RubberBand; using namespace RubberBand;
using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
using std::min; using std::string;
#ifdef RB_PLUGIN_LADSPA #ifdef RB_PLUGIN_LADSPA
@@ -342,18 +341,18 @@ RubberBandLivePitchShifter::instantiate(const LV2_Descriptor *desc, double rate,
const char *, const LV2_Feature *const *) const char *, const LV2_Feature *const *)
{ {
if (rate < 1.0) { if (rate < 1.0) {
std::cerr << "RubberBandLivePitchShifter::instantiate: invalid sample rate " cerr << "RubberBandLivePitchShifter::instantiate: invalid sample rate "
<< rate << " provided" << std::endl; << rate << " provided" << endl;
return nullptr; return nullptr;
} }
size_t srate = size_t(round(rate)); size_t srate = size_t(round(rate));
if (std::string(desc->URI) == lv2DescriptorMono.URI) { if (string(desc->URI) == lv2DescriptorMono.URI) {
return new RubberBandLivePitchShifter(srate, 1); return new RubberBandLivePitchShifter(srate, 1);
} else if (std::string(desc->URI) == lv2DescriptorStereo.URI) { } else if (string(desc->URI) == lv2DescriptorStereo.URI) {
return new RubberBandLivePitchShifter(srate, 2); return new RubberBandLivePitchShifter(srate, 2);
} else { } else {
std::cerr << "RubberBandLivePitchShifter::instantiate: unrecognised URI " cerr << "RubberBandLivePitchShifter::instantiate: unrecognised URI "
<< desc->URI << " requested" << std::endl; << desc->URI << " requested" << endl;
return nullptr; return nullptr;
} }
} }
@@ -469,20 +468,6 @@ RubberBandLivePitchShifter::updateRatio()
// inconsistencies between hosts if some respect the hints more // inconsistencies between hosts if some respect the hints more
// than others // than others
#ifdef RB_PLUGIN_LADSPA
// But we don't want to change the long-standing behaviour of the
// LADSPA plugin, so let's leave this as-is and only do "the right
// thing" for LV2
double oct = (m_octaves ? *m_octaves : 0.0);
oct += (m_semitones ? *m_semitones : 0.0) / 12;
oct += (m_cents ? *m_cents : 0.0) / 1200;
m_ratio = pow(2.0, oct);
#else
// LV2
double octaves = round(m_octaves ? *m_octaves : 0.0); double octaves = round(m_octaves ? *m_octaves : 0.0);
if (octaves < -2.0) octaves = -2.0; if (octaves < -2.0) octaves = -2.0;
if (octaves > 2.0) octaves = 2.0; if (octaves > 2.0) octaves = 2.0;
@@ -499,7 +484,6 @@ RubberBandLivePitchShifter::updateRatio()
octaves + octaves +
semitones / 12.0 + semitones / 12.0 +
cents / 1200.0); cents / 1200.0);
#endif
} }
void void

View File

@@ -34,6 +34,7 @@ using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
using std::min; using std::min;
using std::string;
#ifdef RB_PLUGIN_LADSPA #ifdef RB_PLUGIN_LADSPA
@@ -356,18 +357,18 @@ RubberBandPitchShifter::instantiate(const LV2_Descriptor *desc, double rate,
const char *, const LV2_Feature *const *) const char *, const LV2_Feature *const *)
{ {
if (rate < 1.0) { if (rate < 1.0) {
std::cerr << "RubberBandPitchShifter::instantiate: invalid sample rate " cerr << "RubberBandPitchShifter::instantiate: invalid sample rate "
<< rate << " provided" << std::endl; << rate << " provided" << endl;
return nullptr; return nullptr;
} }
size_t srate = size_t(round(rate)); size_t srate = size_t(round(rate));
if (std::string(desc->URI) == lv2DescriptorMono.URI) { if (string(desc->URI) == lv2DescriptorMono.URI) {
return new RubberBandPitchShifter(srate, 1); return new RubberBandPitchShifter(srate, 1);
} else if (std::string(desc->URI) == lv2DescriptorStereo.URI) { } else if (string(desc->URI) == lv2DescriptorStereo.URI) {
return new RubberBandPitchShifter(srate, 2); return new RubberBandPitchShifter(srate, 2);
} else { } else {
std::cerr << "RubberBandPitchShifter::instantiate: unrecognised URI " cerr << "RubberBandPitchShifter::instantiate: unrecognised URI "
<< desc->URI << " requested" << std::endl; << desc->URI << " requested" << endl;
return nullptr; return nullptr;
} }
} }

View File

@@ -30,10 +30,9 @@
using namespace RubberBand; using namespace RubberBand;
using std::cout;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
using std::min; using std::string;
#ifdef RB_PLUGIN_LADSPA #ifdef RB_PLUGIN_LADSPA
@@ -341,18 +340,18 @@ RubberBandR3PitchShifter::instantiate(const LV2_Descriptor *desc, double rate,
const char *, const LV2_Feature *const *) const char *, const LV2_Feature *const *)
{ {
if (rate < 1.0) { if (rate < 1.0) {
std::cerr << "RubberBandR3PitchShifter::instantiate: invalid sample rate " cerr << "RubberBandR3PitchShifter::instantiate: invalid sample rate "
<< rate << " provided" << std::endl; << rate << " provided" << endl;
return nullptr; return nullptr;
} }
size_t srate = size_t(round(rate)); size_t srate = size_t(round(rate));
if (std::string(desc->URI) == lv2DescriptorMono.URI) { if (string(desc->URI) == lv2DescriptorMono.URI) {
return new RubberBandR3PitchShifter(srate, 1); return new RubberBandR3PitchShifter(srate, 1);
} else if (std::string(desc->URI) == lv2DescriptorStereo.URI) { } else if (string(desc->URI) == lv2DescriptorStereo.URI) {
return new RubberBandR3PitchShifter(srate, 2); return new RubberBandR3PitchShifter(srate, 2);
} else { } else {
std::cerr << "RubberBandR3PitchShifter::instantiate: unrecognised URI " cerr << "RubberBandR3PitchShifter::instantiate: unrecognised URI "
<< desc->URI << " requested" << std::endl; << desc->URI << " requested" << endl;
return nullptr; return nullptr;
} }
} }