|
maiacore 1.10.1
Music analisys library
|
Utility functions and templates for internal maiacore operations. More...
#include <iostream>#include <numeric>Go to the source code of this file.
Functions | |
| template<typename T > | |
| void | ignore (T &&) |
| Suppresses unused variable warnings by accepting and discarding a forwarding reference. More... | |
| constexpr unsigned int | hash (const char *s, int off=0) |
| Compile-time string hash function using the djb2 algorithm. More... | |
| constexpr int | factorial (const int n) |
| Compile-time factorial calculation using recursive template evaluation. More... | |
| bool | isFloatEqual (float A, float B, float epsilon=0.005f) |
| Floating-point equality comparison with epsilon tolerance for approximate matching. More... | |
Utility functions and templates for internal maiacore operations.
Provides compile-time and runtime utilities including hashing for switch-case optimization, mathematical functions, and floating-point comparison with epsilon tolerance for music analysis applications.
|
constexpr |
Compile-time factorial calculation using recursive template evaluation.
| n | Non-negative integer input (n >= 0). |
Recursively computes factorial at compile time. Used for combinatorial calculations in harmonic analysis and voice permutation computations.
|
constexpr |
Compile-time string hash function using the djb2 algorithm.
| s | Null-terminated C-string to hash. |
| off | Offset for recursive character processing (default: 0, internal use). |
Implements the djb2 hash algorithm recursively for constexpr evaluation. Used primarily for optimizing switch-case statements with string literals in MusicXML parsing and enumeration conversions. The hash formula is: hash * 33 XOR current_character, starting with seed value 5381.
| void ignore | ( | T && | ) |
Suppresses unused variable warnings by accepting and discarding a forwarding reference.
| T | Type of the unused variable. |
| Unnamed | forwarding reference to ignore. |
Utility template for suppressing compiler warnings when function parameters are intentionally unused in certain code paths or conditional compilation scenarios.
|
inline |
Floating-point equality comparison with epsilon tolerance for approximate matching.
| A | First value to compare. |
| B | Second value to compare. |
| epsilon | Tolerance threshold for considering values equal (default: 0.005). |
Uses absolute difference comparison suitable for music analysis where small deviations from rounding errors (e.g., frequency calculations, rhythmic quantization, spectral analysis) should be treated as equivalent. The default epsilon of 0.005 accommodates typical floating-point precision errors in quarter-note duration and frequency ratio computations.