Ase namespace

The Anklang C++ API namespace.

Namespaces

namespace AnsiColors
The AnsiColors namespace contains utility functions for colored terminal output.
namespace Aux
Auxillary algorithms brodly useful.
namespace FastMemory
Utilities for allocating cache line aligned memory from huge pages.
namespace Lib
Namespace for implementation internals.
namespace Loft
Loft - A special purpose memory allocator for lock- and obstruction-free thread progress.
namespace MidiLib
Namespace used for Midi Processor implementations.
namespace Path
The Path namespace provides functions for file path manipulation and testing.
namespace Test
Helper namespace for unit testing.

Classes

template <size_t SIZE>
struct AlignedPOD
template <class Value>
class AsyncBlockingQueue
This is a thread-safe asyncronous queue which blocks in pop() until data is provided through push().
class AtomicBits
Vector of atomic bits, operates in blocks of 64 bits.
template <class T>
class AtomicIntrusiveStack
template <typename Value, template<class> class GrowOnlyAllocator = Loft::Allocator>
struct AtomicStack
class AudioEngine
struct AudioParams
Audio parameter handling, internal to AudioProcessor.
class AudioProcessor
Audio signal AudioProcessor base class, implemented by all effects and instruments.
struct AudioProcessorInfo
Detailed information and common properties of AudioProcessor subclasses.
struct AudioTransport
Transport information for AudioSignal processing.
class AutoSeeder
AutoSeeder provides non-deterministic seeding entropy.
class Blob
Binary large object storage container.
struct BusInfo
Structure providing supplementary information about input/output buses.
struct CPUInfo
Acquire information about the runtime architecture and CPU type.
class CString
Compact, deduplicating string variant for constant strings.
class CStringTable
Map std::string <-> uint IDs, thread safe.
template <class... A>
class CallbackList
Reentrant callback list with configurable arguments.
struct Choice
Representation of one possible choice for selection properties.
class Clip
Container for MIDI note and control events.
struct ClipNote
Part specific note event representation.
struct ConvertJsTrigger
Convert between Jsonipc::JsonValue to JsTrigger.
struct ConvertValue
Convert between Value and Jsonipc::JsonValue.
struct ConvertValueP
Convert between ValueP and Jsonipc::JsonValue.
struct ConvertValueR
Convert between ValueR and Jsonipc::JsonValue.
struct ConvertValueRP
Convert between std::shared_ptr<ValueR> and Jsonipc::JsonValue.
class CustomDataContainer
template <typename T>
class CustomDataKey
CustomDataKey objects are used to identify and manage custom data members of CustomDataContainer objects.
class Device
Interface to access Device instances.
struct DeviceInfo
Info for device types.
class DispatcherSource
EventLoop source for handler execution.
class Driver
Base class for a PCM and MIDI devices.
struct DriverEntry
Driver information for PCM and MIDI handling.
class Emittable
Base type for classes with Event subscription.
class EmittableImpl
Implementation type for classes with Event subscription.
struct EnumInfo
Get auxiallary enum information.
struct Event
Structure for callback based notifications.
class EventFd
Wakeup facility for IPC.
template <class Event, class Compare>
class EventList
Maintain an array of unique Event structures with change notification.
class EventLoop
Loop object, polling for events and executing callbacks in accordance.
class EventSource
EventLoop source for callback execution.
template <typename T, size_t ALIGNMENT = FastMemory::cache_line_size>
class FastMemArray
Array with cache-line-alignment containing a fixed numer of PODs.
class FileCrawler
Class implementing a file system crawler.
union FloatIEEE754
class Gadget
Base type for classes that have a Property.
class GadgetImpl
Base type for classes that have a Property.
template <class, class = void>
struct Has_serialize_f
Has_serialize_f<T> - Check if serialize(T&,WritNode&) is provided for T.
struct Id32
Helper class for integer IDs up to 32 Bit, possibly of enum type.
class IniFile
Class to parse INI configuration file sections and values.
class IniWriter
Class to write INI configuration file sections and values.
class JsTrigger
Callback mechanism for Jsonapi/Jsonipc.
class KeccakCryptoRng
class KeccakFastRng
class KeccakGoodRng
class KeccakRng
struct LoftConfig
Configuration for Loft allocations.
struct LoftFree
A std::unique_ptr<> deleter for Loft allocations.
struct LoftStats
Statistics for Loft allocations.
struct Logscale
Logarithmically map (and invert) a range onto 0…+1.
class MainLoop
An EventLoop implementation that offers public API for running the loop.
template <auto setter, auto getter = nullptr>
class Member
Implement C++ member field API with a 0-sized class from setter and getter, maybe combined with [[no_unique_address]].
template <auto accessor>
class Member<accessor, nullptr>
Member accessor class based on a single accessor, maybe combined with [[no_unique_address]].
class MidiDriver
Base class for a MIDI devices.
struct MidiEvent
MidiEvent data structure.
class MidiEventOutput
A stream of writable MidiEvent structures.
template <size_t MAXQUEUES>
class MidiEventReader
An in-order MidiEvent reader for multiple MidiEvent sources.
struct MidiNote
Components of a MIDI note.
class Monitor
Interface for monitoring output signals.
template <typename Node>
struct MpmcStack
template <class T>
struct Mutable
Helper to modify const struct contents, e.g. asyn job lambda members.
class Mwc256
Marsaglia multiply-with-carry generator, period ca 2^255.
class NativeDevice
Interface to access NativeDevice instances.
class Object
Base type for classes with Property interfaces.
class ObjectImpl
Implementation type for classes with Property interfaces.
template <class Event, class CompareOrder>
struct OrderedEventList
Container for a sorted array of opaque Event structures with binary lookup.
struct Param
Structured initializer for Parameter.
struct ParamExtraVals
Helper to specify parameter ranges.
struct Parameter
Structure to provide information about properties or preferences.
struct ParameterMap
Parameter list construction helper.
class ParameterProperty
Abstract base type for Property implementations with Parameter meta data.
class Pcg32Rng
class PcmDriver
Base class for a PCM devices.
struct PcmDriverConfig
PCM device configuration.
template <class Class>
class Persistent
struct PollFD
Mirrors struct pollfd for poll(3posix)
class PollFDSource
EventLoop source for IO callbacks.
class Preference
Class for preference parameters (global settings)
struct ProbeFeatures
Bits representing a selection of probe sample data features.
class ProcessorManager
Interface for management, connecting and processing of AudioProcessor instances.
class Project
Projects support loading, saving, playback and act as containers for all other sound objects.
class Property
A Property allows querying, setting and monitoring of an object property.
class PropertyImpl
Property implementation for GadgetImpl, using lambdas as accessors.
template <size_t MAXQUEUES, class ForwardIterator>
struct QueueMultiplexer
class Re
Wrapper for std::regex to simplify usage and reduce compilation time.
struct Resource
Description of a resource, possibly nested.
class ResourceCrawler
Helper to crawl hierarchical resources.
struct RtCall
Wrap simple callback pointers, without using malloc (obstruction free).
struct RtJobQueue
Add a simple callback to the main event loop, without using malloc (obstruction free).
struct SHA3_224
struct SHA3_256
struct SHA3_384
struct SHA3_512
struct SHAKE128
struct SHAKE256
class Serializable
Interface for serializable objects with Reflink support.
class Server
Central singleton, serves as API entry point.
class SharedBase
Common base type for polymorphic classes managed by std::shared_ptr<>.
template <class T, class Less = std::less<T>>
class SortedVector
Vector that keeps its elements sorted.
class Strings
Convenience Constructor for StringSeq or std::vector<std::string>
class TaskRegistry
The task registry keeps track of runtime threads for profiling and statistical purposes.
struct TaskStatus
Acquire information about a task (process or thread) at runtime.
struct TelemetryField
Telemetry segment location.
struct TelemetrySegment
Telemetry segment location.
struct TickSignature
Musical time signature and tick conversions.
class TimedSource
EventLoop source for timer execution.
class Track
Container for Clip objects and sequencing information.
class TrackImpl
Ase::Track implementation.
class USignalSource
EventLoop source for handler execution.
struct UserNote
Contents of user interface notifications.
struct Value
Value type used to interface with various property types.
struct VirtualBase
Common base type to allow casting between polymorphic classes.
class Writ
Document containing all information needed to serialize and deserialize a Value.
template <typename T, typename = void>
struct WritConverter
Template to specialize string conversion for various data types.
class WritNode
One entry in a Writ serialization document.

Enums

enum class Error: int32_t { NONE = 0, PERMS = EPERM, IO = EIO, NO_MEMORY = ENOMEM, NO_SPACE = ENOSPC, NO_FILES = ENFILE, MANY_FILES = EMFILE, RETRY = EINTR, NOT_DIRECTORY = ENOTDIR, FILE_NOT_FOUND = ENOENT, FILE_IS_DIR = EISDIR, FILE_EXISTS = EEXIST, FILE_BUSY = EBUSY, INTERNAL = 0x30000000, UNIMPLEMENTED, FILE_EOF = 0x30001000, FILE_OPEN_FAILED, FILE_SEEK_FAILED, FILE_READ_FAILED, FILE_WRITE_FAILED, PARSE_ERROR = 0x30002000, NO_HEADER, NO_SEEK_INFO, NO_DATA_AVAILABLE, DATA_CORRUPT, WRONG_N_CHANNELS, FORMAT_INVALID, FORMAT_UNKNOWN, DATA_UNMATCHED, CODEC_FAILURE, BROKEN_ARCHIVE, BAD_PROJECT, NO_PROJECT_DIR, DEVICE_NOT_AVAILABLE = 0x30003000, DEVICE_ASYNC, DEVICE_BUSY, DEVICE_FORMAT, DEVICE_BUFFER, DEVICE_LATENCY, DEVICE_CHANNELS, DEVICE_FREQUENCY, DEVICES_MISMATCH, WAVE_NOT_FOUND = 0x30004000, INVALID_PROPERTY, INVALID_MIDI_CONTROL, OPERATION_BUSY }
Enum representing Error states.
enum class IBusId: uint16 { }
ID type for AudioProcessor input buses, buses are numbered with increasing index.
enum class MidiEventType: uint8_t { PARAM_VALUE = 0x70, NOTE_OFF = 0x80, NOTE_ON = 0x90, AFTERTOUCH = 0xA0, CONTROL_CHANGE = 0xB0, PROGRAM_CHANGE = 0xC0, CHANNEL_PRESSURE = 0xD0, PITCH_BEND = 0xE0, SYSEX = 0xF0 }
Type of MIDI Events.
enum class MidiMessage: int32_t { NONE = 0, ALL_SOUND_OFF = 120, RESET_ALL_CONTROLLERS = 121, LOCAL_CONTROL = 122, ALL_NOTES_OFF = 123, OMNI_MODE_OFF = 124, OMNI_MODE_ON = 125, MONO_MODE_ON = 126, POLY_MODE_ON = 127, PARAM_VALUE = 0x70, NOTE_OFF = 0x80, NOTE_ON = 0x90, AFTERTOUCH = 0xA0, CONTROL_CHANGE = 0xB0, PROGRAM_CHANGE = 0xC0, CHANNEL_PRESSURE = 0xD0, PITCH_BEND = 0xE0, SYSEX = 0xF0 }
Extended type information for MidiEvent.
enum class MusicalTuning: uint8 { OD_12_TET, OD_7_TET, OD_5_TET, DIATONIC_SCALE, INDIAN_SCALE, PYTHAGOREAN_TUNING, PENTATONIC_5_LIMIT, PENTATONIC_BLUES, PENTATONIC_GOGO, QUARTER_COMMA_MEANTONE, SILBERMANN_SORGE, WERCKMEISTER_3, WERCKMEISTER_4, WERCKMEISTER_5, WERCKMEISTER_6, KIRNBERGER_3, YOUNG }
Musical tunings, see: http://en.wikipedia.org/wiki/Musical_tuning.
enum class OBusId: uint16 { }
ID type for AudioProcessor output buses, buses are numbered with increasing index.
enum class ParamId: uint32 { }
ID type for AudioProcessor parameters, the ID numbers are user assignable.
enum class SpeakerArrangement: uint64_t { NONE = 0, FRONT_LEFT = 0x1, FRONT_RIGHT = 0x2, FRONT_CENTER = 0x4, LOW_FREQUENCY = 0x8, BACK_LEFT = 0x10, BACK_RIGHT = 0x20, AUX = uint64_t (1) << 63, MONO = FRONT_LEFT, STEREO = FRONT_LEFT | FRONT_RIGHT, STEREO_21 = STEREO | LOW_FREQUENCY, STEREO_30 = STEREO | FRONT_CENTER, STEREO_31 = STEREO_30 | LOW_FREQUENCY, SURROUND_50 = STEREO_30 | BACK_LEFT | BACK_RIGHT, SURROUND_51 = SURROUND_50 | LOW_FREQUENCY }

Typedefs

template <class T>
using Atomic = boost::atomic<T>
Substitute for std::atomic<> with fixes for GCC.
using ChoicesFunc = std::function<ChoiceS(const CString&)>
Handler to generate all possible parameter choices dynamically.
template <typename T>
using LoftPtr = std::unique_ptr<T, LoftFree>
A std::unique_ptr<> for Loft allocations.
using MinMaxStep = std::tuple<double, double, double>
Min, max, stepping for double ranges.
using ParamInitialVal = std::variant<bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double, const char*, std::string>
Initial value for parameters.
using PropertyGetter = std::function<void(Value&)>
Function type for Property value getters.
using PropertyLister = std::function<ChoiceS(const ParameterProperty&)>
Function type to list Choice Property values.
using PropertySetter = std::function<bool(const Value&)>
Function type for Property value setters.
template <bool value>
using REQUIRES = typename ::std::enable_if<value, bool>::type
REQUIRES<value> - Simplified version of std::enable_if<cond,bool>::type to use SFINAE in function templates.
template <bool value>
using REQUIRESv = typename ::std::enable_if<value, void>::type
REQUIRESv<value> - Simplified version of std::enable_if<cond,void>::type to use SFINAE in struct templates.
using String = std::string
Convenience alias for std::string.
using StringS = std::vector<String>
Convenience alias for a std::vector<std::string>.
using ValueVariant = std::variant<std::monostate, bool, int64, double, String, ValueS, ValueR, InstanceP>
Variant type to hold different types of values.
using int16 = int16_t
A 16-bit signed integer.
using int32 = int32_t
A 32-bit signed integer.
using int64 = int64_t
A 64-bit unsigned integer, use PRI*64 in format strings.
using int8 = int8_t
An 8-bit signed integer.
using uint = uint32_t
Provide 'uint' as convenience type.
using uint16 = uint16_t
A 16-bit unsigned integer.
using uint32 = uint32_t
A 32-bit unsigned integer.
using uint64 = uint64_t
A 64-bit unsigned integer, use PRI*64 in format strings.
using uint8 = uint8_t
An 8-bit unsigned integer.
using unichar = uint32_t
A 32-bit unsigned integer used for Unicode characters.

Functions

static auto anklang_cachedir_base(bool createbase = false) →  String
Find base directory for the creation of temporary caches.
static void atexit_clean_cachedirs()
Clean temporary caches of this process.
static auto bit_rotate64(uint64_t bits, unsigned int offset) →  uint64_t
Rotate left for uint64_t.
template <class Num>
static auto byte_hash64(const Num* data, size_t length) →  ASE_CONST uint64_t
Fast byte hashing with good dispersion and runtime randomization.
static auto codepoint_is_namestartchar(uint32_t c) →  bool
static auto codepoint_is_ncname(uint32_t c) →  bool
template <typename T>
static auto divmod(T dividend, T divisor, T* reminderp) →  T constexpr
Compute integers division and modulo with one X86 asm instruction.
static auto find_text_file(ptrdiff_t symbol_address) →  std::string
Find the binary file containing the runtime symbol at symbol_address.
template <class Num>
static auto fnv1a_consthash64(const Num* ztdata) →  uint64_t constexpr
template <class Num>
static auto fnv1a_consthash64(const Num*const data, size_t length) →  uint64_t constexpr
Variant of fnv1a_consthash64() for memory blocks of arbitrary size.
static auto has_debug_key(const char*const debugkeys, const char*const key) →  bool
Quick boolean check for a colon separated key in a haystack.
static auto hash_secret() →  ASE_PURE uint64_t
Provide hashing nonce for reseeding hashes at program start to avoid collision attacks.
static auto initialized_ase_gettext_domain() →  const char*
Initialize gettext domain for ASE.
template <std::size_t LAST, typename MkFun>
static auto make_case_table(const MkFun& mkjump) →  auto
template <typename MkFun, size_t ... INDICES>
static auto make_indexed_table(const MkFun& mkjump, std::index_sequence<INDICES...>) →  auto
Create a std::array<Fun,N>, where Fun is returned from mkjump (INDICES…).
template <class Num>
static auto pcg_hash32(const Num* data, size_t length, uint64_t seed) →  ASE_CONST uint32_t
template <class Num>
static auto pcg_hash64(const Num* data, size_t length, uint64_t seed) →  ASE_CONST uint64_t
static auto pcg_hash64(const char* ztdata, uint64_t seed) →  ASE_CONST uint64_t
pcg_hash64() variant for zero-terminated strings.
static auto pid_string(int pid) →  String
Create process specific string for a .pid guard file.
template <typename UInt>
static auto rotl(UInt bits, uint32_t offset) →  UInt constexpr
Bitwise rotate-left pattern recognized by gcc & clang at -O1 iff sizeof (bits) == {8,16,32,64}.
template <typename UInt>
static auto rotr(UInt bits, uint32_t offset) →  UInt constexpr
Bitwise rotate-right pattern recognized by gcc & clang at -O1 iff sizeof (bits) == {8,16,32,64}.
static auto string_hash64(const std::string& string) →  ASE_CONST uint64_t
Fast string hashing with good dispersion for std::string and runtime randomization.
static auto string_hash64(const char* ztdata) →  ASE_CONST uint64_t
pcg_hash64() variant for zero-terminated strings.
static auto tmpdir_prefix() →  String
Prefix for temporary cache directories, also used for pruning of stale directories.
template <typename T>
static auto unalias_ptr(T* ptr) →  T*
Force compiler to forget the origin of a possibly aliasing pointer.
template <int CODEPOINT>
static auto utf8character(const char* str, uint32_t* unicode) →  size_t
static auto utf8codepoint(const char* str, uint32_t* unicode) →  size_t
Returns length of unicode character in bytes.
static auto utf8skip(const char* str) →  size_t
Returns length of unicode character in bytes.
auto _(const char* string) →  const char*()
Translate message strings in the Anklang/ASE text domain.
auto _(const std::string& string) →  std::string()
Translate message strings in the Anklang/ASE text domain.
auto _(const char* string, const char* plural, int64_t n) →  const char*()
Translate message strings in the Anklang/ASE text domain, use @plural forms if
!= 1.
auto _(const std::string& string, const std::string& plural, int64_t n) →  std::string()
Translate message strings in the Anklang/ASE text domain, use @plural forms if
!= 1.
template <class T>
__attribute__((__pure__))
Provide demangled stringified name for type T.
template <class T>
__attribute__((__pure__))
Provide demangled stringified name for object obj.
template <class Type, class ... Ts>
__attribute__((always_inline)) inline void new _inplace(Type &typemem
Call inplace new operator by automatically inferring the Type.
template <class Type>
__attribute__((always_inline))
Call inplace delete operator by automatically inferring the Type.
void anklang_cachedir_clean_stale()
Clean stale cache directories from past runtimes, may be called from any thread.
void anklang_cachedir_cleanup(const String& cachedir)
Cleanup a cachedir previously created with anklang_cachedir_create().
auto anklang_cachedir_create() →  String
Create exclusive cache directory for this process' runtime.
auto anklang_home_dir(const String& subdir) →  String
Get Anklang home dir, possibly adding subdir.
auto anklang_runpath(RPath rpath, const String& segment) →  std::string
Retrieve various resource paths at runtime.
auto application_name() →  String
Retrieve the localized program name intended for user display.
void application_name_init(String desktopname)
Set the application_name to a name other than program_alias if desired.
auto ase_build_id() →  const char*
Provide a string containing the ASE library build id.
auto ase_error_blurb(Error error) →  const char*
Describe Error condition.
template <class A0, class... Ar>
auto ase_gettext(const char* format, const A0& a0, const Ar&... restargs) →  const char*
Translate a string, using the ASE locale.
auto ase_version() →  const char*
Provide a string containing the package version.
void assertion_failed(const char* msg, const char* file, int line, const char* func) noexcept
Print instructive message, handle "breakpoint", "backtrace" and "fatal-warnings" in $ASE_DEBUG.
void assertion_fatal(const char* msg, const char* file, int line, const char* func) noexcept
Print a debug message via assertion_failed() and abort the program.
auto backtrace_command() →  std::string
Find GDB and construct command line.
void breakpoint() ASE_ALWAYS_INLINE
Cause a debugging breakpoint, for development only.
template <class T>
void call_delete(T* o)
Simple way to create a standalone callback to delete an object of type T.
void collect_runtime_entropy(uint64* data, size_t n)
Collect entropy from the current process, usually quicker than collect_system_entropy().
void collect_system_entropy(uint64* data, size_t n)
Collect entropy from system devices, like interrupt counters, clocks and random devices.
auto constexpr_equals(const char* a, const char* b, size_t n) →  bool constexpr
Test string equality at compile time.
auto cpu_arch() →  std::string
Retrieve string identifying the CPU architecture.
auto cpu_info() →  String
Retrieve string identifying the runtime CPU type.
auto cstrings_to_vector(const char* s, ...) →  StringS
Construct a StringS from a NULL terminated list of string arguments.
auto current_locale_strtold(const char* nptr, char** endptr) →  long double
Parse a double from a string ala strtod(), trying locale specific characters and POSIX/C formatting.
auto damerau_levenshtein_distance(const std::string& source, const std::string& target, const float ci, const float cd, const float cs, const float ct) →  float
auto damerau_levenshtein_restricted(const std::string& source, const std::string& target, const float ci, const float cd, const float cs, const float ct) →  float
template <typename Float>
auto db2voltage(Float x) →  Float
Convert Decibel to synthesizer value (Voltage).
template <typename Float>
auto db2voltage(Float x) →  ASE_CONST Float
Convert Decibel to synthesizer value (Voltage).
template <typename Float>
auto db_changed(Float a, Float b) →  Float
Determine a significant Decibel change.
template <typename Float>
auto db_changed(Float a, Float b) →  ASE_CONST Float
Determine a significant Decibel change.
template <class ... Args>
auto debug(const char* cond, const char* format, const Args&... args) →  void ASE_ALWAYS_INLINE
Issue a printf-like debugging message if cond is enabled by $ASE_DEBUG.
auto debug_enabled() →  bool
Check if any kind of debugging is enabled by $ASE_DEBUG.
auto debug_key_enabled(const char* conditional) →  bool
Check if conditional is enabled by $ASE_DEBUG.
auto debug_key_enabled(const ::std::string& conditional) →  bool
Check if conditional is enabled by $ASE_DEBUG.
auto debug_key_value(const char* conditional) →  ::std::string
Retrieve the value assigned to debug key conditional in $ASE_DEBUG.
void debug_message(const char* cond, const std::string& message)
Print a debug message, called from Ase::debug().
auto decodefs(const std::string& utf8str) →  std::string
Decode UTF-8 string back into file system path representation, extracting surrogate code points as bytes.
void diag_flush(uint8 code, const String& txt)
Handle stdout and stderr printing with flushing.
auto diag_prefix(uint8 code) →  String
Create prefix for warnings and errors.
auto displayfs(const std::string& utf8str) →  std::string
Convert UTF-8 encoded file system path into human readable display format, the conversion is lossy but readable.
auto encodefs(const std::string& fschars) →  std::string
Encode a file system path consisting of bytes into UTF-8, using surrogate code points to store non UTF-8 bytes.
template <typename Enum>
auto enum_lister(const ParameterProperty&) →  ChoiceS
Helper to list Jsonipc::Enum<> type values as Choice.
auto executable_name() ASE_PURE -> std::string
Retrieve the name part of executable_path().
auto executable_path() →  std::string
Retrieve the path to the currently running executable.
void fast_copy(size_t n, float* d, const float* s)
Copy a block of floats.
void fast_copy(size_t n, uint32_t* d, const uint32_t* s)
Copy a block of integers.
auto fast_db2voltage(float x) →  float
Float precision variant of db2voltage using fast_exp2().
auto fast_exp2(float x) ASE_CONST -> float
auto fast_hz2voltage(float x) →  float
Float precision variant of hz2voltage using fast_log2().
auto fast_log2(float x) ASE_CONST -> float
auto fast_voltage2db(float x) →  float
Float precision variant of voltage2db using fast_log2().
auto fast_voltage2hz(float x) →  float
Float precision variant of voltage2hz using fast_exp2().
template <class ... Args>
auto fatal_error(const char* format, const Args&... args) →  void ASE_NORETURN
template <class RandomIt, class Compare>
void fixed_sort(RandomIt first, RandomIt last, Compare comp = std::less<typename std::iterator_traits<RandomIt>::value_type>())
Use sorting networks to sort containers <= 16 elements without allocations.
void floatfill(float* dst, float f, size_t n)
Fill n values of dst with f.
auto force_double(double d) →  double
Force number into double precision floating point format, even with -ffast-math.
auto force_float(float f) →  float
Force number into single precision floating point format, even with -ffast-math.
auto hz2value(float x) ASE_CONST -> float
Convert Hertz to synthesizer value (Voltage).
template <typename Float>
auto hz2voltage(Float x) →  Float
Convert Hertz to synthesizer value (Voltage).
template <typename Float>
auto hz2voltage(Float x) →  ASE_CONST Float
Convert Hertz to synthesizer value (Voltage).
template <typename Float>
auto hz_changed(Float a, Float b) →  Float
Determine a significant frequency change (audible Hertz).
template <typename Float>
auto hz_changed(Float a, Float b) →  ASE_CONST Float
Determine a significant frequency change (audible Hertz).
auto irintf(float f) →  ASE_CONST int
template <class T>
auto json_parse(const String& jsonstring, T& target) →  bool
Parse a well formed JSON string and assign contents to target.
template <class T>
auto json_parse(const String& jsonstring) →  T
Parse a well formed JSON string and return the resulting value.
template <class T>
auto json_stringify(const T& source, Writ::Flags flags = Writ::Flags(0)) →  String
Create JSON string from source.
void load_registered_drivers()
Load all registered drivers.
auto loft_alloc(size_t size, size_t align) →  LoftPtr<void>
Allocate size bytes (with limited alignment support), may return a nullptr.
auto loft_bucket_size(size_t nbytes) →  size_t
Calculate the real bucket size allocated for a requested size.
auto loft_calloc(size_t nelem, size_t elemsize, size_t align) →  LoftPtr<void>
Allocate and 0-initialize nelem * elemsize bytes, may return a nullptr.
void loft_get_config(LoftConfig& config)
Retrieve current configuration.
void loft_get_stats(LoftStats& stats)
Get statistics about current Loft allocations.
auto loft_grow_preallocate(size_t preallocation_amount) →  size_t
Grow the preallocated arena, issues syscalls.
template <class T, class ... Args>
auto loft_make_unique(Args && ... args) →  LoftPtr<T>
Construct an object T from Loft memory, wrapped in a unique_ptr.
void loft_set_config(const LoftConfig& config)
Configure watermark, notification, etc.
void loft_set_notifier(const std::function<void()>& lowmem)
Install obstruction free callback to notify about watermark underrun.
auto loft_stats_string(const LoftStats& stats) →  String
Stringify LoftStats.
void log_setup(bool inf2stderr, bool log2file)
Open log file.
template <class... A>
auto logerr(const String& dept, const char* format, const A&... args) ASE_PRINTF(2 -> void void
Format and send a log message to the user, stderr and log file, using the POSIX/C locale.
template <class... A>
void logerr(const String& dept, const char* format, const A&... args)
Log error to stderr and logfile.
template <class... A>
void loginf(const char* format, const A&... args) ASE_PRINTF(1
Write a string_format() message to the log file (or possibly stderr), using the POSIX/C locale.
template <class... A>
void logtxt(const char* format, const A&... args)
Log text into logfile only.
template <typename Enum>
auto make_enum_getter(Enum* v) →  std::function<void(Value&)>
Value getter for enumeration types.
template <typename Enum>
auto make_enum_setter(Enum* v) →  std::function<bool(const Value&)>
Value setter for enumeration types.
void memset4(uint32* mem, uint32 filler, uint length)
Fill a memory area with a 32-bit quantitiy.
auto monotonic_counter() →  uint64
A monotonically increasing counter, increments are atomic and visible in all threads.
auto operator+=(ChoiceS& choices, Choice&& newchoice) →  ChoiceS&
Convenience ChoiceS construciton helper.
auto parameter_guess_nick(const String& parameter_label) →  String
Create a few letter nick name from a multi word parameter label.
auto posix_locale_strtold(const char* nptr, char** endptr) →  long double
Parse a double from a string ala strtod(), trying locale specific characters and POSIX/C formatting.
template <class... Args>
void printerr(const char* format, const Args&... args)
Print a message on stderr (and flush stderr) ala printf(), using the POSIX/C locale.
template <class... Args>
void printout(const char* format, const Args&... args)
Print a message on stdout (and flush stdout) ala printf(), using the POSIX/C locale.
auto program_alias() →  String
Retrieve the program name as used for logging or debug messages.
void program_alias_init(String customname)
Set program_alias to a non-localized alias other than program_argv0 if desired.
auto program_cwd() →  String
The current working directory during startup.
auto random_float() →  double
auto random_frange(double begin, double end) →  double
auto random_int64() →  uint64_t
auto random_irange(int64_t begin, int64_t end) →  int64_t
auto random_nonce() →  uint64_t
Provide a unique 64 bit identifier that is not 0, see also random_int64().
void random_secret(uint64_t* secret_var)
Generate a secret non-zero nonce in secret_var, unless it has already been assigned.
template <typename T>
auto register_audio_processor(const char* aseid = nullptr) →  CString
Add an AudioProcessor derived type to the audio processor registry.
auto register_driver_loader(const char* staticwhat, Error(*)() loader) →  bool*
Register loader callbacks at static constructor time.
auto sched_fast_priority(int tid) →  bool
Try to acquire low latency scheduling priority, returns true if nice level is < 0.
auto sched_get_priority(int tid) →  int
Retrieve the nice level of process or thread tid.
auto sched_set_priority(int tid, int nicelevel) →  bool
Try to set the nice level of process or thread tid to nicelevel.
void sha3_224_hash(const void* data, size_t data_length, uint8_t hashvalue[28])
Calculate 224 bit SHA3 digest from data, see also class SHA3_224.
void sha3_256_hash(const void* data, size_t data_length, uint8_t hashvalue[32])
Calculate 256 bit SHA3 digest from data, see also class SHA3_256.
void sha3_384_hash(const void* data, size_t data_length, uint8_t hashvalue[48])
Calculate 384 bit SHA3 digest from data, see also class SHA3_384.
void sha3_512_hash(const void* data, size_t data_length, uint8_t hashvalue[64])
Calculate 512 bit SHA3 digest from data, see also class SHA3_512.
void shake128_hash(const void* data, size_t data_length, uint8_t* hashvalues, size_t n)
Calculate SHA3 extendable output digest for 128 bit security strength, see also class SHAKE128.
void shake256_hash(const void* data, size_t data_length, uint8_t* hashvalues, size_t n)
Calculate SHA3 extendable output digest for 256 bit security strength, see also class SHAKE256.
template <class Target, class Source>
auto shared_ptr_cast(Source* object) →  std::shared_ptr<typename std::remove_pointer<Target>::type>
template <class Target, class Source>
auto shared_ptr_cast(const Source* object) →  const std::shared_ptr<typename std::remove_pointer<Target>::type>
See shared_ptr_cast(Source*).
template <class Target, class Source>
auto shared_ptr_cast(std::shared_ptr<Source>& sptr) →  std::shared_ptr<typename std::remove_pointer<Target>::type>
See shared_ptr_cast(Source*).
template <class Target, class Source>
auto shared_ptr_cast(const std::shared_ptr<Source>& sptr) →  const std::shared_ptr<typename std::remove_pointer<Target>::type>
See shared_ptr_cast(Source*).
template <class Source>
auto shared_ptr_from(Source* object) →  std::shared_ptr<typename std::remove_pointer<Source>::type>
Use shared_ptr_cast<>() to convert an object pointer into a shared_ptr<>.
auto square_max(uint n_values, const float* ivalues) →  float
Find the maximum suqared value in a block of floats.
auto square_sum(uint n_values, const float* ivalues) →  float
Calculate suqare sum of a block of floats.
auto strerror(int errno_num) →  const char*
Get POSIX locale strerror.
auto string_canonify(const String& string, const String& valid_chars, const String& substitute) →  String
auto string_capitalize(const String& str, size_t maxn, bool rest_tolower) →  String
Capitalize words, so the first letter is upper case, the rest lower case.
auto string_casecmp(const String& s1, const String& s2) →  int
Like strcasecmp(3) for UTF-8 strings.
auto string_casefold(const String& src) →  String
Yield UTF-8 string useful for case insensitive comparisons.
auto string_cmp(const String& s1, const String& s2) →  int
Like strcmp(3) for UTF-8 strings.
auto string_cmp_uuid(const String& uuid_string1, const String& uuid_string2) →  int
Returns whether uuid_string1 compares smaller (-1), equal (0) or greater (+1) to uuid_string2.
auto string_demangle_cxx(const char* mangled_identifier) →  const char* noexcept
Demangle identifier via libcc.
auto string_endswith(const String& string, const String& fragment) →  bool
Returns whether string ends with fragment.
auto string_endswith(const String& string, const StringS& fragments) →  bool
Returns whether string ends with any element of fragments.
auto string_find_word(const char* haystack, const char* word) →  const char*
Find occurance of word in haystack.
template <class... Args>
auto string_format(const char* format, const Args&... args) →  ASE_NOINLINE String
Formatted printing ala printf() into a String, using the POSIX/C locale.
auto string_from_bool(bool value) →  String
Convert a boolean value into a string.
auto string_from_cquote(const String& input) →  String
Parse a possibly quoted C string into regular string.
auto string_from_double(double value) →  String
Convert a double into a string, using the POSIX/C locale.
auto string_from_double_vector(const std::vector<double>& dvec, const String& delim) →  String
Construct a string out of all double values passed in dvec, separated by delim.
auto string_from_errno(int errno_val) →  String
Returns a String describing the passed in errno value, similar to strerror().
auto string_from_float(float value) →  String
Convert a float into a string, using the POSIX/C locale.
auto string_from_int(int64 value) →  String
Convert a 64bit signed integer into a string.
auto string_from_long_double(long double value) →  String
Convert a long double into a string, using the POSIX/C locale.
auto string_from_pretty_function_name(const char* cxx_pretty_function) →  String
template <typename Type>
auto string_from_type(Type value) →  String
Create a string from a templated argument value, such as bool, int, double.
auto string_from_uint(uint64 value) →  String
Convert a 64bit unsigned integer into a string.
auto string_has_int(const String& string) →  bool
Checks if a string contains a digit, optionally preceeded by whitespaces.
auto string_hexdump(const void* addr, size_t length, size_t initial_offset) →  String
auto string_is_canonified(const String& string, const String& valid_chars) →  bool
Check if string_canonify() would modify string.
auto string_is_ncname(const String& input) →  bool
auto string_is_uuid(const String& uuid_string) →  bool
Returns whether uuid_string contains a properly formatted UUID string.
auto string_islower(const String& str) →  bool
Check if all string characters are Unicode lower case characters.
auto string_isupper(const String& str) →  bool
Check if all string characters are Unicode upper case characters.
auto string_join(const String& junctor, const StringS& strvec) →  String
template <class... Args>
auto string_locale_format(const char* format, const Args&... args) →  ASE_NOINLINE String
Formatted printing ala printf() into a String, using the current locale.
auto string_locale_vprintf(const char* format, va_list vargs) →  String
Formatted printing like string_vprintf using the current locale.
auto string_lstrip(const String& input) →  String
Strip whitespaces from the left of a string.
auto string_match_identifier(const String& ident1, const String& ident2) →  bool
Check equality of strings canonicalized to "[0-9a-z_]+".
auto string_match_identifier_tail(const String& ident, const String& tail) →  bool
Variant of string_match_identifier() that matches tail against ident at word boundary.
auto string_multiply(const String& s, uint64 count) →  String
Reproduce a string s for count times.
auto string_normalize_nfc(const String& src) →  String
Yield normalized composed UTF-8 string.
auto string_normalize_nfd(const String& src) →  String
Yield normalized decomposed UTF-8 string.
auto string_normalize_nfkc(const String& src) →  String
Formatting stripped normalized composed UTF-8 string.
auto string_normalize_nfkd(const String& src) →  String
Formatting stripped normalized decomposed UTF-8 string.
auto string_option_check(const String& optionlist, const String& feature) →  bool
Check if an option is set/unset in an options list string.
auto string_option_find(const String& optionlist, const String& feature, const String& fallback) →  String
Retrieve the option value from an options list separated by ':' or ';' or fallback.
auto string_option_find_value(const char* string, const char* feature, const String& fallback, const String& denied, bool matchallnone) →  std::string_view
Low level option search, avoids dynamic allocations.
auto string_replace(const String& input, const String& marker, const String& replacement, size_t maxn) →  String
Replace substring marker in input with replacement, at most maxn times.
auto string_rstrip(const String& input) →  String
Strip whitespaces from the right of a string.
auto string_set_A2Z() →  const String&
Returns a string containing all of A-Z.
auto string_set_a2z() →  const String&
Returns a string containing all of a-z.
auto string_set_ascii_alnum() →  const String&
Returns a string containing all of 0-9, A-Z and a-z.
auto string_split(const String& string, const String& splitter, size_t maxn) →  StringS
auto string_split_any(const String& string, const String& splitchars, size_t maxn) →  StringS
auto string_startswith(const String& string, const String& fragment) →  bool
Returns whether string starts with fragment.
auto string_startswith(const String& string, const StringS& fragments) →  bool
Returns whether string starts with any element of fragments.
auto string_strip(const String& input) →  String
Strip whitespaces from the left and right of a string.
auto string_substitute_char(const String& input, const char match, const char subst) →  String
Replace all occouranes of match in input with subst.
auto string_to_bool(const String& string, bool fallback) →  bool
auto string_to_cescape(const String& str) →  String
auto string_to_cquote(const String& str) →  String
Returns a string as C string including double quotes.
auto string_to_double(const String& string) →  double
Parse a double from a string, trying locale specific characters and POSIX/C formatting.
auto string_to_double(const char* dblstring, const char** endptr) →  double
Similar to string_to_double(const String&), but returns the first failing character position in endptr.
auto string_to_double_vector(const String& string) →  std::vector<double>
Parse a string into a list of doubles, expects ';' as delimiter.
auto string_to_hex(const String& input) →  String
Convert bytes in string input to hexadecimal numbers.
auto string_to_identifier(const String& input) →  String
Force lower case, alphanumerics + underscore and non-digit start.
auto string_to_int(const String& string, size_t* consumed, uint base) →  int64
Parse a string into a 64bit integer, optionally specifying the expected number base.
auto string_to_long_double(const String& string) →  long double
Parse a long double from a string, trying locale specific characters and POSIX/C formatting.
auto string_to_long_double(const char* dblstring, const char** endptr) →  long double
Similar to string_to_long_double(const String&), but returns the first failing character position in endptr.
auto string_to_ncname(const String& input, uint32_t substitute) →  String
auto string_to_seconds(const String& string, double fallback) →  double
Parse string into seconds.
template <typename Type>
auto string_to_type(const String& string) →  Type
Convert a string to template argument type, such as bool, int, double.
auto string_to_uint(const String& string, size_t* consumed, uint base) →  uint64
Parse a string into a 64bit unsigned integer, optionally specifying the expected number base.
auto string_tolower(const String& str) →  String
Convert all string characters into Unicode lower case characters.
auto string_totitle(const String& str) →  String
Convert all string characters into Unicode title characters.
auto string_toupper(const String& str) →  String
Convert all string characters into Unicode upper case characters.
auto string_url_decode(const String& urlstr, const bool form_url_encoded) →  String
Decode URL %-sequences in a string, decode '+' if form_url_encoded.
auto string_url_encode(const String& rawstr, const bool form_url_encoded) →  String
Encode special characters to URL %-sequences, encode space as '+' if form_url_encoded.
void string_vector_erase_empty(StringS& svector)
Remove empty elements from a string vector.
auto string_vector_find(const StringS& svector, const String& prefix, const String& fallback) →  String
auto string_vector_find_value(const StringS& svector, const String& prefix, const String& fallback) →  String
void string_vector_lstrip(StringS& svector)
Left-strip all elements of a string vector, see string_lstrip().
void string_vector_rstrip(StringS& svector)
Right-strip all elements of a string vector, see string_rstrip().
void string_vector_strip(StringS& svector)
Strip all elements of a string vector, see string_strip().
auto string_vprintf(const char* format, va_list vargs) →  String
Formatted printing ala vprintf() into a String, using the POSIX/C locale.
auto text_convert(const String& to_charset, String& output_string, const String& from_charset, const String& input_string, const String& fallback_charset, const String& output_mark) →  bool
auto timestamp_benchmark() →  uint64
Returns benchmark timestamp in nano-seconds, clock starts around program startup.
auto timestamp_format(uint64 stamp, uint maxlength) →  String
Convert stamp into a string, adding µsecond fractions if space permits.
auto timestamp_realtime() →  uint64
Return the current time as uint64 in µseconds.
auto timestamp_resolution() →  uint64
Provide resolution of timestamp_benchmark() in nano-seconds.
auto timestamp_startup() →  uint64
Provides the timestamp_realtime() value from program startup.
auto uint16_swap_le_be(uint16_t v) →  uint16_t constexpr
Swap 16-Bit integers between __BIG_ENDIAN and __LITTLE_ENDIAN systems.
auto uint32_swap_le_be(uint32_t v) →  uint32_t constexpr
Swap 32-Bit integers between __BIG_ENDIAN and __LITTLE_ENDIAN systems.
auto uint64_swap_le_be(uint64_t v) →  uint64_t constexpr
Swap 64-Bit integers between __BIG_ENDIAN and __LITTLE_ENDIAN systems.
auto unicode_is_assigned(uint32_t u) →  bool constexpr
Return whether u matches any of the assigned Unicode planes.
auto unicode_is_character(uint32_t u) →  bool constexpr
Return whether u is not one of the 66 Unicode noncharacters.
auto unicode_is_control_code(uint32_t u) →  bool constexpr
Return whether u is one of the 65 Unicode control codes.
auto unicode_is_noncharacter(uint32_t u) →  bool constexpr
Return whether u is one of the 66 Unicode noncharacters.
auto unicode_is_private(uint32_t u) →  bool constexpr
Return whether u is in one of the 3 private use areas of Unicode.
auto unicode_is_valid(uint32_t u) →  bool constexpr
Return whether u is an allowed Unicode codepoint within 0x10FFFF and not part of a UTF-16 surrogate pair.
auto utf8_to_unicode(const char* str, uint32_t* codepoints) →  size_t
auto utf8_to_unicode(const std::string& str, std::vector<uint32_t>& codepoints) →  size_t
auto utf8decode(const std::string& utf8str) →  std::vector<uint32_t>
Convert valid UTF-8 sequences to Unicode codepoints, invalid sequences are treated as Latin-1 characters.
auto utf8encode(const uint32_t* codepoints, size_t n_codepoints) →  std::string
Convert codepoints into an UTF-8 string, using the shortest possible encoding.
auto utf8encode(const std::vector<uint32_t>& codepoints) →  std::string
Convert codepoints into an UTF-8 string, using the shortest possible encoding.
auto utf8len(const char* str) →  size_t
Count valid UTF-8 sequences, invalid sequences are counted as Latin-1 characters.
auto utf8len(const std::string& str) →  size_t
Count valid UTF-8 sequences, invalid sequences are counted as Latin-1 characters.
auto value2hz(float x) ASE_CONST -> float
Convert synthesizer value (Voltage) to Hertz.
template <typename Float>
auto voltage2db(Float x) →  Float
Convert synthesizer value (Voltage) to Decibel.
template <typename Float>
auto voltage2db(Float x) →  ASE_CONST Float
Convert synthesizer value (Voltage) to Decibel.
template <typename Float>
auto voltage2hz(Float x) →  Float
Convert synthesizer value (Voltage) to Hertz.
template <typename Float>
auto voltage2hz(Float x) →  ASE_CONST Float
Convert synthesizer value (Voltage) to Hertz.
template <typename Float>
auto voltage_changed(Float a, Float b) →  Float
Determine a significant synthesizer value (Voltage) change.
template <typename Float>
auto voltage_changed(Float a, Float b) →  ASE_CONST Float
Determine a significant synthesizer value (Voltage) change.
template <class ... Args>
void warning(const char* format, const Args&... args)
Issue a printf-like warning message.
template <class C>
auto weak_ptr_fetch_or_create(std::weak_ptr<C>& wptr, const std::function<std::shared_ptr<C>()>& ctor) →  std::shared_ptr<C>
Fetch shared_ptr from wptr and create C with ctor if needed.
auto zintern_decompress(unsigned int decompressed_size, const unsigned char* cdata, unsigned int cdata_size) →  uint8*
void zintern_free(uint8* dc_data)
Free data returned from zintern_decompress().

Variables

constuint AUDIO_BLOCK_FLOAT_ZEROS_SIZE constexpr
Maximum number of values in the const_float_zeros block.
const double DOUBLE_EPSILON constexpr
Double round-off error at 1.0, equals 2^-53.
const char GUIONLY constexpr
GUI READABLE WRITABLE.
constuint MIDI_NOTE_ID_FIRST constexpr
First (internal) MIDI note event ID (lower IDs are reserved for external notes).
constuint MIDI_NOTE_ID_LAST constexpr
Last valid (internal) MIDI note event ID.
const char STANDARD constexpr
STORAGE GUI READABLE WRITABLE.
const char STORAGE constexpr
STORAGE READABLE WRITABLE.
constint64 TRANSPORT_PPQN constexpr
Maximum number of sample frames to calculate in Processor::render().
bool ase_debugging_enabled
Global boolean to reduce debugging penalty where possible.
bool ase_fatal_warnings
Global boolean to cause the program to abort on warnings.
bool assertion_failed_fatal
Global flag to force aborting on assertion warnings.
uint64_t cached_hash_secret
Use hash_secret() for access.
const float*const cent_table
Finetune factor table with 201 entries for -100…0…+100 cent.
float const_float_zeros
Block of const floats allof value 0.
JobQueue main_jobs
Execute a job callback in the Ase main loop.
RtJobQueue main_rt_jobs
Queue a callback for the main_loop without invoking malloc(), addition is obstruction free.
const float*const semitone_tables_265
Musical Tuning Tables, to be indexed by MusicalTuning

Enum documentation

enum class Ase::MidiEventType: uint8_t

Type of MIDI Events.

Enumerators
PARAM_VALUE
NOTE_OFF

Ase internal Parameter update.

NOTE_ON
AFTERTOUCH

Key Pressure, polyphonic aftertouch.

CONTROL_CHANGE

Control Change.

PROGRAM_CHANGE
CHANNEL_PRESSURE

Channel Aftertouch.

PITCH_BEND
SYSEX

enum class Ase::SpeakerArrangement: uint64_t

Flags to indicate channel arrangements of a bus. See also: https://en.wikipedia.org/wiki/Surround_sound

Enumerators
NONE
FRONT_LEFT

Stereo Left (FL)

FRONT_RIGHT

Stereo Right (FR)

FRONT_CENTER

(FC)

LOW_FREQUENCY

Low Frequency Effects (LFE)

BACK_LEFT

(BL)

BACK_RIGHT

(BR)

AUX

Flag for side chain uses.

MONO

Single Channel (M)

STEREO
STEREO_21
STEREO_30
STEREO_31
SURROUND_50
SURROUND_51

Function documentation

static bool Ase::codepoint_is_namestartchar(uint32_t c)

Check c to be a NameStartChar, according to the QName EBNF. See https://en.wikipedia.org/wiki/QName

static bool Ase::codepoint_is_ncname(uint32_t c)

Check c to be a NameChar, according to the QName EBNF. See https://en.wikipedia.org/wiki/QName

template <class Num>
static uint64_t Ase::fnv1a_consthash64(const Num* ztdata) constexpr

Simple, very fast and well known hash function as constexpr with good dispersion. This is the 64bit version of the well known FNV-1a hash function, implemented as a C++11 constexpr for zero-terminated strings, so the hashes can be used e.g. as case labels in switch statements.

template <std::size_t LAST, typename MkFun>
static auto Ase::make_case_table(const MkFun& mkjump)

Create a jump table std::array<Fun,LAST>, where Fun is returned from mkjump (0 … LAST). Note, mkjump(auto) is a lambda template, invoked with std::integral_constant<unsigned long, 0…LAST>.

template <class Num>
static ASE_CONST uint32_t Ase::pcg_hash32(const Num* data, size_t length, uint64_t seed)

Hash function based on the PCG family of random number generators (RNG). This function is based on the paper [PCG: A Family of Simple Fast Space-Efficient Statistically Good Algorithms for Random Number Generation](http://www.pcg-random.org/paper.html), because of its excellent avalange and distribution properties. The hash data is integrated as octets in the inner LCG RNG loop. Hash generation is very fast, because the inner loop consists only of a multiplication and subtraction, while the ouput bit mixing consists of just 5 simple operations (xor, shift and rotation).

template <class Num>
static ASE_CONST uint64_t Ase::pcg_hash64(const Num* data, size_t length, uint64_t seed)

Hash function based on the PCG family of random number generators (RNG). This function is similar to pcg_hash32() at its core, but because the output is 64bit, the accumulated 64bit LCG state does not need to be bit reduced. A fast but statistially good mixing function with 5 xor/shifts and one multiplication is applied as output stage. This function is allmost as fast as fnv1a_consthash64 due to the similar structures of the inner loops, but it tends to score much better in Avalanche effect tests, usch as SMHasher.

template <int CODEPOINT>
static size_t Ase::utf8character(const char* str, uint32_t* unicode)

Decode valid UTF-8 sequences, invalid sequences are treated as Latin-1 characters.

  • CODEPOINT=0: The return value indicates the number of bytes forgivingly parsed as a single UTF-8 character.
  • CODEPOINT=1: The return value indicates the number of bytes forgivingly parsed as a single UTF-8 character and *unicode is assigned. If *unicode is >= 0x80, a Latin-1 character was encountered.
  • CODEPOINT=2: Invalid characters are encoded as private code points in the range 0xEF80..0xEFFF, see also: https://en.wikipedia.org/wiki/UTF-8#PEP_383
  • CODEPOINT=3: Validly encoded code points in the range 0xEF80..0xEFFF are also treated as invalid characters and are encoded into 0xEF80..0xEFFF.

void Ase::assertion_failed(const char* msg, const char* file, int line, const char* func) noexcept

Print instructive message, handle "breakpoint", "backtrace" and "fatal-warnings" in $ASE_DEBUG.

Issue a warning about an assertion error.

std::string Ase::backtrace_command()

Find GDB and construct command line.

Command to start external debugger for a backtrace.

void Ase::collect_runtime_entropy(uint64* data, size_t n)

Collect entropy from the current process, usually quicker than collect_system_entropy().

To provide good quality random number seeds, this function gathers entropy from a variety of process specific sources. Under Linux, this includes the CPU counters, clocks and random devices. In combination with well established techniques like syscall timings (see Entropics13 Entropics13) and a SHA3 algorithm derived random number generator for the mixing, the entropy collection is designed to be fast and good enough for all non-cryptographic uses. On an Intel Core i7, this function takes around 25µs.

void Ase::collect_system_entropy(uint64* data, size_t n)

Collect entropy from system devices, like interrupt counters, clocks and random devices.

This function adds to collect_runtime_entropy() by collecting entropy from aditional but potentially slower system sources, such as interrupt counters, disk + network statistics, system load, execution + pipelining + scheduling latencies and device MACs. The function is designed to yield random number seeds good enough to generate cryptographic tokens like session keys. On an Intel Core i7, this function takes around 2ms, so it's roughly 80 times slower than collect_runtime_entropy().

String Ase::cpu_info()

Retrieve string identifying the runtime CPU type.

Returns Example: "4 AMD64 GenuineIntel FPU TSC HTT CMPXCHG16B MMX MMXEXT SSESYS SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 "

The returned string contains: number of online CPUs, a string describing the CPU architecture, the vendor and finally a number of flag words describing CPU features plus a trailing space. This allows checks for CPU features via a simple string search for " FEATURE ".

float Ase::damerau_levenshtein_distance(const std::string& source, const std::string& target, const float ci, const float cd, const float cs, const float ct)

Damerau-Levenshtein Distance with unrestricted transpositions. Calculate the unrestricted Damerau-Levenshtein string distance with quadratic time complexity and quadratic memory requirement. Memory: 4 * |source|*|target| + constant.

float Ase::damerau_levenshtein_restricted(const std::string& source, const std::string& target, const float ci, const float cd, const float cs, const float ct)

Damerau-Levenshtein Distance with restricted transposition. Calculate the restricted Damerau-Levenshtein string distance with quadratic time complexity and linear memory requirement. Memory: 12 * max(|source|,|target|) + constant.

float Ase::fast_exp2(float x) ASE_CONST

Fast approximation of 2 raised to the power of x. The parameter x is the exponent within [-127.0…+127.0]. Within -1…+1, the error stays below 4e-7 which corresponds to a sample precision of 21 bit. For integer values of x (i.e. x - floor (x) →  0), the error approaches zero. With FMA instructions and -ffast-math enabled, execution times should be below 10ns on 3GHz machines.

float Ase::fast_log2(float x) ASE_CONST

Fast approximation of logarithm to base 2. The parameter x is the exponent within [1.1e-38…2^127]. Within 1e-7…+1, the error stays below 3.8e-6 which corresponds to a sample precision of 18 bit. When x is an exact power of 2, the error approaches zero. With FMA instructions and -ffast-math enabled, execution times should be below 10ns on 3GHz machines.

template <class ... Args>
void ASE_NORETURN Ase::fatal_error(const char* format, const Args&... args)

Issue a printf-like message and abort the program, this function will not return. Avoid using this in library code, aborting may take precious user data with it, library code should instead use warning(), info() or assert_return().

ASE_CONST int Ase::irintf(float f)

Round float to int, using round-to-nearest Fast version of f < 0 ? int (f - 0.5) : int (f + 0.5).

template <class... A>
void Ase::loginf(const char* format, const A&... args) ASE_PRINTF(1

Write a string_format() message to the log file (or possibly stderr), using the POSIX/C locale.

Log info to logfile (and stderr for some configs)

String Ase::parameter_guess_nick(const String& parameter_label)

Create a few letter nick name from a multi word parameter label.

Find a suitable 3-letter abbreviation for a Parameter without nick.

double Ase::random_float()

Generate uniformly distributed pseudo-random floating point number. This function generates a pseudo-random number like random_int64(), constrained to the range: 0.0 <= number < 1.0.

double Ase::random_frange(double begin, double end)

Generate uniformly distributed pseudo-random floating point number within a range. This function generates a pseudo-random number like random_float(), constrained to the range: begin <= number < end.

uint64_t Ase::random_int64()

Generate a non-deterministic, uniformly distributed 64 bit pseudo-random number. This function generates pseudo-random numbers using the system state as entropy and class KeccakRng for the mixing. No seeding is required.

int64_t Ase::random_irange(int64_t begin, int64_t end)

Generate uniformly distributed pseudo-random integer within range. This function generates a pseudo-random number like random_int64(), constrained to the range: begin <= number < end.

template <class Target, class Source>
std::shared_ptr<typename std::remove_pointer<Target>::type> Ase::shared_ptr_cast(Source* object)

Returns A std::shared_ptr<Target> storing a pointer to object or NULL.
Exceptions
std::bad_weak_ptr if shared_from_this() throws, unless the Target* form is used.

Shorthand for std::dynamic_pointer_cast<>(shared_from_this()). A shared_ptr_cast() takes a std::shared_ptr or a pointer to an object that supports std::enable_shared_from_this::shared_from_this(). Using std::dynamic_pointer_cast(), the shared_ptr passed in (or retrieved via calling shared_from_this()) is cast into a std::shared_ptr<Target>, possibly resulting in an empty (NULL) std::shared_ptr if the underlying dynamic_cast() was not successful or if a NULL object was passed in. Note that shared_from_this() can throw a std::bad_weak_ptr exception if the object has no associated std::shared_ptr (usually during ctor and dtor), in which case the exception will also be thrown from shared_ptr_cast<Target>(). However a shared_ptr_cast<Target*>() call will not throw and yield an empty (NULL) std::shared_ptr<Target>. This is analogous to dynamic_cast<T@amp> which throws, versus dynamic_cast<T*> which yields NULL.

String Ase::string_canonify(const String& string, const String& valid_chars, const String& substitute)

Enforce a canonical charset for a string. Convert all chars in string that are not listed as valid_chars with substitute.

const char* Ase::string_demangle_cxx(const char* mangled_identifier) noexcept

Demangle identifier via libcc.

Demangle a std::typeinfo.name() string into a proper C++ type name. This function uses abi::__cxa_demangle() from <cxxabi.h> to demangle C++ type names, which works for g++, libstdc++, clang++, libc++.

String Ase::string_from_pretty_function_name(const char* cxx_pretty_function)

Extract the full function name from PRETTY_FUNCTION. See also ASE_SIMPLE_FUNCTION.

String Ase::string_hexdump(const void* addr, size_t length, size_t initial_offset)

Produce hexdump of a memory region. Each output line consists of its hexadecimal offset, 16 hexadecimal bytes and the ASCII representation of the same 16 bytes.

bool Ase::string_is_ncname(const String& input)

Check input to be a NCName, according to the QName EBNF. See https://en.wikipedia.org/wiki/QName

String Ase::string_join(const String& junctor, const StringS& strvec)

Join a number of strings. Join a string vector into a single string, using junctor inbetween each pair of strings.

StringS Ase::string_split(const String& string, const String& splitter, size_t maxn)

Split a string, using splitter as delimiter. Passing "" as splitter will split the string at whitespace positions.

StringS Ase::string_split_any(const String& string, const String& splitchars, size_t maxn)

Split a string, using any of the splitchars as delimiter. Passing "" as splitter will split the string between all position.

bool Ase::string_to_bool(const String& string, bool fallback)

Interpret a string as boolean value. Interpret the string as number, "ON"/"OFF" or distinguish "false"/"true" or "yes"/"no" by starting letter. For empty strings, fallback is returned.

String Ase::string_to_cescape(const String& str)

Escape text like a C string. Returns a string that escapes all characters with a backslash '\' that need escaping in C language string syntax.

String Ase::string_to_ncname(const String& input, uint32_t substitute)

Convert input to a NCName, according to the QName EBNF. See https://en.wikipedia.org/wiki/QName

String Ase::string_vector_find(const StringS& svector, const String& prefix, const String& fallback)

Returns fallback if no match was found.

Search for prefix in svector and return the matching element. If multiple matches are possible, the last one is returned.

String Ase::string_vector_find_value(const StringS& svector, const String& prefix, const String& fallback)

Returns fallback if no match was found.

Search for prefix in svector and return reminder of the matching string. If multiple matches are possible, the last one is returned.

bool Ase::text_convert(const String& to_charset, String& output_string, const String& from_charset, const String& input_string, const String& fallback_charset, const String& output_mark)

Convert a string from one encoding to another. Convert input_string from encoding from_charset to to_charset, returning output_string. Interpret unknown characters according to fallback_charset. Use output_mark in place of unconvertible characters. Returns whether the conversion was successful.

size_t Ase::utf8_to_unicode(const char* str, uint32_t* codepoints)

Convert valid UTF-8 sequences to Unicode codepoints, invalid sequences are treated as Latin-1 characters. The array codepoints must be able to hold at least as many elements as are characters stored in str. Returns the number of codepoints stored in codepoints.

size_t Ase::utf8_to_unicode(const std::string& str, std::vector<uint32_t>& codepoints)

Convert valid UTF-8 sequences to Unicode codepoints, invalid sequences are treated as Latin-1 characters. Returns the number of codepoints newly stored in codepoints.

uint8* Ase::zintern_decompress(unsigned int decompressed_size, const unsigned char* cdata, unsigned int cdata_size)

Parameters
decompressed_size exact size of the decompressed data to be returned
cdata compressed data block
cdata_size exact size of the compressed data block
Returns decompressed data block or NULL in low memory situations

Decompress data via zlib. Decompress the data from cdata of length cdata_size into a newly allocated block of size decompressed_size which is returned. The returned block needs to be released with zintern_free(). This function is intended to decompress data which has been compressed with the packres.py utility, so no errors should occour during decompression. Consequently, if any error occours during decompression or if the resulting data block is of a size other than decompressed_size, the program will abort with an appropriate error message. If not enough memory could be allocated for decompression, NULL is returned.