Add some more small clarification comments
This commit is contained in:
parent
92be9fad8b
commit
f6bc17f71b
@ -29,6 +29,7 @@ namespace audio{
|
|||||||
class channel;
|
class channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Playback for one simultaneos audio source
|
||||||
//needs to be thread safe, lock free, and avoid false sharing
|
//needs to be thread safe, lock free, and avoid false sharing
|
||||||
class channel
|
class channel
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//Combine errors from multiple libraries into one to make for easier end usage
|
||||||
class error
|
class error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -48,8 +49,8 @@ namespace audio{
|
|||||||
BAD_BUFFER,
|
BAD_BUFFER,
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
int m_actual;
|
int m_actual; //actual error generated by a library
|
||||||
int m_homog;
|
int m_homog; //homogenized error (from the above enum)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
error(int actual);
|
error(int actual);
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//supported audio frame data formats
|
||||||
enum class frame_fmt{
|
enum class frame_fmt{
|
||||||
float32 = paFloat32,
|
float32 = paFloat32,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//initializer/deinitializer for portaudio
|
||||||
class pa_system
|
class pa_system
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//raw chunk of mixdata used by mixer
|
||||||
struct mixdata {
|
struct mixdata {
|
||||||
float* data = nullptr;
|
float* data = nullptr;
|
||||||
size_t frames = 0;
|
size_t frames = 0;
|
||||||
@ -32,6 +33,7 @@ namespace audio{
|
|||||||
bool allocated = true;
|
bool allocated = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//managed chunk of mixdata used by the end user
|
||||||
class mixchunk
|
class mixchunk
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -28,6 +28,7 @@ namespace audio{
|
|||||||
class mixer;
|
class mixer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Handle playback of multiple simultaneous audio streams
|
||||||
class mixer
|
class mixer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//Sound file reader. Reads directly into mixchunks which can be passed directly to a mixer channel
|
||||||
class sndrd
|
class sndrd
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
namespace audio{
|
namespace audio{
|
||||||
|
|
||||||
|
//Represents an audio device under the control of portaudio
|
||||||
class stream
|
class stream
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <cstdlib> //size_t
|
#include <cstdlib> //size_t
|
||||||
|
|
||||||
|
//Provide aliases for common matrix, vector, and quaternion types
|
||||||
|
|
||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
template<typename T, size_t R, size_t C>
|
template<typename T, size_t R, size_t C>
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
|
//Common stuff shared by all types of matrices
|
||||||
template<typename T, size_t R, size_t C>
|
template<typename T, size_t R, size_t C>
|
||||||
class matrix_base
|
class matrix_base
|
||||||
{
|
{
|
||||||
@ -92,6 +93,7 @@ namespace math{
|
|||||||
constexpr operator const_pointer()const;
|
constexpr operator const_pointer()const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Non square matrices
|
||||||
template<typename T, size_t R, size_t C>
|
template<typename T, size_t R, size_t C>
|
||||||
class matrix : public matrix_base<T,R,C>
|
class matrix : public matrix_base<T,R,C>
|
||||||
{
|
{
|
||||||
@ -119,6 +121,7 @@ namespace math{
|
|||||||
constexpr matrix& operator=(const matrix<U,R,C>& m);
|
constexpr matrix& operator=(const matrix<U,R,C>& m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Square matrices
|
||||||
template<typename T, size_t R>
|
template<typename T, size_t R>
|
||||||
class matrix<T,R,R> : public matrix_base<T,R,R>
|
class matrix<T,R,R> : public matrix_base<T,R,R>
|
||||||
{
|
{
|
||||||
@ -200,6 +203,7 @@ namespace math{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Determine if a given list of tyes are all matrix types
|
||||||
template<typename... Ms>
|
template<typename... Ms>
|
||||||
struct is_matrix {
|
struct is_matrix {
|
||||||
static constexpr bool value = (detail::is_matrix_helper<Ms>::value && ...);
|
static constexpr bool value = (detail::is_matrix_helper<Ms>::value && ...);
|
||||||
@ -221,11 +225,13 @@ namespace math{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Logic operators
|
||||||
template<typename T, typename U, size_t R, size_t C>
|
template<typename T, typename U, size_t R, size_t C>
|
||||||
constexpr bool operator==(const matrix_base<T,R,C>& left, const matrix_base<U,R,C> right);
|
constexpr bool operator==(const matrix_base<T,R,C>& left, const matrix_base<U,R,C> right);
|
||||||
template<typename T, typename U, size_t R, size_t C>
|
template<typename T, typename U, size_t R, size_t C>
|
||||||
constexpr bool operator!=(const matrix_base<T,R,C>& left, const matrix_base<U,R,C> right);
|
constexpr bool operator!=(const matrix_base<T,R,C>& left, const matrix_base<U,R,C> right);
|
||||||
|
|
||||||
|
//Arithmetic operators
|
||||||
template<typename T, typename U, size_t R1, size_t C1, size_t R2>
|
template<typename T, typename U, size_t R1, size_t C1, size_t R2>
|
||||||
constexpr auto operator*(const matrix<T,R1,C1>& left, const matrix<U,C1,R2>& right);
|
constexpr auto operator*(const matrix<T,R1,C1>& left, const matrix<U,C1,R2>& right);
|
||||||
template<typename T, typename U, size_t C, size_t R, std::enable_if_t<std::is_arithmetic_v<std::decay_t<U>>,int> = 0>
|
template<typename T, typename U, size_t C, size_t R, std::enable_if_t<std::is_arithmetic_v<std::decay_t<U>>,int> = 0>
|
||||||
@ -241,6 +247,7 @@ namespace math{
|
|||||||
template<typename T, typename U, size_t C, size_t R>
|
template<typename T, typename U, size_t C, size_t R>
|
||||||
constexpr auto operator-(const matrix<T,R,C>& left);
|
constexpr auto operator-(const matrix<T,R,C>& left);
|
||||||
|
|
||||||
|
//Arithmetic assignment operators
|
||||||
template<typename T, typename U, size_t R>
|
template<typename T, typename U, size_t R>
|
||||||
constexpr decltype(auto) operator*=(matrix<T,R,R>& left, const matrix<U,R,R>& right);
|
constexpr decltype(auto) operator*=(matrix<T,R,R>& left, const matrix<U,R,R>& right);
|
||||||
template<typename T, typename U, size_t C, size_t R, std::enable_if_t<std::is_arithmetic_v<std::decay_t<U>>,int> = 0>
|
template<typename T, typename U, size_t C, size_t R, std::enable_if_t<std::is_arithmetic_v<std::decay_t<U>>,int> = 0>
|
||||||
|
|||||||
@ -19,6 +19,8 @@
|
|||||||
#ifndef REXY_MATH_HPP
|
#ifndef REXY_MATH_HPP
|
||||||
#define REXY_MATH_HPP
|
#define REXY_MATH_HPP
|
||||||
|
|
||||||
|
//include this file to access all the math components easily
|
||||||
|
|
||||||
#include "fwd_declare.hpp"
|
#include "fwd_declare.hpp"
|
||||||
#include "math_common.hpp"
|
#include "math_common.hpp"
|
||||||
#include "vec.hpp"
|
#include "vec.hpp"
|
||||||
|
|||||||
@ -22,12 +22,14 @@
|
|||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
namespace detail{
|
namespace detail{
|
||||||
|
//sentinel classes saying how to initialize some math classes
|
||||||
struct zero_initialize_t {};
|
struct zero_initialize_t {};
|
||||||
struct no_initialize_t {};
|
struct no_initialize_t {};
|
||||||
struct id_initialize_t {};
|
struct id_initialize_t {};
|
||||||
struct manual_initialize_t {};
|
struct manual_initialize_t {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//instantiation of sentinels
|
||||||
static inline constexpr detail::zero_initialize_t zero_initialize;
|
static inline constexpr detail::zero_initialize_t zero_initialize;
|
||||||
static inline constexpr detail::no_initialize_t no_initialize;
|
static inline constexpr detail::no_initialize_t no_initialize;
|
||||||
static inline constexpr detail::id_initialize_t id_initialize;
|
static inline constexpr detail::id_initialize_t id_initialize;
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
|
//( ͡° ͜ʖ ͡°)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class quaternion
|
class quaternion
|
||||||
{
|
{
|
||||||
|
|||||||
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
namespace math{
|
namespace math{
|
||||||
|
|
||||||
|
//class representing vectors
|
||||||
|
//inherit from matrix base because it also shared matrix attributes
|
||||||
template<typename T, size_t R>
|
template<typename T, size_t R>
|
||||||
class vector : public matrix_base<T,R,1>
|
class vector : public matrix_base<T,R,1>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
namespace util{
|
namespace util{
|
||||||
|
|
||||||
|
//multiproducer, multiconsumer thread safe ring buffer with some attempts to optimize against thread thrashing
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class mpmc_ring_buffer
|
class mpmc_ring_buffer
|
||||||
{
|
{
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include <utility> //integer_sequence
|
#include <utility> //integer_sequence
|
||||||
|
|
||||||
namespace util{
|
namespace util{
|
||||||
|
//generate an integer sequence counting up from 0. eg 0,1,2,3...
|
||||||
template<int I, int... Is>
|
template<int I, int... Is>
|
||||||
struct sequence_gen{
|
struct sequence_gen{
|
||||||
using type = typename sequence_gen<I-1, Is..., sizeof...(Is)>::type;
|
using type = typename sequence_gen<I-1, Is..., sizeof...(Is)>::type;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user