Fix MSVC warnings up to level 2 (#7329)
* Fix MSVC warnings up to /W2 * Fix large shift UB warning
This commit is contained in:
@@ -132,9 +132,10 @@ private:
|
||||
|
||||
namespace {
|
||||
|
||||
auto sizeToHighAndLow(std::size_t size) -> std::pair<DWORD, DWORD>
|
||||
template<typename T>
|
||||
auto sizeToHighAndLow(T size) -> std::pair<DWORD, DWORD>
|
||||
{
|
||||
if constexpr(sizeof(std::size_t) <= sizeof(DWORD)) {
|
||||
if constexpr (sizeof(T) <= sizeof(DWORD)) {
|
||||
return {0, size};
|
||||
} else {
|
||||
return {static_cast<DWORD>(size >> 32), static_cast<DWORD>(size)};
|
||||
|
||||
@@ -189,7 +189,7 @@ const AutomatableModel * AutomationClip::firstObject() const
|
||||
return model;
|
||||
}
|
||||
|
||||
static FloatModel fm(0, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, 0.001);
|
||||
static FloatModel fm(0, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, 0.001f);
|
||||
return &fm;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,13 +97,13 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters(
|
||||
Model * _parent ) :
|
||||
Model( _parent ),
|
||||
m_used( false ),
|
||||
m_predelayModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env pre-delay" ) ),
|
||||
m_attackModel( 0.0, 0.0, 2.0, 0.001, this, tr( "Env attack" ) ),
|
||||
m_holdModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Env hold" ) ),
|
||||
m_decayModel( 0.5, 0.0, 2.0, 0.001, this, tr( "Env decay" ) ),
|
||||
m_sustainModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Env sustain" ) ),
|
||||
m_releaseModel( 0.1, 0.0, 2.0, 0.001, this, tr( "Env release" ) ),
|
||||
m_amountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "Env mod amount" ) ),
|
||||
m_predelayModel(0.f, 0.f, 2.f, 0.001f, this, tr("Env pre-delay")),
|
||||
m_attackModel(0.f, 0.f, 2.f, 0.001f, this, tr("Env attack")),
|
||||
m_holdModel(0.5f, 0.f, 2.f, 0.001f, this, tr("Env hold")),
|
||||
m_decayModel(0.5f, 0.f, 2.f, 0.001f, this, tr("Env decay")),
|
||||
m_sustainModel(0.5f, 0.f, 1.f, 0.001f, this, tr("Env sustain")),
|
||||
m_releaseModel(0.1f, 0.f, 2.f, 0.001f, this, tr("Env release")),
|
||||
m_amountModel(0.f, -1.f, 1.f, 0.005f, this, tr("Env mod amount")),
|
||||
m_valueForZeroAmount( _value_for_zero_amount ),
|
||||
m_pahdFrames( 0 ),
|
||||
m_rFrames( 0 ),
|
||||
@@ -111,12 +111,12 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters(
|
||||
m_rEnv( nullptr ),
|
||||
m_pahdBufSize( 0 ),
|
||||
m_rBufSize( 0 ),
|
||||
m_lfoPredelayModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO pre-delay" ) ),
|
||||
m_lfoAttackModel( 0.0, 0.0, 1.0, 0.001, this, tr( "LFO attack" ) ),
|
||||
m_lfoSpeedModel( 0.1, 0.001, 1.0, 0.0001,
|
||||
SECS_PER_LFO_OSCILLATION * 1000.0, this,
|
||||
tr( "LFO frequency" ) ),
|
||||
m_lfoAmountModel( 0.0, -1.0, 1.0, 0.005, this, tr( "LFO mod amount" ) ),
|
||||
m_lfoPredelayModel(0.f, 0.f, 1.f, 0.001f, this, tr("LFO pre-delay")),
|
||||
m_lfoAttackModel(0.f, 0.f, 1.f, 0.001f, this, tr("LFO attack")),
|
||||
m_lfoSpeedModel(0.1f, 0.001f, 1.f, 0.0001f,
|
||||
SECS_PER_LFO_OSCILLATION * 1000.f, this,
|
||||
tr("LFO frequency")),
|
||||
m_lfoAmountModel(0.f, -1.f, 1.f, 0.005f, this, tr("LFO mod amount")),
|
||||
m_lfoWaveModel( static_cast<int>(LfoShape::SineWave), 0, NumLfoShapes, this, tr( "LFO wave shape" ) ),
|
||||
m_x100Model( false, this, tr( "LFO frequency x 100" ) ),
|
||||
m_controlEnvAmountModel( false, this, tr( "Modulate env amount" ) ),
|
||||
|
||||
@@ -64,7 +64,7 @@ InstrumentSoundShaping::InstrumentSoundShaping(
|
||||
m_filterEnabledModel( false, this ),
|
||||
m_filterModel( this, tr( "Filter type" ) ),
|
||||
m_filterCutModel( 14000.0, 1.0, 14000.0, 1.0, this, tr( "Cutoff frequency" ) ),
|
||||
m_filterResModel( 0.5, BasicFilters<>::minQ(), 10.0, 0.01, this, tr( "Q/Resonance" ) )
|
||||
m_filterResModel(0.5f, BasicFilters<>::minQ(), 10.f, 0.01f, this, tr("Q/Resonance"))
|
||||
{
|
||||
for( int i = 0; i < NumTargets; ++i )
|
||||
{
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace lmms
|
||||
|
||||
LfoController::LfoController( Model * _parent ) :
|
||||
Controller( ControllerType::Lfo, _parent, tr( "LFO Controller" ) ),
|
||||
m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
|
||||
m_speedModel( 2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Oscillator speed" ) ),
|
||||
m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Oscillator amount" ) ),
|
||||
m_baseModel(0.5f, 0.f, 1.f, 0.001f, this, tr("Base value")),
|
||||
m_speedModel(2.f, 0.01f, 20.f, 0.0001f, 20000.f, this, tr("Oscillator speed")),
|
||||
m_amountModel(1.f, -1.f, 1.f, 0.005f, this, tr("Oscillator amount")),
|
||||
m_phaseModel( 0.0, 0.0, 360.0, 4.0, this, tr( "Oscillator phase" ) ),
|
||||
m_waveModel( static_cast<int>(Oscillator::WaveShape::Sine), 0, Oscillator::NumWaveShapes,
|
||||
this, tr( "Oscillator waveform" ) ),
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace lmms
|
||||
MixerRoute::MixerRoute( MixerChannel * from, MixerChannel * to, float amount ) :
|
||||
m_from( from ),
|
||||
m_to( to ),
|
||||
m_amount( amount, 0, 1, 0.001, nullptr,
|
||||
tr( "Amount to send from channel %1 to channel %2" ).arg( m_from->m_channelIndex ).arg( m_to->m_channelIndex ) )
|
||||
m_amount(amount, 0, 1, 0.001f, nullptr,
|
||||
tr("Amount to send from channel %1 to channel %2").arg(m_from->m_channelIndex).arg(m_to->m_channelIndex))
|
||||
{
|
||||
//qDebug( "created: %d to %d", m_from->m_channelIndex, m_to->m_channelIndex );
|
||||
// create send amount model
|
||||
@@ -67,7 +67,7 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) :
|
||||
m_buffer( new sampleFrame[Engine::audioEngine()->framesPerPeriod()] ),
|
||||
m_muteModel( false, _parent ),
|
||||
m_soloModel( false, _parent ),
|
||||
m_volumeModel( 1.0, 0.0, 2.0, 0.001, _parent ),
|
||||
m_volumeModel(1.f, 0.f, 2.f, 0.001f, _parent),
|
||||
m_name(),
|
||||
m_lock(),
|
||||
m_channelIndex( idx ),
|
||||
|
||||
@@ -122,13 +122,13 @@ int precomputeWindow(float *window, unsigned int length, FFTWindow type, bool no
|
||||
gain = 1;
|
||||
return 0;
|
||||
case FFTWindow::BlackmanHarris:
|
||||
a0 = 0.35875;
|
||||
a1 = 0.48829;
|
||||
a2 = 0.14128;
|
||||
a3 = 0.01168;
|
||||
a0 = 0.35875f;
|
||||
a1 = 0.48829f;
|
||||
a2 = 0.14128f;
|
||||
a3 = 0.01168f;
|
||||
break;
|
||||
case FFTWindow::Hamming:
|
||||
a0 = 0.54;
|
||||
a0 = 0.54f;
|
||||
a1 = 1.0 - a0;
|
||||
a2 = 0;
|
||||
a3 = 0;
|
||||
@@ -204,11 +204,11 @@ int compressbands(const float *absspec_buffer, float *compressedband, int num_ol
|
||||
|
||||
float j_min = (i * ratio) + bottom;
|
||||
|
||||
if (j_min < 0) {j_min = bottom;}
|
||||
if (j_min < 0) { j_min = static_cast<float>(bottom); }
|
||||
|
||||
float j_max = j_min + ratio;
|
||||
|
||||
for (float j = (int)j_min; j <= j_max; j++)
|
||||
for (float j = std::floor(j_min); j <= j_max; j++)
|
||||
{
|
||||
compressedband[i] += absspec_buffer[(int)j];
|
||||
}
|
||||
|
||||
@@ -76,12 +76,12 @@ LV2_URID UridMap::map(const char *uri)
|
||||
if (itr == m_map.end())
|
||||
{
|
||||
// 1 is the first free URID
|
||||
std::size_t index = 1u + m_unMap.size();
|
||||
const auto index = static_cast<LV2_URID>(1u + m_unMap.size());
|
||||
auto pr = m_map.emplace(std::move(uriStr), index);
|
||||
if (pr.second)
|
||||
{
|
||||
m_unMap.emplace_back(pr.first->first.c_str());
|
||||
result = static_cast<LV2_URID>(index);
|
||||
result = index;
|
||||
}
|
||||
}
|
||||
else { result = itr->second; }
|
||||
|
||||
@@ -120,7 +120,7 @@ AutomationEditor::AutomationEditor() :
|
||||
//keeps the direction of the widget, undepended on the locale
|
||||
setLayoutDirection( Qt::LeftToRight );
|
||||
|
||||
m_tensionModel = new FloatModel(1.0, 0.0, 1.0, 0.01);
|
||||
m_tensionModel = new FloatModel(1.f, 0.f, 1.f, 0.01f);
|
||||
connect( m_tensionModel, SIGNAL(dataChanged()),
|
||||
this, SLOT(setTension()));
|
||||
|
||||
@@ -2107,7 +2107,7 @@ AutomationEditorWindow::AutomationEditorWindow() :
|
||||
|
||||
for( float const & zoomLevel : m_editor->m_zoomXLevels )
|
||||
{
|
||||
m_editor->m_zoomingXModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
|
||||
m_editor->m_zoomingXModel.addItem(QString("%1%").arg(zoomLevel * 100));
|
||||
}
|
||||
m_editor->m_zoomingXModel.setValue( m_editor->m_zoomingXModel.findText( "100%" ) );
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ PianoRoll::PianoRoll() :
|
||||
// setup zooming-stuff
|
||||
for( float const & zoomLevel : m_zoomLevels )
|
||||
{
|
||||
m_zoomingModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
|
||||
m_zoomingModel.addItem(QString("%1%").arg(zoomLevel * 100));
|
||||
}
|
||||
m_zoomingModel.setValue( m_zoomingModel.findText( "100%" ) );
|
||||
connect( &m_zoomingModel, SIGNAL(dataChanged()),
|
||||
@@ -323,7 +323,7 @@ PianoRoll::PianoRoll() :
|
||||
// zoom y
|
||||
for (float const & zoomLevel : m_zoomYLevels)
|
||||
{
|
||||
m_zoomingYModel.addItem(QString( "%1\%" ).arg(zoomLevel * 100));
|
||||
m_zoomingYModel.addItem(QString("%1%").arg(zoomLevel * 100));
|
||||
}
|
||||
m_zoomingYModel.setValue(m_zoomingYModel.findText("100%"));
|
||||
connect(&m_zoomingYModel, SIGNAL(dataChanged()),
|
||||
|
||||
@@ -295,7 +295,7 @@ ControllerConnectionDialog::~ControllerConnectionDialog()
|
||||
void ControllerConnectionDialog::selectController()
|
||||
{
|
||||
// Midi
|
||||
if( m_midiGroupBox->model()->value() > 0 )
|
||||
if (m_midiGroupBox->model()->value())
|
||||
{
|
||||
if( m_midiControllerSpinBox->model()->value() > 0 )
|
||||
{
|
||||
@@ -321,8 +321,7 @@ void ControllerConnectionDialog::selectController()
|
||||
// User
|
||||
else
|
||||
{
|
||||
if( m_userGroupBox->model()->value() > 0 &&
|
||||
Engine::getSong()->controllers().size() )
|
||||
if (m_userGroupBox->model()->value() && Engine::getSong()->controllers().size())
|
||||
{
|
||||
m_controller = Engine::getSong()->controllers().at(
|
||||
m_userController->model()->value() );
|
||||
|
||||
@@ -282,7 +282,7 @@ void Fader::paintEvent(QPaintEvent* ev)
|
||||
|
||||
void Fader::paintLevels(QPaintEvent* ev, QPainter& painter, bool linear)
|
||||
{
|
||||
std::function<float(float value)> mapper = [this](float value) { return ampToDbfs(qMax<float>(0.0001, value)); };
|
||||
std::function<float(float value)> mapper = [this](float value) { return ampToDbfs(qMax(0.0001f, value)); };
|
||||
|
||||
if (linear)
|
||||
{
|
||||
@@ -376,7 +376,7 @@ void Fader::paintLevels(QPaintEvent* ev, QPainter& painter, bool linear)
|
||||
// is the minimum value and that all other values lie inbetween. Otherwise
|
||||
// there will be warnings when the gradient is defined.
|
||||
const float mappedClipStarts(mapper(dbfsToAmp(0.f)));
|
||||
const float mappedWarnEnd(mapper(dbfsToAmp(-0.01)));
|
||||
const float mappedWarnEnd(mapper(dbfsToAmp(-0.01f)));
|
||||
const float mappedWarnStart(mapper(dbfsToAmp(-6.f)));
|
||||
const float mappedOkEnd(mapper(dbfsToAmp(-12.f)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user