2 Commits

Author SHA1 Message Date
Johannes Lorenz
71ce49d7ba Remove lots of useless/misplaced includes (#7999)
Follow-Up of 7db3fa94a1 .

This was done by setting `CMAKE_C_INCLUDE_WHAT_YOU_USE` and
`CMAKE_CXX_INCLUDE_WHAT_YOU_USE` to (broken down into multiple lines here,
note, all below `FL/x.h` is not required for C):

```
include-what-you-use;
    -Xiwyu;--mapping_file=/usr/share/include-what-you-use/qt5_11.imp;
    -Xiwyu;--keep=*/xmmintrin.h;
    -Xiwyu;--keep=*/lmmsconfig.h;
    -Xiwyu;--keep=*/weak_libjack.h;
    -Xiwyu;--keep=*/sys/*;
    -Xiwyu;--keep=*/debug.h;
    -Xiwyu;--keep=*/SDL/*;
    -Xiwyu;--keep=*/alsa/*;
    -Xiwyu;--keep=*/FL/x.h;
    -Xiwyu;--keep=*/MidiApple.h;
    -Xiwyu;--keep=*/MidiWinMM.h;
    -Xiwyu;--keep=*/AudioSoundIo.h;
    -Xiwyu;--keep=*/OpulenZ/adplug/*;
    -Xiwyu;--keep=QPainterPath;
    -Xiwyu;--keep=QtTest
```

FAQ:

* Q: Does this speed-up a completely fresh compile?
* A: No, I measured it.

* Q: Does it speed up anything else?
* A: Yes. If you change one header, it can reduce the number of CPP files
     that your compiler needs to recompile, or your IDE has to re-scan.

* Q: What other reasons are for this PR?
* A: It's idiomatic to only include headers if you need them. Also, it will
     reduce output for those who want to use IWYU for new PRs.

Background:

This is just a remainder PR of what I planned. My original idea was to setup
a CI which warns you of useless includes (but not of all issues that IWYU
complains about). However, I could not see that this was favored on Discord.
A full IWYU CI also has the problem that it (possibly??) needs to compile
with `make -j 1`, which would make CI really slow.

However, for that plan, I had to fix the whole code base to be IWYU
compliant - which it now is.
2025-07-21 23:39:17 +02:00
saker
a311eed8e8 Add Tap Tempo (#6375)
* Add Tap Tempo Feature (#6375)
Resolves #5181

* Update formatting, use namespaces, etc.

* Use Qt Designer .ui file to handle the UI
Thanks to irrenhaus for the idea
Also added a few buttons I will add functionality for

* Play metronome sound when tapped

* Improve stabilization speed by comparing differences in length between intervals
To improve the speed at which the BPM counter stabilizes at a
certain number, we now compare the differences in length between
the last two taps and the most recent two taps and reset the counter
if the threshold is passed.
I made it so that a difference of 500 ms resets the counter.

* Remove duplicate m_ui
An artifact from my battle with Git and merge conflicts..

* Format TapTempoUi header file

* Add lmms namespace in UI file

* Remove taptempo.ui XML file
Not needed

* Add LMMS_EXPORT to SamplePlayHandle

* Use std::chrono::duration<double, std::milli> for intervals
Co-authored-by: irrenhaus3 <irrenhaus3@gmail.com>

* Use alias for steady_clock
Co-authored-by: irrenhaus3 <irrenhaus3@gmail.com>

* Speed up convergence by accounting for recent intervals

This uses a combination of keeping track of a more accurate BPM,
while also using a BPM difference threshold to move towards the true BPM
more quickly.

After three taps, a "recent interval" is calculated, which is similar
to the latest interval, but less fluctuating since it accounts for
three taps instead of one. This allows for comparing between
the BPM on the display with the recent BPM more closely.

We then compare the difference in magnitude of both BPM's
with the threshold. If the threshold is passed, the counter gets reset.

* Remove semicolon from "QOBJECT;" in plugins/TapTempo/TapTempo.h

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>

* Add newline between using alias and constructor

* Cleanup header files

* Add // namespace lmms::gui comment

* Rename header guards in plugins/TapTempo/TapTempo.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Rename header guards in plugins/TapTempo/TapTempo.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Rename header guards in plugins/TapTempo/TapTempoUi.h

Will merge this file with ``TapTempoView`` soon.

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Rename header guards in plugins/TapTempo/TapTempoUi.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Update plugins/TapTempo/TapTempo.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Replace virtual with override in plugins/TapTempo/TapTempo.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Merge UI file into TapTempoView

* Pass TapTempo* directly into constructor in plugins/TapTempo/TapTempoView.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Update style in plugins/TapTempo/TapTempoView.h

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Add parameter name for keyPressEvent function in plugins/TapTempo/TapTempoView.h

Also reorder the function declarations to match the order in the source file.

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Remove dynamic_cast to TapTempo* in plugins/TapTempo/TapTempoView.cpp

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Restrict C linkage to only lmms_plugin_main and plugin descriptor
Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Simplify algorithm

* Update labels when calling closeEvent

* Add reset button

* Adjust layout

* Format document

* Only allow the tap button to gain focus

* Use icon provided by LMMS

* Add sync button and adjust formatting

* Make the metronome downbeat the first beat

Also simplify code

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Round BPM values when syncing with project tempo

Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>

* Change Plugin::Tool to Plugin::Type::Tool

---------

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
Co-authored-by: Dalton Messmer <33463986+messmerd@users.noreply.github.com>
2023-08-25 14:43:09 -04:00