diff --git a/plugins/vst/SfizzVstEditor.cpp b/plugins/vst/SfizzVstEditor.cpp index e42721ef..6b19f0c7 100644 --- a/plugins/vst/SfizzVstEditor.cpp +++ b/plugins/vst/SfizzVstEditor.cpp @@ -206,7 +206,7 @@ void PLUGIN_API SfizzVstEditor::update(FUnknown* changedUnknown, int32 message) uiReceiveValue(EditId::SfzFile, state.sfzFile); uiReceiveValue(EditId::Volume, state.volume); uiReceiveValue(EditId::Polyphony, state.numVoices); - uiReceiveValue(EditId::Oversampling, 1u << state.oversamplingLog2); + uiReceiveValue(EditId::Oversampling, float(1u << state.oversamplingLog2)); uiReceiveValue(EditId::PreloadSize, state.preloadSize); uiReceiveValue(EditId::ScalaFile, state.scalaFile); uiReceiveValue(EditId::ScalaRootKey, state.scalaRootKey); @@ -237,7 +237,7 @@ void PLUGIN_API SfizzVstEditor::update(FUnknown* changedUnknown, int32 message) uiReceiveValue(EditId::Polyphony, range.denormalize(value)); break; case kPidOversampling: - uiReceiveValue(EditId::Oversampling, 1u << (int32)range.denormalize(value)); + uiReceiveValue(EditId::Oversampling, float(1u << (int32)range.denormalize(value))); break; case kPidPreloadSize: uiReceiveValue(EditId::PreloadSize, range.denormalize(value)); diff --git a/plugins/vst/SfizzVstProcessor.cpp b/plugins/vst/SfizzVstProcessor.cpp index 4fd0c917..764e50fb 100644 --- a/plugins/vst/SfizzVstProcessor.cpp +++ b/plugins/vst/SfizzVstProcessor.cpp @@ -309,7 +309,7 @@ void SfizzVstProcessor::updateTimeInfo(const Vst::ProcessContext& context) sfz::Sfizz& synth = *_synth; if (context.state & context.kTempoValid) - synth.tempo(0, 60.0f / context.tempo); + synth.tempo(0, float(60.0 / context.tempo)); if (context.state & context.kTimeSigValid) { _timeSigNumerator = context.timeSigNumerator; diff --git a/scripts/run_clang_tidy.sh b/scripts/run_clang_tidy.sh index 097e4760..52b555fc 100755 --- a/scripts/run_clang_tidy.sh +++ b/scripts/run_clang_tidy.sh @@ -7,7 +7,6 @@ clang-tidy \ src/sfizz/EQPool.cpp \ src/sfizz/FilePool.cpp \ src/sfizz/FilterPool.cpp \ - src/sfizz/FloatEnvelopes.cpp \ src/sfizz/Logger.cpp \ src/sfizz/MidiState.cpp \ src/sfizz/Opcode.cpp \ @@ -24,13 +23,13 @@ clang-tidy \ src/sfizz/effects/Filter.cpp \ src/sfizz/effects/Lofi.cpp \ src/sfizz/effects/Nothing.cpp \ - vst/SfizzVstController.cpp \ - vst/SfizzVstProcessor.cpp \ - vst/SfizzVstEditor.cpp \ - vst/SfizzVstState.cpp \ + plugins/vst/SfizzVstController.cpp \ + plugins/vst/SfizzVstProcessor.cpp \ + plugins/vst/SfizzVstEditor.cpp \ + plugins/vst/SfizzVstState.cpp \ -- -Iexternal/abseil-cpp -Iexternal/jsl/include -Iexternal/filesystem/include -Iexternal/atomic_queue/include -Iexternal/threadpool -Isrc/external/hiir -Isrc/external/pugixml/src \ -Iexternal/st_audiofile/src -Iexternal/st_audiofile/thirdparty/dr_libs \ -Isrc/sfizz -Isrc -Isrc/sfizz/utility/bit_array -Isrc/sfizz/utility/spin_mutex -Isrc/external/spline -Isrc/external/cpuid/src -Iexternal/simde \ - -Ivst -Ivst/external/VST_SDK/VST3_SDK -Ieditor/external/vstgui4 -Ivst/external/ring_buffer \ - -Ieditor/src \ + -Iplugins/vst -Iplugins/vst/external/VST_SDK/VST3_SDK -Iplugins/editor/external/vstgui4 -Iplugins/vst/external/ring_buffer \ + -Iplugins/editor/src \ -DNDEBUG -std=c++17 diff --git a/src/sfizz/FilePool.cpp b/src/sfizz/FilePool.cpp index ae39b144..bea0f3b4 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -234,7 +234,7 @@ absl::optional sfz::FilePool::getFileInformation(const Fil FileInformation returnedValue; returnedValue.end = static_cast(reader->frames()) - 1; returnedValue.sampleRate = static_cast(reader->sampleRate()); - returnedValue.numChannels = reader->channels(); + returnedValue.numChannels = static_cast(reader->channels()); InstrumentInfo instrumentInfo {}; bool haveInstrumentInfo = reader->getInstrument(&instrumentInfo); @@ -267,7 +267,7 @@ absl::optional sfz::FilePool::getFileInformation(const Fil } if (haveInstrumentInfo) - returnedValue.rootKey = clamp(instrumentInfo.basenote, 0, 127); + returnedValue.rootKey = clamp(instrumentInfo.basenote, 0, 127); return returnedValue; } @@ -379,7 +379,7 @@ void sfz::FilePool::setPreloadSize(uint32_t preloadSize) noexcept } } -void sfz::FilePool::loadingJob(QueuedFileData data) noexcept +void sfz::FilePool::loadingJob(const QueuedFileData& data) noexcept { raiseCurrentThreadPriority(); @@ -496,17 +496,17 @@ bool is_ready(std::future const& f) void sfz::FilePool::dispatchingJob() noexcept { - QueuedFileData queuedData; while (dispatchBarrier.wait(), dispatchFlag) { std::lock_guard guard { loadingJobsMutex }; + QueuedFileData queuedData; if (filesToLoad->try_pop(queuedData)) { if (queuedData.id.expired()) { // file ID was nulled, it means the region was deleted, ignore } else loadingJobs.push_back( - threadPool->enqueue([this](const QueuedFileData& data) { loadingJob(data); }, queuedData)); + threadPool->enqueue([this](const QueuedFileData& data) { loadingJob(data); }, std::move(queuedData))); } // Clear finished jobs diff --git a/src/sfizz/FilePool.h b/src/sfizz/FilePool.h index 976438fd..b30c5cf4 100644 --- a/src/sfizz/FilePool.h +++ b/src/sfizz/FilePool.h @@ -356,7 +356,7 @@ private: void dispatchingJob() noexcept; void garbageJob() noexcept; - void loadingJob(QueuedFileData data) noexcept; + void loadingJob(const QueuedFileData& data) noexcept; std::mutex loadingJobsMutex; std::vector> loadingJobs; std::thread dispatchThread { &FilePool::dispatchingJob, this }; diff --git a/src/sfizz/FilterPool.cpp b/src/sfizz/FilterPool.cpp index 76667bd0..1fd77988 100644 --- a/src/sfizz/FilterPool.cpp +++ b/src/sfizz/FilterPool.cpp @@ -33,7 +33,7 @@ void sfz::FilterHolder::setup(const Region& region, unsigned filterId, int noteN fast_real_distribution dist { 0.0f, description->random }; baseCutoff *= centsFactor(dist(Random::randomGenerator)); } - const auto keytrack = description->keytrack * (noteNumber - description->keycenter); + const auto keytrack = description->keytrack * float(noteNumber - description->keycenter); baseCutoff *= centsFactor(keytrack); const auto veltrack = description->veltrack * velocity; baseCutoff *= centsFactor(veltrack); diff --git a/src/sfizz/Panning.cpp b/src/sfizz/Panning.cpp index 5c2cf455..74588782 100644 --- a/src/sfizz/Panning.cpp +++ b/src/sfizz/Panning.cpp @@ -35,7 +35,7 @@ static const auto panData = []() float panLookup(float pan) { // reduce range, round to nearest - const int index = lroundPositive(pan * (panSize - 1)); + const long index = lroundPositive(pan * (panSize - 1)); return panData[index]; } diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index a23dbfae..55f92c73 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -920,10 +920,10 @@ bool sfz::Region::parseLFOOpcode(const Opcode& opcode, LFODescription& lfo) getOrCreateConnection(sourceKey, targetKey).sourceDepthMod = sourceDepthKey; processGenericCc(opcode, depthModSpec, sourceDepthKey); break; - case_any_lfo("depthchanaft"): + case_any_lfo("depthchanaft"): // NOLINT bugprone-branch-clone // TODO(jpc) LFO v1 break; - case_any_lfo("depthpolyaft"): + case_any_lfo("depthpolyaft"): // NOLINT bugprone-branch-clone // TODO(jpc) LFO v1 break; case_any_lfo("fade"): @@ -935,10 +935,10 @@ bool sfz::Region::parseLFOOpcode(const Opcode& opcode, LFODescription& lfo) case_any_lfo_any_ccN("freq"): // also freqcc& processGenericCc(opcode, Default::lfoFreqMod, lfo.freqKey); break; - case_any_lfo("freqchanaft"): + case_any_lfo("freqchanaft"): // NOLINT bugprone-branch-clone // TODO(jpc) LFO v1 break; - case_any_lfo("freqpolyaft"): + case_any_lfo("freqpolyaft"): // NOLINT bugprone-branch-clone // TODO(jpc) LFO v1 break; @@ -1638,7 +1638,7 @@ float sfz::Region::getBasePitchVariation(float noteNumber, float velocity) const ASSERT(velocity >= 0.0f && velocity <= 1.0f); fast_real_distribution pitchDistribution { 0.0f, pitchRandom }; - float pitchVariationInCents = pitchKeytrack * (noteNumber - pitchKeycenter); // note difference with pitch center + float pitchVariationInCents = pitchKeytrack * (noteNumber - float(pitchKeycenter)); // note difference with pitch center pitchVariationInCents += pitch; // sample tuning pitchVariationInCents += config::centPerSemitone * transpose; // sample transpose pitchVariationInCents += velocity * pitchVeltrack; // track velocity diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 6304f4d3..d60a43f6 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -1016,9 +1016,10 @@ void Synth::renderBlock(AudioSpan buffer) noexcept // Send the set of changed CCs Client broadcaster = impl.getBroadcaster(); const BitArray& changedCCs = impl.changedCCsThisCycle_; + const int finalFrameNumber = int(numFrames - 1); if (broadcaster.canReceive()) { sfizz_blob_t blob { changedCCs.data(), static_cast(changedCCs.byte_size()) }; - broadcaster.receive<'b'>(numFrames - 1, "/cc/changed", &blob); + broadcaster.receive<'b'>(finalFrameNumber, "/cc/changed", &blob); } impl.changedCCsThisCycle_.clear(); // Send the changed keyswitch @@ -1027,7 +1028,7 @@ void Synth::renderBlock(AudioSpan buffer) noexcept int32_t value = -1; if (impl.currentSwitch_) value = *impl.currentSwitch_; - broadcaster.receive<'i'>(numFrames - 1, "/sw/last/current", value); + broadcaster.receive<'i'>(finalFrameNumber, "/sw/last/current", value); } impl.currentSwitchChanged_ = false; } diff --git a/src/sfizz/Voice.cpp b/src/sfizz/Voice.cpp index 1f449bd0..65b13cb9 100644 --- a/src/sfizz/Voice.cpp +++ b/src/sfizz/Voice.cpp @@ -485,7 +485,7 @@ bool Voice::startVoice(Layer* layer, int delay, const TriggerEvent& event) noexc impl.triggerDelay_ = delay; impl.initialDelay_ = delay + static_cast(region.getDelay(resources.midiState) * impl.sampleRate_); impl.baseFrequency_ = resources.tuning.getFrequencyOfKey(impl.triggerEvent_.number); - impl.sampleSize_ = region.getSampleEnd(resources.midiState, resources.filePool.getOversamplingFactor()) - impl.sourcePosition_ - 1; + impl.sampleSize_ = int(region.getSampleEnd(resources.midiState, resources.filePool.getOversamplingFactor()) - impl.sourcePosition_ - 1); impl.bendStepFactor_ = centsFactor(region.bendStep); impl.bendSmoother_.setSmoothing(region.bendSmooth, impl.sampleRate_); impl.bendSmoother_.reset(centsFactor(region.getBendInCents(resources.midiState.getPitchBend()))); @@ -1129,7 +1129,7 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept } if (!released()) - off(i, true); + off(int(i), true); fill(indices->subspan(i), sampleEnd); fill(coeffs->subspan(i), 0x1.fffffep-1); @@ -1167,8 +1167,8 @@ void Voice::Impl::fillWithData(AudioSpan buffer) noexcept // compute crossfade positions for (unsigned i = 0; i < ptSize; ++i) { - float pos = ptIndices[i] + ptCoeffs[i]; - xfCurvePos[i] = (pos - loop.xfOutStart) / loop.xfSize; + float pos = float(ptIndices[i]) + ptCoeffs[i]; + xfCurvePos[i] = (pos - float(loop.xfOutStart)) / float(loop.xfSize); } //----------------------------------------------------------------// @@ -1390,8 +1390,8 @@ const Curve& Voice::Impl::getSCurve() constexpr unsigned N = Curve::NumValues; float values[N]; for (unsigned i = 0; i < N; ++i) { - double x = i / static_cast(N - 1); - values[i] = (1.0 - std::cos(M_PI * x)) * 0.5; + double x = i / double(N - 1); + values[i] = float((1.0 - std::cos(M_PI * x)) * 0.5); } return Curve::buildFromPoints(values); }();