#include <ValueUtils.h>
|
static float | eitherOr (float d1, float d2) |
|
static std::string | eitherOr (std::string s1, std::string s2) |
|
static std::set< int > | dividedBy (float divisor, const std::set< int > &originals) |
|
static float | ratio (float value, float limit) |
|
static bool | isInteger (const std::string &raw) |
|
static float | limitDecimalPrecision (float value) |
|
static std::string | k (int value) |
|
static std::string | randomFrom (std::vector< std::string > from) |
|
static std::vector< std::string > | randomFrom (std::vector< std::string > from, int num) |
|
static long | gcd (long a, long b) |
|
static std::vector< int > | factors (long target, std::vector< int > testFactors) |
|
static int | subDiv (int numerator, int denominator) |
|
static int | multipleFloor (int factor, float value) |
|
static float | interpolate (float floor, float ceiling, float position) |
|
static void | enforceMaxStereo (int value) |
|
static std::optional< UUID > | getKeyOfHighestValue (const std::map< UUID, int > &map) |
|
static int | roundToNearest (int N, int value) |
|
static std::vector< UUID > | withIdsRemoved (std::vector< UUID > fromIds, int count) |
|
static std::string | emptyZero (int value) |
|
static std::vector< std::string > | last (int num, std::vector< std::string > list) |
|
◆ dividedBy()
std::set< int > ValueUtils::dividedBy |
( |
float |
divisor, |
|
|
const std::set< int > & |
originals |
|
) |
| |
|
static |
Divide a set of integers by a float and return the divided set
- Parameters
-
divisor | to divide by |
originals | to divide |
- Returns
- divided originals
◆ eitherOr() [1/2]
float ValueUtils::eitherOr |
( |
float |
d1, |
|
|
float |
d2 |
|
) |
| |
|
static |
Return the first value if it's non-null, else the second
- Parameters
-
d1 | to check if non-null and return |
d2 | to default to, if s1 is null |
- Returns
- s1 if non-null, else s2
◆ eitherOr() [2/2]
std::string ValueUtils::eitherOr |
( |
std::string |
s1, |
|
|
std::string |
s2 |
|
) |
| |
|
static |
Return the first value if it's non-null, else the second
- Parameters
-
s1 | to check if non-null and return |
s2 | to default to, if s1 is null |
- Returns
- s1 if non-null, else s2
◆ emptyZero()
std::string ValueUtils::emptyZero |
( |
int |
value | ) |
|
|
static |
Get string value of int, or empty if zero
- Parameters
-
- Returns
- non-zero value, or empty
◆ enforceMaxStereo()
void ValueUtils::enforceMaxStereo |
( |
int |
value | ) |
|
|
static |
Enforce a maximum
- Parameters
-
- Exceptions
-
runtime_error | if value greater than allowable |
◆ factors()
std::vector< int > ValueUtils::factors |
( |
long |
target, |
|
|
std::vector< int > |
testFactors |
|
) |
| |
|
static |
Get the values (filtered from the given set of test factors) which are factors of the target value
- Parameters
-
target | which we'll test values against |
testFactors | values to test |
- Returns
- values that are indeed a factor of the target value
◆ gcd()
long ValueUtils::gcd |
( |
long |
a, |
|
|
long |
b |
|
) |
| |
|
static |
Greatest common denominator of two numbers
- Parameters
-
a | from which to compute |
b | from which to compute |
- Returns
- greatest common denominator
◆ getKeyOfHighestValue()
std::optional< UUID > ValueUtils::getKeyOfHighestValue |
( |
const std::map< UUID, int > & |
map | ) |
|
|
static |
Get the key from a map, based on the highest value stored
- Parameters
-
- Returns
- key of the highest value
◆ interpolate()
float ValueUtils::interpolate |
( |
float |
floor, |
|
|
float |
ceiling, |
|
|
float |
position |
|
) |
| |
|
static |
Interpolate a value between the floor and ceiling
- Parameters
-
floor | bottom value |
ceiling | top value |
position | between 0 and 1 of value to interpolate between the floor and ceiling |
- Returns
- interpolated value
◆ isInteger()
bool ValueUtils::isInteger |
( |
const std::string & |
raw | ) |
|
|
static |
True if input string is an integer
- Parameters
-
raw | text to check if it's an integer |
- Returns
- true if it's an integer
◆ k()
std::string ValueUtils::k |
( |
int |
value | ) |
|
|
static |
Get the "kilos" representation of an integer, as in 128k for 128000
- Parameters
-
value | for which to get kilos |
- Returns
- kilos representation
◆ last()
std::vector< std::string > ValueUtils::last |
( |
int |
num, |
|
|
std::vector< std::string > |
list |
|
) |
| |
|
static |
Get the last N values from a list
- Parameters
-
num | of entries |
list | of all entries |
- Returns
- last N entries from the list
◆ limitDecimalPrecision()
float ValueUtils::limitDecimalPrecision |
( |
float |
value | ) |
|
|
static |
Round a value to N decimal places. Architect wants to limit the floating point precision of chord and event position, in order to limit obsession over the position of things. https://www.pivotaltracker.com/story/show/154976066
- Parameters
-
- Returns
- rounded position
◆ multipleFloor()
int ValueUtils::multipleFloor |
( |
int |
factor, |
|
|
float |
value |
|
) |
| |
|
static |
Round down to a multiple of the given factor
- Parameters
-
factor | of which to get a multiple |
value | source |
- Returns
- floor of value
◆ randomFrom() [1/2]
std::string ValueUtils::randomFrom |
( |
std::vector< std::string > |
from | ) |
|
|
static |
Get a random string from the collection
- Parameters
-
from | which to get random string |
- Returns
- random string from collection
◆ randomFrom() [2/2]
std::vector< std::string > ValueUtils::randomFrom |
( |
std::vector< std::string > |
from, |
|
|
int |
num |
|
) |
| |
|
static |
Get N number of the member strings from the collection. Don't repeat a choice.
- Parameters
-
from | which to get random strings |
num | number of strings to get |
- Returns
- random strings from collection
◆ ratio()
float ValueUtils::ratio |
( |
float |
value, |
|
|
float |
limit |
|
) |
| |
|
static |
Calculate ratio (of 0 to 1) within a zero-to-N limit
- Parameters
-
value | to calculate radio of |
limit | N where ratio will be calculated based on zero-to-N |
- Returns
- ratio between 0 and 1
◆ roundToNearest()
int ValueUtils::roundToNearest |
( |
int |
N, |
|
|
int |
value |
|
) |
| |
|
static |
Round value to the nearest positive multiple of N
◆ subDiv()
int ValueUtils::subDiv |
( |
int |
numerator, |
|
|
int |
denominator |
|
) |
| |
|
static |
Get the smallest subdivision within the total, e.g. — [12,3] = 4 — [12,4] = 3 — [16,4] = 4 — [24,3] = 4 — [24,4] = 3 — [48,3] = 4 — [48,4] = 3 — [64,4] = 4
- Parameters
-
numerator | from which to compute |
denominator | from which to compute |
◆ withIdsRemoved()
std::vector< UUID > ValueUtils::withIdsRemoved |
( |
std::vector< UUID > |
fromIds, |
|
|
int |
count |
|
) |
| |
|
static |
Remove some number of ids from the list
- Parameters
-
fromIds | to begin with |
count | number of ids to add |
- Returns
- list including added ids
◆ HOURS_PER_DAY
long ValueUtils::HOURS_PER_DAY = 24 |
|
static |
◆ MICROS_PER_MILLI
long ValueUtils::MICROS_PER_MILLI = 1000 |
|
static |
◆ MICROS_PER_MINUTE
◆ MICROS_PER_MINUTE_FLOAT
◆ MICROS_PER_SECOND
◆ MICROS_PER_SECOND_FLOAT
◆ MILLIS_PER_SECOND
long ValueUtils::MILLIS_PER_SECOND = 1000 |
|
static |
◆ MINUTES_PER_HOUR
long ValueUtils::MINUTES_PER_HOUR = 60 |
|
static |
◆ NANOS_PER_MICRO
long ValueUtils::NANOS_PER_MICRO = 1000 |
|
static |
◆ NANOS_PER_SECOND
◆ SECONDS_PER_DAY
◆ SECONDS_PER_HOUR
◆ SECONDS_PER_MINUTE
long ValueUtils::SECONDS_PER_MINUTE = 60 |
|
static |
The documentation for this class was generated from the following files:
- /home/runner/work/xjmusic/xjmusic/engine/include/xjmusic/util/ValueUtils.h
- /home/runner/work/xjmusic/xjmusic/engine/src/util/ValueUtils.cpp