-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,8 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
/build | ||
/CMakeFiles | ||
CMakeCache.txt | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(AUDIO_PLUGINS VERSION 0.0.1) | ||
|
||
add_subdirectory(deps/juce) | ||
set_directory_properties(PROPERTIES JUCE_COMPANY_NAME "sainsay") | ||
set_directory_properties(PROPERTIES JUCE_COMPANY_WEBSITE "https://github.com/sainsay/AudioPlugins" ) | ||
|
||
add_subdirectory(common) | ||
|
||
target_compile_features(Common PRIVATE cxx_std_20) | ||
|
||
add_subdirectory(infinight) | ||
target_compile_features(Infinight PRIVATE cxx_std_20) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
set(PROJECT_NAME "Common") | ||
|
||
project(${PROJECT_NAME}) | ||
|
||
file( GLOB_RECURSE common_source_list "${CMAKE_CURRENT_LIST_DIR}/src/*cpp" "${CMAKE_CURRENT_LIST_DIR}/src/*.c") | ||
file( GLOB_RECURSE common_private_list "${CMAKE_CURRENT_LIST_DIR}/src/*h" "${CMAKE_CURRENT_LIST_DIR}/src/*hpp") | ||
file( GLOB_RECURSE common_public_list "${CMAKE_CURRENT_LIST_DIR}/include/*h" "${CMAKE_CURRENT_LIST_DIR}/include/*hpp") | ||
|
||
add_library(${PROJECT_NAME} STATIC | ||
${common_public_list} | ||
${common_private_list} | ||
${common_source_list} | ||
) | ||
|
||
include_directories(${CMAKE_CURRENT_LIST_DIR}/include/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#pragma once | ||
|
||
namespace sain{ | ||
|
||
|
||
|
||
template<typename T, size_t size> | ||
struct Sample | ||
{ | ||
T Data[size]; | ||
|
||
T& operator[](const size_t idx) | ||
{ | ||
return Data[idx]; | ||
} | ||
}; | ||
|
||
using StereoSample = Sample<float, 2>; | ||
template<> | ||
struct Sample<float , 2> | ||
{ | ||
float L; | ||
float R; | ||
|
||
float& operator[](const size_t idx) | ||
{ | ||
jassert(idx < 2); | ||
float* f = reinterpret_cast<float*>(this); | ||
return *(f+idx); | ||
// potentially dangerous code. | ||
|
||
} | ||
|
||
StereoSample& operator*( float rhs ) | ||
{ | ||
L *= rhs; | ||
R *= rhs; | ||
return *this; | ||
} | ||
|
||
StereoSample& operator+=( StereoSample& rhs ) | ||
{ | ||
L += rhs.L; | ||
R += rhs.R; | ||
return *this; | ||
} | ||
|
||
}; | ||
|
||
|
||
template<> | ||
struct Sample<float , 6> | ||
{ | ||
float L; | ||
float R; | ||
float C; | ||
float Sub; | ||
float SurL; | ||
float SurR; | ||
|
||
float& operator[](const size_t idx) | ||
{ | ||
jassert(idx < 6); | ||
|
||
float* f = reinterpret_cast<float*>(this); | ||
return *(f+idx); | ||
// potentially dangerous code. | ||
} | ||
}; | ||
|
||
using FiveOneSample = Sample<float, 6>; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
#define FLAG_IS_SET(var, flag) ((var) & (flag)) != static_cast<decltype(var)>(0) | ||
#define SET_FLAG(var, flag) var |= (flag) | ||
#define TOGGLE_FLAG(var, flag) var ^= (flag) | ||
#define CLEAR_FLAG(var, flag) var &= ~(flag) | ||
|
||
#define DEF_FLAG_OR_OP(type, internal_type) \ | ||
inline type operator|(const type& a, const type& b) \ | ||
{ \ | ||
return static_cast<type>(static_cast<internal_type>(a) | static_cast<internal_type>(b)); \ | ||
} | ||
|
||
#define DEF_FLAG_ASSIGN_OR_OP(type, internal_type) \ | ||
inline type& operator|=(type& a, const type& b) \ | ||
{ \ | ||
a = static_cast<type>(static_cast<internal_type>(a) | static_cast<internal_type>(b)); \ | ||
return a; \ | ||
} | ||
|
||
#define DEF_FLAG_AND_OP(type, internal_type) \ | ||
inline type operator&(const type& a, const type& b) \ | ||
{ \ | ||
return static_cast<type>(static_cast<internal_type>(a) & static_cast<internal_type>(b)); \ | ||
} | ||
|
||
#define DEF_FLAG_ASSIGN_AND_OP(type, internal_type) \ | ||
inline type operator&=(type& a, const type& b) \ | ||
{ \ | ||
a = static_cast<type>(static_cast<internal_type>(a) & static_cast<internal_type>(b)); \ | ||
return a; \ | ||
} | ||
|
||
#define DEF_FLAG_XOR_OP(type, internal_type) \ | ||
inline type operator^(const type& a, const type& b) \ | ||
{ \ | ||
return static_cast<type>(static_cast<internal_type>(a) ^ static_cast<internal_type>(b)); \ | ||
} | ||
|
||
#define DEF_FLAG_ASSIGN_XOR_OP(type, internal_type) \ | ||
inline type operator^=(type& a, const type& b) \ | ||
{ \ | ||
a = static_cast<type>(static_cast<internal_type>(a) ^ static_cast<internal_type>(b)); \ | ||
return a; \ | ||
} | ||
|
||
#define DEF_FLAG_NOT_OP(type, internal_type) \ | ||
inline type operator~(const type& a) \ | ||
{ \ | ||
return static_cast<type>(~static_cast<internal_type>(a)); \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#include <inttypes.h> | ||
#include <array> | ||
|
||
#include <iostream> | ||
|
||
namespace sain | ||
{ | ||
template <typename _Ty, size_t count> | ||
class RingBuffer | ||
{ | ||
public: | ||
typedef _Ty value_type; | ||
typedef _Ty* pointer; | ||
typedef const _Ty* const_pointer; | ||
typedef _Ty& reference; | ||
typedef const _Ty& const_reference; | ||
|
||
std::array<value_type, count> data; | ||
|
||
private: | ||
|
||
typedef typename std::array<_Ty, count>::iterator DataIterator; | ||
typedef typename std::array<value_type, count>::reverse_iterator DataReverseIterator; | ||
|
||
class RingBufferIterator | ||
{ | ||
RingBuffer* myRingBuffer; | ||
DataIterator it; | ||
public: | ||
|
||
RingBufferIterator() : | ||
myRingBuffer(nullptr), | ||
it(nullptr) | ||
{ | ||
} | ||
|
||
RingBufferIterator(RingBuffer* rb, DataIterator start) : | ||
myRingBuffer(rb), | ||
it(start) | ||
{ | ||
} | ||
|
||
RingBufferIterator(const RingBufferIterator& rhs) | ||
{ | ||
this->it = rhs.it; | ||
this->myRingBuffer = rhs.myRingBuffer; | ||
} | ||
|
||
RingBufferIterator& operator=(const RingBufferIterator& rhs) | ||
{ | ||
this->it = rhs.it; | ||
this->myRingBuffer = rhs.myRingBuffer; | ||
return *this; | ||
} | ||
|
||
RingBufferIterator(RingBufferIterator&& rhs) | ||
{ | ||
this->it = rhs.it; | ||
this->myRingBuffer = rhs.myRingBuffer; | ||
|
||
rhs.myRingBuffer = nullptr; | ||
rhs.it = std::_Array_iterator<_Ty, count>( nullptr ); | ||
} | ||
|
||
RingBufferIterator& operator=(RingBufferIterator&& rhs) | ||
{ | ||
this->it = rhs.it; | ||
this->myRingBuffer = rhs.myRingBuffer; | ||
|
||
rhs.myRingBuffer = nullptr; | ||
rhs.it = std::_Array_iterator<_Ty, count>( nullptr ); | ||
return *this; | ||
} | ||
|
||
RingBufferIterator& operator++() | ||
{ | ||
++it; | ||
if (it == myRingBuffer->data.end()) | ||
{ | ||
it = myRingBuffer->data.begin(); | ||
} | ||
return *this; | ||
} | ||
|
||
RingBufferIterator& operator--(){ | ||
if(it == myRingBuffer->data.begin()) | ||
{ | ||
it = myRingBuffer->data.end(); | ||
--it; | ||
return *this; | ||
} | ||
--it; | ||
return *this; | ||
} | ||
|
||
size_t operator-(const RingBufferIterator& rhs) const | ||
{ | ||
return this->it - rhs.it; | ||
} | ||
|
||
reference operator*() const | ||
{ | ||
return *it; | ||
} | ||
}; | ||
|
||
public: | ||
using iterator = RingBufferIterator; | ||
|
||
RingBuffer( ) | ||
{ | ||
std::fill(data.begin(), data.end(), value_type()); | ||
} | ||
|
||
~RingBuffer( ){} | ||
|
||
iterator from(size_t idx) | ||
{ | ||
return iterator(this, data.begin() + idx); | ||
} | ||
|
||
iterator begin() | ||
{ | ||
return iterator(this, data.begin()); | ||
} | ||
|
||
iterator end() | ||
{ | ||
return iterator(this, data.end()); | ||
} | ||
|
||
void Clear(){ | ||
std::fill(data.begin(), data.end(), value_type()); | ||
} | ||
|
||
}; | ||
|
||
} // namespace sain |
Oops, something went wrong.