1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
/*
* Copyright © 2017-2020 Wellington Wallace
*
* This file is part of PulseEffects.
*
* PulseEffects is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PulseEffects is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PulseEffects. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef UTIL_HPP
#define UTIL_HPP
#include <cmath>
#include <glib-object.h>
#include <glib.h>
#include <iostream>
#include <locale>
#include <thread>
#include <vector>
namespace util {
const float minimum_db_level = -99.0F;
const float minimum_linear_level = 0.00001F;
void debug(const std::string& s);
void error(const std::string& s);
void critical(const std::string& s);
void warning(const std::string& s);
void info(const std::string& s);
auto get_global_locale() -> std::locale;
auto get_c_locale() -> std::locale;
auto logspace(const float& start, const float& stop, const uint& npoints) -> std::vector<float>;
auto linspace(const float& start, const float& stop, const uint& npoints) -> std::vector<float>;
template <typename T>
auto linear_to_db(const T& amp) -> T {
return (amp >= minimum_linear_level) ? (20.0F * log10f(amp)) : minimum_db_level;
}
template <typename T>
auto db_to_linear(const T& db) -> T {
return expf((db / 20.0F) * logf(10.0F));
}
auto db20_gain_to_linear(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
auto linear_gain_to_db20(const GValue* value, const GVariantType* expected_type, gpointer user_data) -> GVariant*;
auto db10_gain_to_linear(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
auto double_to_float(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
auto db20_gain_to_linear_double(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
auto linear_double_gain_to_db20(const GValue* value, const GVariantType* expected_type, gpointer user_data)
-> GVariant*;
auto double_x10_to_int(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
auto ms_to_ns(GValue* value, GVariant* variant, gpointer user_data) -> gboolean;
void print_thread_id();
} // namespace util
#endif
|