diff --git a/CMakeLists.txt b/CMakeLists.txt index a9dbda4ccbd..9a6d97e8d87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -646,22 +646,26 @@ option(USE_WERROR "Treat compiler warnings as errors" OFF) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") set(COMPILE_ERROR_FLAGS "-Wall" # Enable most warnings by default - "-Werror=unused-function" # Unused functions are an error - # TODO: Fix the code and remove the following: - "-Wno-sign-compare" # Permit comparisons between signed and unsigned integers - "-Wno-strict-overflow" # Permit optimisations assuming no signed overflow ) set(THIRD_PARTY_COMPILE_ERROR_FLAGS "-w" # Disable all warnings ) - # Due to a regression in gcc-4.8.X, we need to disable array-bounds check - # TODO: Is this still necessary? if(CMAKE_COMPILER_IS_GNUCXX) list(APPEND COMPILE_ERROR_FLAGS + # The following warning generates false positives that are difficult + # to work around, in particular when inlining calls to standard + # algorithms performed on single-element arrays. See, for example, + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111273. "-Wno-array-bounds" # Permit out-of-bounds array subscripts - "-Wno-attributes" # Permit unrecognised attributes ) + + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11") + list(APPEND COMPILE_ERROR_FLAGS + # This has the same problems described above for "array-bounds". + "-Wno-stringop-overread" # Permit string functions overreading the source + ) + endif() endif() if(USE_WERROR) diff --git a/include/AudioEngineWorkerThread.h b/include/AudioEngineWorkerThread.h index b76235aa125..60a5ef8104d 100644 --- a/include/AudioEngineWorkerThread.h +++ b/include/AudioEngineWorkerThread.h @@ -71,8 +71,8 @@ class AudioEngineWorkerThread : public QThread private: std::atomic m_items[JOB_QUEUE_SIZE]; - std::atomic_int m_writeIndex; - std::atomic_int m_itemsDone; + std::atomic_size_t m_writeIndex; + std::atomic_size_t m_itemsDone; OperationMode m_opMode; } ; diff --git a/include/AudioPortAudio.h b/include/AudioPortAudio.h index dbe750c4f82..fbfa9b60dd6 100644 --- a/include/AudioPortAudio.h +++ b/include/AudioPortAudio.h @@ -84,11 +84,7 @@ class AudioPortAudio : public AudioDevice return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "PortAudio" ); } - - int process_callback( const float *_inputBuffer, - float * _outputBuffer, - unsigned long _framesPerBuffer ); - + int process_callback(const float* _inputBuffer, float* _outputBuffer, f_cnt_t _framesPerBuffer); class setupWidget : public gui::AudioDeviceSetupWidget { @@ -151,8 +147,8 @@ class AudioPortAudio : public AudioDevice bool m_wasPAInitError; SampleFrame* m_outBuf; - int m_outBufPos; - int m_outBufSize; + std::size_t m_outBufPos; + fpp_t m_outBufSize; bool m_stopped; diff --git a/include/BufferManager.h b/include/BufferManager.h index 98f6703db02..84602f1215d 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -39,10 +39,6 @@ class LMMS_EXPORT BufferManager public: static void init( fpp_t fpp ); static SampleFrame* acquire(); - // audio-buffer-mgm - static void clear( SampleFrame* ab, const f_cnt_t frames, - const f_cnt_t offset = 0 ); - static void release( SampleFrame* buf ); private: diff --git a/include/LocklessAllocator.h b/include/LocklessAllocator.h index d44b9954374..1652ac71d66 100644 --- a/include/LocklessAllocator.h +++ b/include/LocklessAllocator.h @@ -50,8 +50,8 @@ class LocklessAllocator std::atomic_int * m_freeState; size_t m_freeStateSets; - std::atomic_int m_available; - std::atomic_int m_startIndex; + std::atomic_size_t m_available; + std::atomic_size_t m_startIndex; } ; diff --git a/include/MidiEvent.h b/include/MidiEvent.h index 9a14e427c44..453f6541098 100644 --- a/include/MidiEvent.h +++ b/include/MidiEvent.h @@ -190,6 +190,8 @@ class MidiEvent setParam( 0, pitchBend ); } + auto sysExData() const -> const char* { return m_sysExData; } + Source source() const { return m_source; @@ -212,7 +214,7 @@ class MidiEvent int32_t m_sysExDataLen; // len of m_sysExData } m_data; - [[maybe_unused]] const char* m_sysExData; + const char* m_sysExData; const void* m_sourcePort; // Stores the source of the MidiEvent: Internal or External (hardware controllers). diff --git a/include/Mixer.h b/include/Mixer.h index e65bde010b9..d74f9c11c9b 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -79,7 +79,7 @@ class MixerChannel : public ThreadableJob auto color() const -> const std::optional& { return m_color; } void setColor(const std::optional& color) { m_color = color; } - std::atomic_int m_dependenciesMet; + std::atomic_size_t m_dependenciesMet; void incrementDeps(); void processed(); diff --git a/include/Oscillator.h b/include/Oscillator.h index f537044dc93..0a5e166dc9e 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -170,12 +170,8 @@ class LMMS_EXPORT Oscillator { if (buffer == nullptr || buffer->size() == 0) { return 0; } const auto frames = buffer->size(); - const auto frame = sample * frames; - auto f1 = static_cast(frame) % frames; - if (f1 < 0) - { - f1 += frames; - } + const auto frame = absFraction(sample) * frames; + const auto f1 = static_cast(frame); return linearInterpolate(buffer->data()[f1][0], buffer->data()[(f1 + 1) % frames][0], fraction(frame)); } @@ -190,12 +186,8 @@ class LMMS_EXPORT Oscillator inline wtSampleControl getWtSampleControl(const float sample) const { wtSampleControl control; - control.frame = sample * OscillatorConstants::WAVETABLE_LENGTH; - control.f1 = static_cast(control.frame) % OscillatorConstants::WAVETABLE_LENGTH; - if (control.f1 < 0) - { - control.f1 += OscillatorConstants::WAVETABLE_LENGTH; - } + control.frame = absFraction(sample) * OscillatorConstants::WAVETABLE_LENGTH; + control.f1 = static_cast(control.frame); control.f2 = control.f1 < OscillatorConstants::WAVETABLE_LENGTH - 1 ? control.f1 + 1 : 0; diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index d4676b52e79..a2e2e08d62b 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -189,13 +189,11 @@ private slots: void processErrored(QProcess::ProcessError err ); } ; - -LMMS_EXPORT inline std::string QSTR_TO_STDSTR(QString const& qstr) +inline std::string QSTR_TO_STDSTR(QString const& qstr) { return qstr.toStdString(); } - } // namespace lmms #endif // LMMS_REMOTE_PLUGIN_H diff --git a/include/RmsHelper.h b/include/RmsHelper.h index fd2c0f9bbd2..a50d5ff6d2b 100644 --- a/include/RmsHelper.h +++ b/include/RmsHelper.h @@ -36,7 +36,7 @@ namespace lmms class RmsHelper { public: - RmsHelper( int size ) : + RmsHelper(std::size_t size) : m_buffer( nullptr ) { setSize( size ); @@ -46,7 +46,7 @@ class RmsHelper if( m_buffer ) delete[] m_buffer; } - inline void setSize( int size ) + void setSize(std::size_t size) { if( m_buffer ) { @@ -90,8 +90,8 @@ class RmsHelper private: float * m_buffer; float m_sum; - unsigned int m_pos; - unsigned int m_size; + std::size_t m_pos; + std::size_t m_size; float m_sizef; }; diff --git a/include/Track.h b/include/Track.h index b801bb1828b..db33900f5da 100644 --- a/include/Track.h +++ b/include/Track.h @@ -127,7 +127,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject void deleteClips(); int numOfClips(); - Clip * getClip( int clipNum ); + auto getClip(std::size_t clipNum) -> Clip*; int getClipNum(const Clip* clip ); const clipVector & getClips() const diff --git a/include/fft_helpers.h b/include/fft_helpers.h index cd4e5f88db4..80c69a0a35a 100644 --- a/include/fft_helpers.h +++ b/include/fft_helpers.h @@ -37,7 +37,7 @@ namespace lmms // NOTE: FFT_BUFFER_SIZE should be considered deprecated! // It is used by Eq plugin and some older code here, but this should be a user // switchable parameter, not a constant. Use a value from FFT_BLOCK_SIZES -const unsigned int FFT_BUFFER_SIZE = 2048; +constexpr auto FFT_BUFFER_SIZE = std::size_t{2048}; // Allowed FFT block sizes. Ranging from barely useful to barely acceptable // because of performance and latency reasons. diff --git a/include/lmms_math.h b/include/lmms_math.h index bf5e53a2b53..0da3b9b3dc9 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -61,10 +61,9 @@ static inline float fraction( const float _x ) * If the result is interpreted as a phase of an oscillator, it makes that negative phases are * converted to positive phases. */ -static inline float absFraction( const float _x ) +static inline float absFraction(const float x) { - return( _x - ( _x >= 0.0f ? static_cast( _x ) : - static_cast( _x ) - 1 ) ); + return x - std::floor(x); } /*! diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index b10c065b29d..4cc14ba9cdb 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -123,7 +123,7 @@ void AudioFileProcessor::playNote( NotePlayHandle * _n, if( !_n->m_pluginData ) { - if (m_stutterModel.value() == true && m_nextPlayStartPoint >= m_sample.endFrame()) + if (m_stutterModel.value() == true && m_nextPlayStartPoint >= static_cast(m_sample.endFrame())) { // Restart playing the note if in stutter mode, not in loop mode, // and we're at the end of the sample. @@ -288,7 +288,7 @@ auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> f_cnt_t * Engine::audioEngine()->outputSampleRate() / Engine::audioEngine()->baseSampleRate(); - const auto startFrame = m_nextPlayStartPoint >= m_sample.endFrame() + const auto startFrame = m_nextPlayStartPoint >= static_cast(m_sample.endFrame()) ? m_sample.startFrame() : m_nextPlayStartPoint; const auto duration = m_sample.endFrame() - startFrame; diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 76e8b9681d9..ea1c43acba1 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -153,7 +153,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) // read input buffer and write it to oversampled buffer if( m_rateEnabled ) // rate crushing enabled so do that { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { for( int o = 0; o < OS_RATE; ++o ) { @@ -180,7 +180,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) } else // rate crushing disabled: simply oversample with zero-order hold { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { for( int o = 0; o < OS_RATE; ++o ) { @@ -196,7 +196,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) // the oversampled buffer is now written, so filter it to reduce aliasing - for( int f = 0; f < frames * OS_RATE; ++f ) + for (auto f = std::size_t{0}; f < frames * OS_RATE; ++f) { if( qMax( qAbs( m_buffer[f][0] ), qAbs( m_buffer[f][1] ) ) >= 1.0e-10f ) { @@ -225,7 +225,7 @@ bool BitcrushEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames ) double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { float lsum = 0.0f; float rsum = 0.0f; diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index f5d5aa574a8..e81e655501a 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -205,9 +205,9 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D m_paramsCompleter->setCompletionMode(QCompleter::PopupCompletion); // Add static amount of CarlaParamFloatModel's. - int paramCount = fDescriptor->get_parameter_count(fHandle); + const auto paramCount = fDescriptor->get_parameter_count(fHandle); m_paramModels.reserve(paramCount); - for (int i=0; i < paramCount; ++i) + for (auto i = std::size_t{0}; i < paramCount; ++i) { m_paramModels.push_back(new CarlaParamFloatModel(this)); connect(m_paramModels[i], &CarlaParamFloatModel::dataChanged, @@ -274,7 +274,7 @@ const NativeTimeInfo* CarlaInstrument::handleGetTimeInfo() const void CarlaInstrument::handleUiParameterChanged(const uint32_t index, const float value) const { - if (m_paramModels.count() > index) + if (m_paramModels.size() > index) { m_paramModels[index]->setValue(value); } @@ -369,7 +369,7 @@ void CarlaInstrument::saveSettings(QDomDocument& doc, QDomElement& parent) std::free(state); #if CARLA_VERSION_HEX >= CARLA_MIN_PARAM_VERSION - for (uint32_t index = 0; index < m_paramModels.count(); ++index) + for (uint32_t index = 0; index < m_paramModels.size(); ++index) { QString idStr = CARLA_SETTING_PREFIX + QString::number(index); m_paramModels[index]->saveSettings(doc, parent, idStr); @@ -439,7 +439,7 @@ void CarlaInstrument::refreshParams(bool init) void CarlaInstrument::clearParamModels() { //Delete the models, this also disconnects all connections (automation and controller connections) - for (uint32_t index=0; index < m_paramModels.count(); ++index) + for (uint32_t index = 0; index < m_paramModels.size(); ++index) { delete m_paramModels[index]; } @@ -899,7 +899,7 @@ CarlaParamsView::~CarlaParamsView() m_carlaInstrumentView->m_paramsView = nullptr; // Clear models - if (m_carlaInstrument->m_paramModels.isEmpty() == false) + if (!m_carlaInstrument->m_paramModels.empty()) { m_carlaInstrument->clearParamModels(); } @@ -930,7 +930,7 @@ void CarlaParamsView::filterKnobs() m_maxColumns = m_inputScrollArea->width() / maxKnobWidth; QString text = m_paramsFilterLineEdit->text(); - for (uint32_t i=0; i < m_knobs.count(); ++i) + for (uint32_t i = 0; i < m_knobs.size(); ++i) { // Don't show disabled (unused) knobs. if (!m_carlaInstrument->m_paramModels[i]->enabled()) @@ -975,7 +975,7 @@ void CarlaParamsView::filterKnobs() void CarlaParamsView::refreshKnobs() { // Make sure all the knobs are deleted. - for (uint32_t i=0; i < m_knobs.count(); ++i) + for (uint32_t i = 0; i < m_knobs.size(); ++i) { delete m_knobs[i]; // Delete knob widgets itself. } @@ -996,15 +996,15 @@ void CarlaParamsView::refreshKnobs() m_maxKnobWidthPerGroup[i] = 0; } - if (!m_carlaInstrument->m_paramModels.count()) { return; } + if (m_carlaInstrument->m_paramModels.empty()) { return; } // Make room in QList m_knobs - m_knobs.reserve(m_carlaInstrument->m_paramModels.count()); + m_knobs.reserve(m_carlaInstrument->m_paramModels.size()); QStringList groupNameList; groupNameList.reserve(m_carlaInstrument->m_paramGroupCount); - for (uint32_t i=0; i < m_carlaInstrument->m_paramModels.count(); ++i) + for (uint32_t i = 0; i < m_carlaInstrument->m_paramModels.size(); ++i) { bool enabled = m_carlaInstrument->m_paramModels[i]->enabled(); m_knobs.push_back(new Knob(KnobType::Dark28, m_inputScrollAreaWidgetContent)); @@ -1105,7 +1105,7 @@ void CarlaParamsView::addKnob(uint32_t index) void CarlaParamsView::clearKnobs() { // Remove knobs from layout. - for (uint16_t i=0; i < m_knobs.count(); ++i) + for (uint16_t i = 0; i < m_knobs.size(); ++i) { m_knobs[i]->close(); } diff --git a/plugins/CarlaBase/Carla.h b/plugins/CarlaBase/Carla.h index d8eab5fc43f..f833c4668e6 100644 --- a/plugins/CarlaBase/Carla.h +++ b/plugins/CarlaBase/Carla.h @@ -29,6 +29,8 @@ #define CARLA_MIN_PARAM_VERSION 0x020090 #define CARLA_VERSION_HEX_3 0x30000 +#include + // qt #include #include @@ -223,7 +225,7 @@ private slots: QMutex fMutex; uint8_t m_paramGroupCount; - QList m_paramModels; + std::vector m_paramModels; QDomElement m_settingsElem; QCompleter* m_paramsCompleter; @@ -351,7 +353,7 @@ private slots: CarlaInstrument* const m_carlaInstrument; CarlaInstrumentView* const m_carlaInstrumentView; - QList m_knobs; + std::vector m_knobs; // Keep track of the biggest knob width per group QList m_maxKnobWidthPerGroup; diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index 2784f9b6bba..2142d040c76 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -142,7 +142,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames zeroSampleFrames(m_work, frames); // run temp bands - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { m_tmp1[f][0] = m_lp2.update( buf[f][0], 0 ); m_tmp1[f][1] = m_lp2.update( buf[f][1], 1 ); @@ -153,7 +153,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames // run band 1 if( mute1 ) { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { m_work[f][0] += m_lp1.update( m_tmp1[f][0], 0 ) * m_gain1; m_work[f][1] += m_lp1.update( m_tmp1[f][1], 1 ) * m_gain1; @@ -163,7 +163,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames // run band 2 if( mute2 ) { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { m_work[f][0] += m_hp2.update( m_tmp1[f][0], 0 ) * m_gain2; m_work[f][1] += m_hp2.update( m_tmp1[f][1], 1 ) * m_gain2; @@ -173,7 +173,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames // run band 3 if( mute3 ) { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { m_work[f][0] += m_lp3.update( m_tmp2[f][0], 0 ) * m_gain3; m_work[f][1] += m_lp3.update( m_tmp2[f][1], 1 ) * m_gain3; @@ -183,7 +183,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames // run band 4 if( mute4 ) { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { m_work[f][0] += m_hp4.update( m_tmp2[f][0], 0 ) * m_gain4; m_work[f][1] += m_hp4.update( m_tmp2[f][1], 1 ) * m_gain4; @@ -193,7 +193,7 @@ bool CrossoverEQEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frames const float d = dryLevel(); const float w = wetLevel(); double outSum = 0.0; - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { buf[f][0] = d * buf[f][0] + w * m_work[f][0]; buf[f][1] = d * buf[f][1] + w * m_work[f][1]; diff --git a/plugins/Eq/EqSpectrumView.cpp b/plugins/Eq/EqSpectrumView.cpp index 75be486975c..99df328efec 100644 --- a/plugins/Eq/EqSpectrumView.cpp +++ b/plugins/Eq/EqSpectrumView.cpp @@ -54,7 +54,7 @@ EqAnalyser::EqAnalyser() : const float a2 = 0.14128f; const float a3 = 0.01168f; - for (int i = 0; i < FFT_BUFFER_SIZE; i++) + for (auto i = std::size_t{0}; i < FFT_BUFFER_SIZE; i++) { m_fftWindow[i] = (a0 - a1 * cos(2 * F_PI * i / ((float)FFT_BUFFER_SIZE - 1.0)) + a2 * cos(4 * F_PI * i / ((float)FFT_BUFFER_SIZE - 1.0)) diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index d801e82d465..e9acddeeb15 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -380,9 +380,8 @@ void FreeBoyInstrument::playNote(NotePlayHandle* nph, SampleFrame* workingBuffer papu->writeRegister(0xff23, 128); } - constexpr int bufSize = 2048; - int framesLeft = frames; - int dataLen = 0; + constexpr auto bufSize = f_cnt_t{2048}; + auto framesLeft = frames; auto buf = std::array{}; while (framesLeft > 0) { @@ -392,12 +391,11 @@ void FreeBoyInstrument::playNote(NotePlayHandle* nph, SampleFrame* workingBuffer papu->endFrame(FRAME_LENGTH); avail = papu->samplesAvail(); } - dataLen = framesLeft > avail ? avail : framesLeft; - dataLen = dataLen > bufSize ? bufSize : dataLen; + const auto dataLen = std::min({static_cast(avail), framesLeft, bufSize}); - long count = papu->readSamples(buf.data(), dataLen * 2) / 2; + const auto count = static_cast(papu->readSamples(buf.data(), dataLen * 2) / 2); - for (fpp_t frame = 0; frame < count; ++frame) + for (auto frame = std::size_t{0}; frame < count; ++frame) { for (ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch) { diff --git a/plugins/GigPlayer/CMakeLists.txt b/plugins/GigPlayer/CMakeLists.txt index 69ac1b80cdf..ccec8c87336 100644 --- a/plugins/GigPlayer/CMakeLists.txt +++ b/plugins/GigPlayer/CMakeLists.txt @@ -6,11 +6,6 @@ if(LMMS_HAVE_GIG) # Required for not crashing loading files with libgig add_compile_options("-fexceptions") - # disable deprecated check for mingw-x-libgig - if(LMMS_BUILD_WIN32) - add_compile_options("-Wno-deprecated") - endif(LMMS_BUILD_WIN32) - link_directories(${GIG_LIBRARY_DIRS}) link_libraries(${GIG_LIBRARIES}) build_plugin(gigplayer diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index b6613de7f70..b72e30b3335 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -323,7 +323,7 @@ void GigInstrument::playNote( NotePlayHandle * _n, SampleFrame* ) void GigInstrument::play( SampleFrame* _working_buffer ) { const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); - const int rate = Engine::audioEngine()->outputSampleRate(); + const auto rate = Engine::audioEngine()->outputSampleRate(); // Initialize to zeros std::memset( &_working_buffer[0][0], 0, DEFAULT_CHANNELS * frames * sizeof( float ) ); @@ -1216,7 +1216,7 @@ bool GigSample::convertSampleRate( SampleFrame & oldBuf, SampleFrame & newBuf, return false; } - if( src_data.output_frames_gen > 0 && src_data.output_frames_gen < newSize ) + if (src_data.output_frames_gen > 0 && static_cast(src_data.output_frames_gen) < newSize) { qCritical() << "GigInstrument: not enough frames, wanted" << newSize << "generated" << src_data.output_frames_gen; diff --git a/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp b/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp index e5af1e8bf72..992d05304ca 100755 --- a/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp +++ b/plugins/GranularPitchShifter/GranularPitchShifterEffect.cpp @@ -258,7 +258,7 @@ void GranularPitchShifterEffect::changeSampleRate() m_ringBufLength = m_sampleRate * ringBufLength; m_ringBuf.resize(m_ringBufLength); - for (size_t i = 0; i < m_ringBufLength; ++i) + for (size_t i = 0; i < static_cast(m_ringBufLength); ++i) { m_ringBuf[i][0] = 0; m_ringBuf[i][1] = 0; diff --git a/plugins/GranularPitchShifter/GranularPitchShifterEffect.h b/plugins/GranularPitchShifter/GranularPitchShifterEffect.h index c904b4c1389..0f94168b7b6 100755 --- a/plugins/GranularPitchShifter/GranularPitchShifterEffect.h +++ b/plugins/GranularPitchShifter/GranularPitchShifterEffect.h @@ -58,7 +58,7 @@ class GranularPitchShifterEffect : public Effect // double index and fraction are required for good quality float getHermiteSample(double index, int ch) { - const int index_floor = static_cast(index); + const auto index_floor = static_cast(index); const double fraction = index - index_floor; float v0, v1, v2, v3; diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index 26901c65f6e..75c79ad214b 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -139,7 +139,7 @@ bool LadspaEffect::processAudioBuffer( SampleFrame* _buf, return( false ); } - int frames = _frames; + auto frames = _frames; SampleFrame* o_buf = nullptr; QVarLengthArray sBuf(_frames); diff --git a/plugins/Monstro/Monstro.cpp b/plugins/Monstro/Monstro.cpp index 7063be0e265..874b5d8d13a 100644 --- a/plugins/Monstro/Monstro.cpp +++ b/plugins/Monstro/Monstro.cpp @@ -685,7 +685,7 @@ void MonstroSynth::renderOutput( fpp_t _frames, SampleFrame* _buf ) } -inline void MonstroSynth::updateModulators( float * env1, float * env2, float * lfo1, float * lfo2, int frames ) +inline void MonstroSynth::updateModulators(float * env1, float * env2, float * lfo1, float * lfo2, f_cnt_t frames) { // frames played before const f_cnt_t tfp = m_nph->totalFramesPlayed(); @@ -790,7 +790,7 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * // attack for( f_cnt_t f = 0; f < frames; ++f ) { - if( tfp + f < m_lfoatt[i] ) lfo[i][f] *= ( static_cast( tfp ) / m_lfoatt[i] ); + if (tfp + f < static_cast(m_lfoatt[i])) { lfo[i][f] *= static_cast(tfp) / m_lfoatt[i]; } } diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index da705b9ff9f..a1ae72a381b 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -184,7 +184,7 @@ class MonstroSynth MonstroInstrument * m_parent; NotePlayHandle * m_nph; - inline void updateModulators( float * env1, float * env2, float * lfo1, float * lfo2, int frames ); + inline void updateModulators(float * env1, float * env2, float * lfo1, float * lfo2, f_cnt_t frames); // linear interpolation /* inline sample_t interpolate( sample_t s1, sample_t s2, float x ) diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 6d8da26e396..ecc1d8f304e 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -86,7 +86,7 @@ void MultitapEchoEffect::updateFilters( int begin, int end ) void MultitapEchoEffect::runFilter( SampleFrame* dst, SampleFrame* src, StereoOnePole & filter, const fpp_t frames ) { - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { dst[f][0] = filter.update( src[f][0], 0 ); dst[f][1] = filter.update( src[f][1], 1 ); @@ -152,7 +152,7 @@ bool MultitapEchoEffect::processAudioBuffer( SampleFrame* buf, const fpp_t frame // pop the buffer and mix it into output m_buffer.pop( m_work ); - for( int f = 0; f < frames; ++f ) + for (auto f = std::size_t{0}; f < frames; ++f) { buf[f][0] = d * buf[f][0] + w * m_work[f][0]; buf[f][1] = d * buf[f][1] + w * m_work[f][1]; diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index 54c36a510f0..c167bcec259 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -302,7 +302,7 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, // fxKnob is [0;1] float t = m_fx1Model.value(); - for (int i=0 ; i < frames + offset ; i++) + for (auto i = std::size_t{0}; i < frames + offset; i++) { _working_buffer[i][0] = waveshape( _working_buffer[i][0], t ) * m_volModel.value() / 100.0f; diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.cpp b/plugins/PeakControllerEffect/PeakControllerEffect.cpp index af64d0095c9..886036095f8 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffect.cpp @@ -110,7 +110,7 @@ bool PeakControllerEffect::processAudioBuffer( SampleFrame* _buf, if( c.m_absModel.value() ) { - for( int i = 0; i < _frames; ++i ) + for (auto i = std::size_t{0}; i < _frames; ++i) { // absolute value is achieved because the squares are > 0 sum += _buf[i][0]*_buf[i][0] + _buf[i][1]*_buf[i][1]; @@ -118,7 +118,7 @@ bool PeakControllerEffect::processAudioBuffer( SampleFrame* _buf, } else { - for( int i = 0; i < _frames; ++i ) + for (auto i = std::size_t{0}; i < _frames; ++i) { // the value is absolute because of squaring, // so we need to correct it @@ -131,7 +131,7 @@ bool PeakControllerEffect::processAudioBuffer( SampleFrame* _buf, // this will mute the output after the values were measured if( c.m_muteModel.value() ) { - for( int i = 0; i < _frames; ++i ) + for (auto i = std::size_t{0}; i < _frames; ++i) { _buf[i][0] = _buf[i][1] = 0.0f; } diff --git a/plugins/ReverbSC/base.c b/plugins/ReverbSC/base.c index c8d1dff679e..d5c52b0bd1a 100644 --- a/plugins/ReverbSC/base.c +++ b/plugins/ReverbSC/base.c @@ -189,7 +189,7 @@ int sp_set(sp_param *p, SPFLOAT val) { int sp_out(sp_data *sp, uint32_t chan, SPFLOAT val) { - if(chan > sp->nchan - 1) { + if (chan >= (uint32_t) sp->nchan) { fprintf(stderr, "sp_out: Invalid channel\n"); return SP_NOT_OK; } diff --git a/plugins/Sf2Player/Sf2Player.cpp b/plugins/Sf2Player/Sf2Player.cpp index 14868bf0e69..13dab7b8abd 100644 --- a/plugins/Sf2Player/Sf2Player.cpp +++ b/plugins/Sf2Player/Sf2Player.cpp @@ -499,44 +499,58 @@ void Sf2Instrument::updateGain() fluid_synth_set_gain( m_synth, m_gain.value() ); } - - +#define FLUIDSYNTH_VERSION_HEX ((FLUIDSYNTH_VERSION_MAJOR << 16) \ + | (FLUIDSYNTH_VERSION_MINOR << 8) \ + | FLUIDSYNTH_VERSION_MICRO) +#define USE_NEW_EFFECT_API (FLUIDSYNTH_VERSION_HEX >= 0x020200) void Sf2Instrument::updateReverbOn() { - fluid_synth_set_reverb_on( m_synth, m_reverbOn.value() ? 1 : 0 ); +#if USE_NEW_EFFECT_API + fluid_synth_reverb_on(m_synth, -1, m_reverbOn.value() ? 1 : 0); +#else + fluid_synth_set_reverb_on(m_synth, m_reverbOn.value() ? 1 : 0); +#endif } - - - void Sf2Instrument::updateReverb() { - fluid_synth_set_reverb( m_synth, m_reverbRoomSize.value(), +#if USE_NEW_EFFECT_API + fluid_synth_set_reverb_group_roomsize(m_synth, -1, m_reverbRoomSize.value()); + fluid_synth_set_reverb_group_damp(m_synth, -1, m_reverbDamping.value()); + fluid_synth_set_reverb_group_width(m_synth, -1, m_reverbWidth.value()); + fluid_synth_set_reverb_group_level(m_synth, -1, m_reverbLevel.value()); +#else + fluid_synth_set_reverb(m_synth, m_reverbRoomSize.value(), m_reverbDamping.value(), m_reverbWidth.value(), - m_reverbLevel.value() ); + m_reverbLevel.value()); +#endif } - - - -void Sf2Instrument::updateChorusOn() +void Sf2Instrument::updateChorusOn() { - fluid_synth_set_chorus_on( m_synth, m_chorusOn.value() ? 1 : 0 ); +#if USE_NEW_EFFECT_API + fluid_synth_chorus_on(m_synth, -1, m_chorusOn.value() ? 1 : 0); +#else + fluid_synth_set_chorus_on(m_synth, m_chorusOn.value() ? 1 : 0); +#endif } - - - -void Sf2Instrument::updateChorus() +void Sf2Instrument::updateChorus() { - fluid_synth_set_chorus( m_synth, static_cast( m_chorusNum.value() ), +#if USE_NEW_EFFECT_API + fluid_synth_set_chorus_group_nr(m_synth, -1, static_cast(m_chorusNum.value())); + fluid_synth_set_chorus_group_level(m_synth, -1, m_chorusLevel.value()); + fluid_synth_set_chorus_group_speed(m_synth, -1, m_chorusSpeed.value()); + fluid_synth_set_chorus_group_depth(m_synth, -1, m_chorusDepth.value()); + fluid_synth_set_chorus_group_type(m_synth, -1, FLUID_CHORUS_MOD_SINE); +#else + fluid_synth_set_chorus(m_synth, static_cast(m_chorusNum.value()), m_chorusLevel.value(), m_chorusSpeed.value(), - m_chorusDepth.value(), 0 ); + m_chorusDepth.value(), FLUID_CHORUS_MOD_SINE); +#endif } - - void Sf2Instrument::updateTuning() { if (instrumentTrack()->microtuner()->enabledModel()->value()) @@ -898,7 +912,7 @@ void Sf2Instrument::renderFrames( f_cnt_t frames, SampleFrame* buf ) { qCritical( "Sf2Instrument: error while resampling: %s", src_strerror( error ) ); } - if( src_data.output_frames_gen > frames ) + if (static_cast(src_data.output_frames_gen) < frames) { qCritical("Sf2Instrument: not enough frames: %ld / %zu", src_data.output_frames_gen, frames); } diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index 4f2b1765a6d..4d21abd4dea 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -305,8 +305,11 @@ void SidInstrument::playNote( NotePlayHandle * _n, auto sid = static_cast(_n->m_pluginData); int delta_t = clockrate * frames / samplerate + 4; - // avoid variable length array for msvc compat - auto buf = reinterpret_cast(_working_buffer + offset); +#ifndef _MSC_VER + short buf[frames]; +#else + const auto buf = static_cast(_alloca(frames * sizeof(short))); +#endif auto sidreg = std::array{}; for (auto& reg : sidreg) @@ -407,12 +410,13 @@ void SidInstrument::playNote( NotePlayHandle * _n, sidreg[24] = data8&0x00FF; - int num = sid_fillbuffer(sidreg.data(), sid, delta_t, buf, frames); - if(num!=frames) + const auto num = static_cast(sid_fillbuffer(sidreg.data(), sid, delta_t, buf, frames)); + if (num != frames) { printf("!!!Not enough samples\n"); + } // loop backwards to avoid overwriting data in the short-to-float conversion - for( fpp_t frame = frames - 1; frame >= 0; frame-- ) + for (auto frame = std::size_t{0}; frame < frames; ++frame) { sample_t s = float(buf[frame])/32768.0; for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) diff --git a/plugins/SlicerT/SlicerT.cpp b/plugins/SlicerT/SlicerT.cpp index 3644060edb2..dcfbf6bc551 100644 --- a/plugins/SlicerT/SlicerT.cpp +++ b/plugins/SlicerT/SlicerT.cpp @@ -96,7 +96,7 @@ void SlicerT::playNote(NotePlayHandle* handle, SampleFrame* workingBuffer) sliceStart = 0; sliceEnd = 1; } - else if (noteIndex > 0 && noteIndex < m_slicePoints.size()) + else if (noteIndex > 0 && static_cast(noteIndex) < m_slicePoints.size()) { noteIndex -= 1; sliceStart = m_slicePoints[noteIndex]; @@ -134,9 +134,9 @@ void SlicerT::playNote(NotePlayHandle* handle, SampleFrame* workingBuffer) // exponential fade out, applyRelease() not used since it extends the note length int fadeOutFrames = m_fadeOutFrames.value() / 1000.0f * Engine::audioEngine()->outputSampleRate(); int noteFramesLeft = noteLeft * m_originalSample.sampleSize() * speedRatio; - for (int i = 0; i < frames; i++) + for (auto i = std::size_t{0}; i < frames; i++) { - float fadeValue = static_cast(noteFramesLeft - i) / fadeOutFrames; + float fadeValue = static_cast(noteFramesLeft - static_cast(i)) / fadeOutFrames; fadeValue = std::clamp(fadeValue, 0.0f, 1.0f); fadeValue = cosinusInterpolate(0, 1, fadeValue); @@ -170,7 +170,7 @@ void SlicerT::findSlices() float maxMag = -1; std::vector singleChannel(m_originalSample.sampleSize(), 0); - for (int i = 0; i < m_originalSample.sampleSize(); i++) + for (auto i = std::size_t{0}; i < m_originalSample.sampleSize(); i++) { singleChannel[i] = (m_originalSample.data()[i][0] + m_originalSample.data()[i][1]) / 2; maxMag = std::max(maxMag, singleChannel[i]); @@ -179,7 +179,7 @@ void SlicerT::findSlices() // normalize and find 0 crossings std::vector zeroCrossings; float lastValue = 1; - for (int i = 0; i < singleChannel.size(); i++) + for (auto i = std::size_t{0}; i < singleChannel.size(); i++) { singleChannel[i] /= maxMag; if (sign(lastValue) != sign(singleChannel[i])) @@ -199,7 +199,7 @@ void SlicerT::findSlices() float spectralFlux = 0; float prevFlux = 1E-10f; // small value, no divison by zero - for (int i = 0; i < singleChannel.size() - windowSize; i += windowSize) + for (int i = 0; i < static_cast(singleChannel.size()) - windowSize; i += windowSize) { // fft std::copy_n(singleChannel.data() + i, windowSize, fftIn.data()); @@ -300,7 +300,7 @@ std::vector SlicerT::getMidi() float totalTicks = outFrames / framesPerTick; float lastEnd = 0; - for (int i = 0; i < m_slicePoints.size() - 1; i++) + for (auto i = std::size_t{0}; i < m_slicePoints.size() - 1; i++) { float sliceStart = lastEnd; float sliceEnd = totalTicks * m_slicePoints[i + 1]; @@ -342,7 +342,7 @@ void SlicerT::saveSettings(QDomDocument& document, QDomElement& element) } element.setAttribute("totalSlices", static_cast(m_slicePoints.size())); - for (int i = 0; i < m_slicePoints.size(); i++) + for (auto i = std::size_t{0}; i < m_slicePoints.size(); i++) { element.setAttribute(tr("slice_%1").arg(i), m_slicePoints[i]); } diff --git a/plugins/SlicerT/SlicerTWaveform.cpp b/plugins/SlicerT/SlicerTWaveform.cpp index 3793ed2f159..808b81c399b 100644 --- a/plugins/SlicerT/SlicerTWaveform.cpp +++ b/plugins/SlicerT/SlicerTWaveform.cpp @@ -195,11 +195,11 @@ void SlicerTWaveform::drawEditor() brush.setPen(QPen(s_sliceColor, 2)); - for (int i = 0; i < m_slicerTParent->m_slicePoints.size(); i++) + for (auto i = std::size_t{0}; i < m_slicerTParent->m_slicePoints.size(); i++) { float xPos = (m_slicerTParent->m_slicePoints.at(i) - startFrame) / numFramesToDraw * m_editorWidth; - if (i == m_closestSlice) + if (i == static_cast(m_closestSlice)) { brush.setPen(QPen(s_sliceHighlightColor, 2)); brush.drawLine(xPos, 0, xPos, m_editorHeight); @@ -268,7 +268,7 @@ void SlicerTWaveform::updateClosest(QMouseEvent* me) m_closestSlice = -1; float startFrame = m_seekerStart; float endFrame = m_seekerEnd; - for (int i = 0; i < m_slicerTParent->m_slicePoints.size(); i++) + for (auto i = std::size_t{0}; i < m_slicerTParent->m_slicePoints.size(); i++) { float sliceIndex = m_slicerTParent->m_slicePoints.at(i); float xPos = (sliceIndex - startFrame) / (endFrame - startFrame); diff --git a/plugins/SpectrumAnalyzer/SaProcessor.cpp b/plugins/SpectrumAnalyzer/SaProcessor.cpp index e0eef8b595a..d9e7ac8a494 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.cpp +++ b/plugins/SpectrumAnalyzer/SaProcessor.cpp @@ -232,7 +232,7 @@ void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) if (band_end - band_start > 1.0) { // band spans multiple pixels: draw all pixels it covers - for (int target = std::max(static_cast(band_start), 0); + for (auto target = static_cast(std::max(band_start, 0.f)); target < band_end && target < waterfallWidth(); target++) { pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]); @@ -259,7 +259,9 @@ void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) accL += ((int)band_end - band_start) * m_normSpectrumL[i]; accR += ((int)band_end - band_start) * m_normSpectrumR[i]; - if (target >= 0 && target < waterfallWidth()) {pixel[target] = makePixel(accL, accR);} + if (target >= 0 && static_cast(target) < waterfallWidth()) { + pixel[target] = makePixel(accL, accR); + } // save remaining portion of the band for the following band / pixel accL = (band_end - (int)band_end) * m_normSpectrumL[i]; @@ -270,7 +272,7 @@ void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) else { // Linear: always draws one or more pixels per band - for (int target = std::max(static_cast(band_start), 0); + for (auto target = static_cast(std::max(band_start, 0.f)); target < band_end && target < waterfallWidth(); target++) { pixel[target] = makePixel(m_normSpectrumL[i], m_normSpectrumR[i]); diff --git a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp index 452e1e90fe4..2d15da7f47b 100644 --- a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp +++ b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp @@ -302,7 +302,7 @@ void SaSpectrumView::refreshPaths() // part new, part old. At reasonable frame rate, such difference is invisible.. void SaSpectrumView::updateBuffers(const float *spectrum, float *displayBuffer, float *peakBuffer) { - for (int n = 0; n < m_processor->binCount(); n++) + for (auto n = std::size_t{0}; n < m_processor->binCount(); n++) { // Update the exponential average if enabled, or simply copy the value. if (!m_controls->m_pauseModel.value()) diff --git a/plugins/StereoEnhancer/StereoEnhancer.cpp b/plugins/StereoEnhancer/StereoEnhancer.cpp index d5ed8d99d6d..261c897df2f 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.cpp +++ b/plugins/StereoEnhancer/StereoEnhancer.cpp @@ -145,7 +145,7 @@ bool StereoEnhancerEffect::processAudioBuffer( SampleFrame* _buf, void StereoEnhancerEffect::clearMyBuffer() { - for (int i = 0; i < DEFAULT_BUFFER_SIZE; i++) + for (auto i = std::size_t{0}; i < DEFAULT_BUFFER_SIZE; i++) { m_delayBuffer[i][0] = 0.0f; m_delayBuffer[i][1] = 0.0f; diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index c4dd08afa1c..19b8ab1c06b 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -72,11 +72,11 @@ class Vibed::StringContainer ~StringContainer() = default; - void addString(int harm, float pick, float pickup, const float* impulse, float randomize, + void addString(std::size_t harm, float pick, float pickup, const float* impulse, float randomize, float stringLoss, float detune, int oversample, bool state, int id) { constexpr auto octave = std::array{0.25f, 0.5f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f}; - assert(harm >= 0 && harm < octave.size()); + assert(harm < octave.size()); m_strings[id] = VibratingString{m_pitch * octave[harm], pick, pickup, impulse, m_bufferLength, m_sampleRate, oversample, randomize, stringLoss, detune, state}; diff --git a/plugins/VstBase/RemoteVstPlugin.cpp b/plugins/VstBase/RemoteVstPlugin.cpp index ef31cfdb8eb..62cb7cfe5e1 100644 --- a/plugins/VstBase/RemoteVstPlugin.cpp +++ b/plugins/VstBase/RemoteVstPlugin.cpp @@ -265,7 +265,7 @@ class RemoteVstPlugin : public RemotePluginClient void saveChunkToFile( const std::string & _file ); // restore settings chunk of plugin from file - void loadChunkFromFile( const std::string & _file, int _len ); + void loadChunkFromFile(const std::string& _file, std::size_t _len); // restore settings chunk of plugin from file void loadPresetFile( const std::string & _file ); @@ -1303,7 +1303,7 @@ void RemoteVstPlugin::saveChunkToFile( const std::string & _file ) "Error opening file for saving chunk.\n" ); return; } - if ( fwrite( chunk, 1, len, fp ) != len ) + if (fwrite(chunk, 1, len, fp) != static_cast(len)) { fprintf( stderr, "Error saving chunk to file.\n" ); @@ -1541,7 +1541,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) unsigned int toUInt; float * pFloat; - if (m_plugin->uniqueID != pBank->fxID) { + if (static_cast(m_plugin->uniqueID) != pBank->fxID) { sendMessage( message( IdVstCurrentProgramName ). addString( "Error: Plugin UniqID not match" ) ); fclose( stream ); @@ -1577,7 +1577,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) else { auto toUIntArray = reinterpret_cast(chunk); - for (int i = 0; i < pBank->numPrograms; i++ ) + for (auto i = 0u; i < pBank->numPrograms; i++) { toUInt = endian_swap( toUIntArray[ i ] ); pFloat = ( float* ) &toUInt; @@ -1625,10 +1625,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) delete[] (char*)chunk; } - - - -void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len ) +void RemoteVstPlugin::loadChunkFromFile(const std::string& _file, std::size_t _len) { auto chunk = new char[_len]; diff --git a/plugins/Xpressive/ExprSynth.cpp b/plugins/Xpressive/ExprSynth.cpp index ef5d3dbf111..c48b94ec8dc 100644 --- a/plugins/Xpressive/ExprSynth.cpp +++ b/plugins/Xpressive/ExprSynth.cpp @@ -147,13 +147,8 @@ struct LastSampleFunction : public exprtk::ifunction inline T operator()(const T& x) override { - if (!std::isnan(x) && !std::isinf(x)) - { - const int ix=(int)x; - if (ix>=1 && ix<=m_history_size) - { - return m_samples[(ix + m_pivot_last) % m_history_size]; - } + if (!std::isnan(x) && x >= 1 && x <= m_history_size) { + return m_samples[(static_cast(x) + m_pivot_last) % m_history_size]; } return 0; } diff --git a/plugins/Xpressive/Xpressive.cpp b/plugins/Xpressive/Xpressive.cpp index 3fb1fc5f2f6..23a76b22820 100644 --- a/plugins/Xpressive/Xpressive.cpp +++ b/plugins/Xpressive/Xpressive.cpp @@ -579,9 +579,9 @@ void XpressiveView::expressionChanged() { if (parse_ok) { e->exprValid().setValue(0); - const int length = m_raw_graph->length(); + const auto length = static_cast(m_raw_graph->length()); auto const samples = new float[length]; - for (i = 0; i < length; i++) { + for (auto i = std::size_t{0}; i < length; i++) { t = i / (float) length; samples[i] = expr.evaluate(); if (std::isinf(samples[i]) != 0 || std::isnan(samples[i]) != 0) diff --git a/plugins/ZynAddSubFx/CMakeLists.txt b/plugins/ZynAddSubFx/CMakeLists.txt index b3490a50fb1..cbd7326fe6b 100644 --- a/plugins/ZynAddSubFx/CMakeLists.txt +++ b/plugins/ZynAddSubFx/CMakeLists.txt @@ -25,13 +25,9 @@ endif() # build ZynAddSubFX with full optimizations if(NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-declarations -fpermissive") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fpermissive") endif() -IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "6.0.0") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation -Wno-format-truncation") -ENDIF() - IF(MINGW_PREFIX) SET(FLTK_FLUID_EXECUTABLE "${MINGW_PREFIX}/bin/fluid") ENDIF() diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index c0287cd8bb7..77b242199f8 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -108,7 +108,7 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( m_plugin( nullptr ), m_remotePlugin( nullptr ), m_portamentoModel( 0, 0, 127, 1, this, tr( "Portamento" ) ), - m_filterFreqModel( 64, 0, 127, 1, this, tr( "Filter frequency" ) ), + m_filterFreqModel( 127, 0, 127, 1, this, tr( "Filter frequency" ) ), m_filterQModel( 64, 0, 127, 1, this, tr( "Filter resonance" ) ), m_bandwidthModel( 64, 0, 127, 1, this, tr( "Bandwidth" ) ), m_fmGainModel( 127, 0, 127, 1, this, tr( "FM gain" ) ), diff --git a/plugins/ZynAddSubFx/zynaddsubfx b/plugins/ZynAddSubFx/zynaddsubfx index aac04bc55c4..9499523f703 160000 --- a/plugins/ZynAddSubFx/zynaddsubfx +++ b/plugins/ZynAddSubFx/zynaddsubfx @@ -1 +1 @@ -Subproject commit aac04bc55c4114460009897686b597f98adfaa65 +Subproject commit 9499523f70322b6034673566898300e7543fdf3e diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index 157b6fe65a7..42e7079b016 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -95,7 +95,7 @@ AudioEngine::AudioEngine( bool renderOnly ) : m_inputBufferFrames[i] = 0; m_inputBufferSize[i] = DEFAULT_BUFFER_SIZE * 100; m_inputBuffer[i] = new SampleFrame[ DEFAULT_BUFFER_SIZE * 100 ]; - BufferManager::clear( m_inputBuffer[i], m_inputBufferSize[i] ); + zeroSampleFrames(m_inputBuffer[i], m_inputBufferSize[i]); } // determine FIFO size and number of frames per period diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index ae459c5e484..70f7760419f 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -79,7 +79,7 @@ void AudioEngineWorkerThread::JobQueue::run() while (processedJob && m_itemsDone < m_writeIndex) { processedJob = false; - for( int i = 0; i < m_writeIndex && i < JOB_QUEUE_SIZE; ++i ) + for (auto i = std::size_t{0}; i < m_writeIndex && i < JOB_QUEUE_SIZE; ++i) { ThreadableJob * job = m_items[i].exchange(nullptr); if( job ) diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index a7a051e260b..47598c63325 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -47,10 +47,6 @@ SampleFrame* BufferManager::acquire() return new SampleFrame[s_framesPerPeriod]; } -void BufferManager::clear( SampleFrame* ab, const f_cnt_t frames, const f_cnt_t offset ) -{ - zeroSampleFrames(ab + offset, frames); -} void BufferManager::release( SampleFrame* buf ) diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index fea907942af..934ccc3f8ca 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -159,11 +159,10 @@ inline void ControllerConnection::setTargetName( const QString & _name ) */ void ControllerConnection::finalizeConnections() { - for( int i = 0; i < s_connections.size(); ++i ) + for (auto i = std::size_t{0}; i < s_connections.size(); ++i) { ControllerConnection * c = s_connections[i]; - if ( !c->isFinalized() && c->m_controllerId < - Engine::getSong()->controllers().size() ) + if (!c->isFinalized() && static_cast(c->m_controllerId) < Engine::getSong()->controllers().size()) { c->setController( Engine::getSong()-> controllers().at( c->m_controllerId ) ); @@ -221,7 +220,7 @@ void ControllerConnection::loadSettings( const QDomElement & _this ) if (!Engine::getSong()->isLoadingProject() && m_controllerId != -1 - && m_controllerId < Engine::getSong()->controllers().size()) + && static_cast(m_controllerId) < Engine::getSong()->controllers().size()) { setController( Engine::getSong()-> controllers().at( m_controllerId ) ); diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index a55dbd82b95..b664387bd42 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -1184,7 +1184,7 @@ static void upgradeElement_1_2_0_rc2_42( QDomElement & el ) int syncmode = el.attribute( "syncmode" ).toInt(); QStringList names; QDomNamedNodeMap atts = el.attributes(); - for( uint i = 0; i < atts.length(); i++ ) + for (auto i = 0; i < atts.length(); i++) { QString name = atts.item( i ).nodeName(); if( name.endsWith( "_numerator" ) ) diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 9c0a4596a11..a3c3bcf9184 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -299,11 +299,6 @@ void EnvelopeAndLfoParameters::fillLevel( float * _buf, f_cnt_t _frame, { QMutexLocker m(&m_paramMutex); - if( _frame < 0 || _release_begin < 0 ) - { - return; - } - fillLfoLevel( _buf, _frame, _frames ); for( fpp_t offset = 0; offset < _frames; ++offset, ++_buf, ++_frame ) diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index a57ce6ce5b2..eca06f9a2bb 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -66,7 +66,7 @@ InstrumentSoundShaping::InstrumentSoundShaping( m_filterCutModel( 14000.0, 1.0, 14000.0, 1.0, this, tr( "Cutoff frequency" ) ), m_filterResModel(0.5f, BasicFilters<>::minQ(), 10.f, 0.01f, this, tr("Q/Resonance")) { - for( int i = 0; i < NumTargets; ++i ) + for (auto i = std::size_t{0}; i < NumTargets; ++i) { float value_for_zero_amount = 0.0; if( static_cast(i) == Target::Volume ) @@ -279,7 +279,7 @@ f_cnt_t InstrumentSoundShaping::envFrames( const bool _only_vol ) const if( _only_vol == false ) { - for( int i = static_cast(Target::Volume)+1; i < NumTargets; ++i ) + for (auto i = static_cast(Target::Volume) + 1; i < NumTargets; ++i) { if( m_envLfoParameters[i]->isUsed() && m_envLfoParameters[i]->PAHD_Frames() > ret_val ) @@ -313,7 +313,7 @@ f_cnt_t InstrumentSoundShaping::releaseFrames() const return m_envLfoParameters[static_cast(Target::Volume)]->releaseFrames(); } - for( int i = static_cast(Target::Volume)+1; i < NumTargets; ++i ) + for (auto i = static_cast(Target::Volume) + 1; i < NumTargets; ++i) { if( m_envLfoParameters[i]->isUsed() ) { @@ -333,7 +333,7 @@ void InstrumentSoundShaping::saveSettings( QDomDocument & _doc, QDomElement & _t m_filterResModel.saveSettings( _doc, _this, "fres" ); m_filterEnabledModel.saveSettings( _doc, _this, "fwet" ); - for( int i = 0; i < NumTargets; ++i ) + for (auto i = std::size_t{0}; i < NumTargets; ++i) { m_envLfoParameters[i]->saveState( _doc, _this ).setTagName( m_envLfoParameters[i]->nodeName() + @@ -356,7 +356,7 @@ void InstrumentSoundShaping::loadSettings( const QDomElement & _this ) { if( node.isElement() ) { - for( int i = 0; i < NumTargets; ++i ) + for (auto i = std::size_t{0}; i < NumTargets; ++i) { if( node.nodeName() == m_envLfoParameters[i]->nodeName() + diff --git a/src/core/LocklessAllocator.cpp b/src/core/LocklessAllocator.cpp index 919093906c3..92eadd75128 100644 --- a/src/core/LocklessAllocator.cpp +++ b/src/core/LocklessAllocator.cpp @@ -71,8 +71,7 @@ LocklessAllocator::LocklessAllocator( size_t nmemb, size_t size ) LocklessAllocator::~LocklessAllocator() { - int available = m_available; - if( available != m_capacity ) + if (m_available != m_capacity) { fprintf( stderr, "LocklessAllocator: " "Destroying with elements still allocated\n" ); @@ -110,7 +109,7 @@ void * LocklessAllocator::alloc() // Some of these CAS loops could probably use relaxed atomics, as discussed // in http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange. // Let's use sequentially-consistent ops to be safe for now. - int available = m_available.load(); + auto available = m_available.load(); do { if( !available ) diff --git a/src/core/Microtuner.cpp b/src/core/Microtuner.cpp index 9c5ab871bc8..46d83017fa2 100644 --- a/src/core/Microtuner.cpp +++ b/src/core/Microtuner.cpp @@ -126,14 +126,14 @@ int Microtuner::octaveSize() const */ void Microtuner::updateScaleList(int index) { - if (index >= 0 && index < MaxScaleCount) + if (index >= 0 && static_cast(index) < MaxScaleCount) { m_scaleModel.replaceItem(index, QString::number(index) + ": " + Engine::getSong()->getScale(index)->getDescription()); } else { - for (int i = 0; i < MaxScaleCount; i++) + for (auto i = std::size_t{0}; i < MaxScaleCount; i++) { m_scaleModel.replaceItem(i, QString::number(i) + ": " + Engine::getSong()->getScale(i)->getDescription()); @@ -147,14 +147,14 @@ void Microtuner::updateScaleList(int index) */ void Microtuner::updateKeymapList(int index) { - if (index >= 0 && index < MaxKeymapCount) + if (index >= 0 && static_cast(index) < MaxKeymapCount) { m_keymapModel.replaceItem(index, QString::number(index) + ": " + Engine::getSong()->getKeymap(index)->getDescription()); } else { - for (int i = 0; i < MaxKeymapCount; i++) + for (auto i = std::size_t{0}; i < MaxKeymapCount; i++) { m_keymapModel.replaceItem(i, QString::number(i) + ": " + Engine::getSong()->getKeymap(i)->getDescription()); diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 0b0689eb54d..7e3fc1f60c5 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -74,7 +74,7 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) : m_queued( false ), m_dependenciesMet(0) { - BufferManager::clear( m_buffer, Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_buffer, Engine::audioEngine()->framesPerPeriod()); } @@ -99,7 +99,7 @@ inline void MixerChannel::processed() void MixerChannel::incrementDeps() { - int i = m_dependenciesMet++ + 1; + const auto i = m_dependenciesMet++ + 1; if( i >= m_receives.size() && ! m_queued ) { m_queued = true; @@ -235,7 +235,7 @@ int Mixer::createChannel() void Mixer::activateSolo() { - for (int i = 1; i < m_mixerChannels.size(); ++i) + for (auto i = std::size_t{1}; i < m_mixerChannels.size(); ++i) { m_mixerChannels[i]->m_muteBeforeSolo = m_mixerChannels[i]->m_muteModel.value(); m_mixerChannels[i]->m_muteModel.setValue( true ); @@ -244,7 +244,7 @@ void Mixer::activateSolo() void Mixer::deactivateSolo() { - for (int i = 1; i < m_mixerChannels.size(); ++i) + for (auto i = std::size_t{1}; i < m_mixerChannels.size(); ++i) { m_mixerChannels[i]->m_muteModel.setValue( m_mixerChannels[i]->m_muteBeforeSolo ); } @@ -260,7 +260,7 @@ void Mixer::toggledSolo() m_mixerChannels[m_lastSoloed]->m_soloModel.setValue( false ); } //determine the soloed channel - for (int i = 0; i < m_mixerChannels.size(); ++i) + for (auto i = std::size_t{0}; i < m_mixerChannels.size(); ++i) { if (m_mixerChannels[i]->m_soloModel.value() == true) soloedChan = i; @@ -355,7 +355,7 @@ void Mixer::deleteChannel( int index ) m_mixerChannels.erase(m_mixerChannels.begin() + index); delete ch; - for( int i = index; i < m_mixerChannels.size(); ++i ) + for (auto i = static_cast(index); i < m_mixerChannels.size(); ++i) { validateChannelName( i, i + 1 ); @@ -381,7 +381,7 @@ void Mixer::deleteChannel( int index ) void Mixer::moveChannelLeft( int index ) { // can't move master or first channel - if( index <= 1 || index >= m_mixerChannels.size() ) + if (index <= 1 || static_cast(index) >= m_mixerChannels.size()) { return; } @@ -612,8 +612,7 @@ void Mixer::mixToChannel( const SampleFrame* _buf, mix_ch_t _ch ) void Mixer::prepareMasterMix() { - BufferManager::clear( m_mixerChannels[0]->m_buffer, - Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_mixerChannels[0]->m_buffer, Engine::audioEngine()->framesPerPeriod()); } @@ -685,8 +684,7 @@ void Mixer::masterMix( SampleFrame* _buf ) // reset channel process state for( int i = 0; i < numChannels(); ++i) { - BufferManager::clear( m_mixerChannels[i]->m_buffer, - Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_mixerChannels[i]->m_buffer, Engine::audioEngine()->framesPerPeriod()); m_mixerChannels[i]->reset(); m_mixerChannels[i]->m_queued = false; // also reset hasInput @@ -746,7 +744,7 @@ void Mixer::clearChannel(mix_ch_t index) void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this ) { // save channels - for( int i = 0; i < m_mixerChannels.size(); ++i ) + for (auto i = std::size_t{0}; i < m_mixerChannels.size(); ++i) { MixerChannel * ch = m_mixerChannels[i]; @@ -757,7 +755,7 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this ) ch->m_volumeModel.saveSettings( _doc, mixch, "volume" ); ch->m_muteModel.saveSettings( _doc, mixch, "muted" ); ch->m_soloModel.saveSettings( _doc, mixch, "soloed" ); - mixch.setAttribute( "num", i ); + mixch.setAttribute("num", static_cast(i)); mixch.setAttribute( "name", ch->m_name ); if (const auto& color = ch->color()) { mixch.setAttribute("color", color->name()); } @@ -776,7 +774,8 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this ) // make sure we have at least num channels void Mixer::allocateChannelsTo(int num) { - while( num > m_mixerChannels.size() - 1 ) + if (num <= 0) { return; } + while (static_cast(num) > m_mixerChannels.size() - 1) { createChannel(); @@ -815,7 +814,7 @@ void Mixer::loadSettings( const QDomElement & _this ) // mixer sends QDomNodeList chData = mixch.childNodes(); - for( unsigned int i=0; i= Engine::audioEngine()->outputSampleRate() / 2) { - BufferManager::clear(ab, frames); + zeroSampleFrames(ab, frames); return; } // If this oscillator is used to PM or PF modulate another oscillator, take a note. diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index eb90f6b65b1..134fcd31100 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -55,7 +55,7 @@ void PlayHandle::doProcessing() if( m_usesBuffer ) { m_bufferReleased = false; - BufferManager::clear(m_playHandleBuffer, Engine::audioEngine()->framesPerPeriod()); + zeroSampleFrames(m_playHandleBuffer, Engine::audioEngine()->framesPerPeriod()); play( buffer() ); } else diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index 4cfcc313c5e..dc26bf2b554 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -333,7 +333,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) { if( _out_buf != nullptr ) { - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); } return false; } @@ -352,7 +352,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) } if( _out_buf != nullptr ) { - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); } return false; } @@ -426,7 +426,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) { auto o = (SampleFrame*)(m_audioBuffer.get() + m_inputCount * frames); // clear buffer, if plugin didn't fill up both channels - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); for (ch_cnt_t ch = 0; ch < std::min(DEFAULT_CHANNELS, outputs); ++ch) diff --git a/src/core/RingBuffer.cpp b/src/core/RingBuffer.cpp index 133af843a4c..652cd43dcf9 100644 --- a/src/core/RingBuffer.cpp +++ b/src/core/RingBuffer.cpp @@ -144,7 +144,6 @@ void RingBuffer::pop( SampleFrame* dst ) void RingBuffer::read( SampleFrame* dst, f_cnt_t offset ) { f_cnt_t pos = ( m_position + offset ) % m_size; - if( pos < 0 ) { pos += m_size; } if( pos + m_fpp <= m_size ) // we won't go over the edge so we can just memcpy here { @@ -171,7 +170,6 @@ void RingBuffer::read( SampleFrame* dst, float offset ) void RingBuffer::read( SampleFrame* dst, f_cnt_t offset, f_cnt_t length ) { f_cnt_t pos = ( m_position + offset ) % m_size; - if( pos < 0 ) { pos += m_size; } if( pos + length <= m_size ) // we won't go over the edge so we can just memcpy here { diff --git a/src/core/Sample.cpp b/src/core/Sample.cpp index 7bbb4e9b9d8..db99620c9d4 100644 --- a/src/core/Sample.cpp +++ b/src/core/Sample.cpp @@ -140,12 +140,12 @@ bool Sample::play(SampleFrame* dst, PlaybackState* state, size_t numFrames, floa = state->resampler().resample(&playBuffer[0][0], playBuffer.size(), &dst[0][0], numFrames, resampleRatio); advance(state, resampleResult.inputFramesUsed, loopMode); - const auto outputFrames = resampleResult.outputFramesGenerated; + const auto outputFrames = static_cast(resampleResult.outputFramesGenerated); if (outputFrames < numFrames) { std::fill_n(dst + outputFrames, numFrames - outputFrames, SampleFrame{}); } if (!typeInfo::isEqual(m_amplification, 1.0f)) { - for (int i = 0; i < numFrames; ++i) + for (auto i = std::size_t{0}; i < numFrames; ++i) { dst[i][0] *= m_amplification; dst[i][1] *= m_amplification; diff --git a/src/core/SampleDecoder.cpp b/src/core/SampleDecoder.cpp index 1e1ddb545cf..d3ee091f42a 100644 --- a/src/core/SampleDecoder.cpp +++ b/src/core/SampleDecoder.cpp @@ -174,7 +174,7 @@ auto decodeSampleOggVorbis(const QString& audioFile) -> std::optional(totalSamplesRead / numChannels); - for (int i = 0; i < result.size(); ++i) + for (auto i = std::size_t{0}; i < result.size(); ++i) { if (numChannels == 1) { result[i] = {buffer[i], buffer[i]}; } else if (numChannels > 1) { result[i] = {buffer[i * numChannels], buffer[i * numChannels + 1]}; } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 392e9e2566c..92cb2ba3051 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -847,7 +847,7 @@ void Song::clearProject() stop(); } - for( int i = 0; i < PlayModeCount; i++ ) + for (auto i = std::size_t{0}; i < PlayModeCount; i++) { setPlayPos( 0, ( PlayMode )i ); } @@ -1349,7 +1349,7 @@ void Song::restoreScaleStates(const QDomElement &element) { QDomNode node = element.firstChild(); - for (int i = 0; i < MaxScaleCount && !node.isNull() && !isCancelled(); i++) + for (auto i = std::size_t{0}; i < MaxScaleCount && !node.isNull() && !isCancelled(); i++) { m_scales[i]->restoreState(node.toElement()); node = node.nextSibling(); @@ -1374,7 +1374,7 @@ void Song::restoreKeymapStates(const QDomElement &element) { QDomNode node = element.firstChild(); - for (int i = 0; i < MaxKeymapCount && !node.isNull() && !isCancelled(); i++) + for (auto i = std::size_t{0}; i < MaxKeymapCount && !node.isNull() && !isCancelled(); i++) { m_keymaps[i]->restoreState(node.toElement()); node = node.nextSibling(); diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 6c4ba465e4b..7ff73e71891 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -388,14 +388,14 @@ int Track::numOfClips() * \todo if we create a Clip here, should we somehow attach it to the * track? */ -Clip * Track::getClip( int clipNum ) +auto Track::getClip(std::size_t clipNum) -> Clip* { if( clipNum < m_clips.size() ) { return m_clips[clipNum]; } - printf( "called Track::getClip( %d ), " - "but Clip %d doesn't exist\n", clipNum, clipNum ); + printf( "called Track::getClip( %zu ), " + "but Clip %zu doesn't exist\n", clipNum, clipNum ); return createClip( clipNum * TimePos::ticksPerBar() ); } diff --git a/src/core/audio/AudioOss.cpp b/src/core/audio/AudioOss.cpp index 1321a8a247a..bd427523520 100644 --- a/src/core/audio/AudioOss.cpp +++ b/src/core/audio/AudioOss.cpp @@ -99,10 +99,9 @@ AudioOss::AudioOss( bool & _success_ful, AudioEngine* _audioEngine ) : fcntl( m_audioFD, F_SETFD, fcntl( m_audioFD, F_GETFD ) | FD_CLOEXEC ); int frag_spec; - for( frag_spec = 0; static_cast( 0x01 << frag_spec ) < - audioEngine()->framesPerPeriod() * channels() * - BYTES_PER_INT_SAMPLE; - ++frag_spec ) + for (frag_spec = 0; + 1u << frag_spec < audioEngine()->framesPerPeriod() * channels() * BYTES_PER_INT_SAMPLE; + ++frag_spec) { } diff --git a/src/core/audio/AudioPort.cpp b/src/core/audio/AudioPort.cpp index 7bae3db1cf5..8efdd2c11a7 100644 --- a/src/core/audio/AudioPort.cpp +++ b/src/core/audio/AudioPort.cpp @@ -113,7 +113,7 @@ void AudioPort::doProcessing() const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); // clear the buffer - BufferManager::clear( m_portBuffer, fpp ); + zeroSampleFrames(m_portBuffer, fpp); //qDebug( "Playhandles: %d", m_playHandles.size() ); for( PlayHandle * ph : m_playHandles ) // now we mix all playhandle buffers into the audioport buffer diff --git a/src/core/audio/AudioPortAudio.cpp b/src/core/audio/AudioPortAudio.cpp index 00bbec2e491..eb5058bc6b5 100644 --- a/src/core/audio/AudioPortAudio.cpp +++ b/src/core/audio/AudioPortAudio.cpp @@ -229,10 +229,7 @@ void AudioPortAudio::stopProcessing() } -int AudioPortAudio::process_callback( - const float *_inputBuffer, - float * _outputBuffer, - unsigned long _framesPerBuffer ) +int AudioPortAudio::process_callback(const float* _inputBuffer, float* _outputBuffer, f_cnt_t _framesPerBuffer) { if( supportsCapture() ) { @@ -261,8 +258,7 @@ int AudioPortAudio::process_callback( } m_outBufSize = frames; } - const int min_len = std::min(static_cast(_framesPerBuffer), - m_outBufSize - m_outBufPos); + const auto min_len = std::min(_framesPerBuffer, m_outBufSize - m_outBufPos); for( fpp_t frame = 0; frame < min_len; ++frame ) { diff --git a/src/gui/MainApplication.cpp b/src/gui/MainApplication.cpp index d33ede4d260..48c400a24dd 100644 --- a/src/gui/MainApplication.cpp +++ b/src/gui/MainApplication.cpp @@ -92,7 +92,7 @@ bool MainApplication::winEventFilter(MSG* msg, long* result) switch(msg->message) { case WM_STYLECHANGING: - if(msg->wParam == GWL_EXSTYLE) + if (msg->wParam == static_cast(GWL_EXSTYLE)) { // Prevent plugins making the main window transparent STYLESTRUCT * style = reinterpret_cast(msg->lParam); diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 6bb8415bd45..20660df4110 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -224,14 +224,14 @@ MicrotunerConfig::MicrotunerConfig() : */ void MicrotunerConfig::updateScaleList(int index) { - if (index >= 0 && index < MaxScaleCount) + if (index >= 0 && static_cast(index) < MaxScaleCount) { m_scaleComboModel.replaceItem(index, QString::number(index) + ": " + Engine::getSong()->getScale(index)->getDescription()); } else { - for (int i = 0; i < MaxScaleCount; i++) + for (auto i = std::size_t{0}; i < MaxScaleCount; i++) { m_scaleComboModel.replaceItem(i, QString::number(i) + ": " + Engine::getSong()->getScale(i)->getDescription()); @@ -246,14 +246,14 @@ void MicrotunerConfig::updateScaleList(int index) */ void MicrotunerConfig::updateKeymapList(int index) { - if (index >= 0 && index < MaxKeymapCount) + if (index >= 0 && static_cast(index) < MaxKeymapCount) { m_keymapComboModel.replaceItem(index, QString::number(index) + ": " + Engine::getSong()->getKeymap(index)->getDescription()); } else { - for (int i = 0; i < MaxKeymapCount; i++) + for (auto i = std::size_t{0}; i < MaxKeymapCount; i++) { m_keymapComboModel.replaceItem(i, QString::number(i) + ": " + Engine::getSong()->getKeymap(i)->getDescription()); diff --git a/src/gui/SampleWaveform.cpp b/src/gui/SampleWaveform.cpp index 91b6e26c3b6..ca356e72713 100644 --- a/src/gui/SampleWaveform.cpp +++ b/src/gui/SampleWaveform.cpp @@ -51,12 +51,12 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q const size_t maxFrames = numPixels * static_cast(framesPerPixel); - int pixelIndex = 0; + auto pixelIndex = std::size_t{0}; - for (int i = 0; i < maxFrames; i += static_cast(resolution)) + for (auto i = std::size_t{0}; i < maxFrames; i += static_cast(resolution)) { pixelIndex = i / framesPerPixel; - const int frameIndex = !parameters.reversed ? i : maxFrames - i; + const auto frameIndex = !parameters.reversed ? i : maxFrames - i; const auto& frame = parameters.buffer[frameIndex]; const auto value = frame.average(); @@ -75,11 +75,11 @@ void SampleWaveform::visualize(Parameters parameters, QPainter& painter, const Q pixelIndex++; } - for (int i = 0; i < numPixels; i++) + for (auto i = std::size_t{0}; i < numPixels; i++) { const int lineY1 = centerY - max[i] * halfHeight * parameters.amplification; const int lineY2 = centerY - min[i] * halfHeight * parameters.amplification; - const int lineX = i + x; + const int lineX = static_cast(i) + x; painter.drawLine(lineX, lineY1, lineX, lineY2); const float rms = std::sqrt(squared[i] / framesPerResolution); diff --git a/src/gui/clips/ClipView.cpp b/src/gui/clips/ClipView.cpp index a0f7f7c53c6..9eb6acb6b94 100644 --- a/src/gui/clips/ClipView.cpp +++ b/src/gui/clips/ClipView.cpp @@ -534,8 +534,9 @@ DataFile ClipView::createClipDataFiles( { // Insert into the dom under the "clips" element Track* clipTrack = clipView->m_trackView->getTrack(); - int trackIndex = std::distance(tc->tracks().begin(), std::find(tc->tracks().begin(), tc->tracks().end(), clipTrack)); - assert(trackIndex != tc->tracks().size()); + const auto trackIt = std::find(tc->tracks().begin(), tc->tracks().end(), clipTrack); + assert(trackIt != tc->tracks().end()); + int trackIndex = std::distance(tc->tracks().begin(), trackIt); QDomElement clipElement = dataFile.createElement("clip"); clipElement.setAttribute( "trackIndex", trackIndex ); clipElement.setAttribute( "trackType", static_cast(clipTrack->type()) ); diff --git a/src/gui/editors/PatternEditor.cpp b/src/gui/editors/PatternEditor.cpp index 5237690a7e7..2915786981d 100644 --- a/src/gui/editors/PatternEditor.cpp +++ b/src/gui/editors/PatternEditor.cpp @@ -135,10 +135,10 @@ void PatternEditor::dropEvent(QDropEvent* de) // Ensure pattern clips exist bool hasValidPatternClips = false; - if (t->getClips().size() == m_ps->numOfPatterns()) + if (t->getClips().size() == static_cast(m_ps->numOfPatterns())) { hasValidPatternClips = true; - for (int i = 0; i < t->getClips().size(); ++i) + for (auto i = std::size_t{0}; i < t->getClips().size(); ++i) { if (t->getClips()[i]->startPosition() != TimePos(i, 0)) { diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 5811f956cc1..bda6894f3ee 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -219,7 +219,7 @@ PianoRoll::PianoRoll() : m_noteEditMenu = new QMenu( this ); m_noteEditMenu->clear(); - for( int i = 0; i < m_nemStr.size(); ++i ) + for (auto i = std::size_t{0}; i < m_nemStr.size(); ++i) { auto act = new QAction(m_nemStr.at(i), this); connect( act, &QAction::triggered, [this, i](){ changeNoteEditMode(i); } ); diff --git a/src/gui/instrument/InstrumentSoundShapingView.cpp b/src/gui/instrument/InstrumentSoundShapingView.cpp index a3a78e25670..7558c4c2637 100644 --- a/src/gui/instrument/InstrumentSoundShapingView.cpp +++ b/src/gui/instrument/InstrumentSoundShapingView.cpp @@ -48,7 +48,7 @@ InstrumentSoundShapingView::InstrumentSoundShapingView(QWidget* parent) : m_targetsTabWidget = new TabWidget(tr("TARGET"), this); - for (int i = 0; i < InstrumentSoundShaping::NumTargets; ++i) + for (auto i = std::size_t{0}; i < InstrumentSoundShaping::NumTargets; ++i) { m_envLfoViews[i] = new EnvelopeAndLfoView(m_targetsTabWidget); m_targetsTabWidget->addTab(m_envLfoViews[i], @@ -115,7 +115,7 @@ void InstrumentSoundShapingView::modelChanged() m_filterComboBox->setModel( &m_ss->m_filterModel ); m_filterCutKnob->setModel( &m_ss->m_filterCutModel ); m_filterResKnob->setModel( &m_ss->m_filterResModel ); - for( int i = 0; i < InstrumentSoundShaping::NumTargets; ++i ) + for (auto i = std::size_t{0}; i < InstrumentSoundShaping::NumTargets; ++i) { m_envLfoViews[i]->setModel( m_ss->m_envLfoParameters[i] ); } diff --git a/src/gui/modals/ExportProjectDialog.cpp b/src/gui/modals/ExportProjectDialog.cpp index 8dfda4981f6..1f989841f3b 100644 --- a/src/gui/modals/ExportProjectDialog.cpp +++ b/src/gui/modals/ExportProjectDialog.cpp @@ -56,7 +56,7 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, } int cbIndex = 0; - for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i ) + for (auto i = std::size_t{0}; i < ProjectRenderer::NumFileFormats; ++i) { if( ProjectRenderer::fileEncodeDevices[i].isAvailable() ) { @@ -268,7 +268,7 @@ void ExportProjectDialog::startBtnClicked() } // Find proper file extension. - for( int i = 0; i < ProjectRenderer::NumFileFormats; ++i ) + for (auto i = std::size_t{0}; i < ProjectRenderer::NumFileFormats; ++i) { if (m_ft == ProjectRenderer::fileEncodeDevices[i].m_fileFormat) { diff --git a/src/gui/tracks/TrackContentWidget.cpp b/src/gui/tracks/TrackContentWidget.cpp index e205a0c00ea..afea82ea41c 100644 --- a/src/gui/tracks/TrackContentWidget.cpp +++ b/src/gui/tracks/TrackContentWidget.cpp @@ -413,7 +413,7 @@ bool TrackContentWidget::canPasteSelection( TimePos clipPos, const QMimeData* md int finalTrackIndex = trackIndex + currentTrackIndex - initialTrackIndex; // Track must be in TrackContainer's tracks - if( finalTrackIndex < 0 || finalTrackIndex >= tracks.size() ) + if (finalTrackIndex < 0 || static_cast(finalTrackIndex) >= tracks.size()) { return false; } diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 8cb840592a6..775bd96a8b8 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -57,7 +57,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) : const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); m_buffer = new SampleFrame[frames]; - BufferManager::clear( m_buffer, frames ); + zeroSampleFrames(m_buffer, frames); setToolTip(tr("Oscilloscope")); @@ -190,7 +190,7 @@ void Oscilloscope::paintEvent( QPaintEvent * ) otherChannelsColor(); // Any other channel p.setPen(QPen(color, width)); - for( int frame = 0; frame < frames; ++frame ) + for (auto frame = std::size_t{0}; frame < frames; ++frame) { sample_t const clippedSample = AudioEngine::clip(m_buffer[frame][ch]); m_points[frame] = QPointF(