Add some more small clarification comments

This commit is contained in:
rexy712 2020-08-30 10:48:06 -07:00
parent 92be9fad8b
commit f6bc17f71b
16 changed files with 29 additions and 2 deletions

View File

@ -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
{ {

View File

@ -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);

View File

@ -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,
}; };

View File

@ -21,6 +21,7 @@
namespace audio{ namespace audio{
//initializer/deinitializer for portaudio
class pa_system class pa_system
{ {
private: private:

View File

@ -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:

View File

@ -28,6 +28,7 @@ namespace audio{
class mixer; class mixer;
} }
//Handle playback of multiple simultaneous audio streams
class mixer class mixer
{ {
public: public:

View File

@ -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:

View File

@ -28,6 +28,7 @@
namespace audio{ namespace audio{
//Represents an audio device under the control of portaudio
class stream class stream
{ {
private: private:

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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;

View File

@ -28,6 +28,7 @@
namespace math{ namespace math{
//( ͡° ͜ʖ ͡°)
template<typename T> template<typename T>
class quaternion class quaternion
{ {

View File

@ -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>
{ {

View File

@ -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
{ {

View File

@ -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;