Browse Source

remove redundancies with libdizzy

master
heck 8 months ago
parent
commit
53e5b8388d
  1. 6
      src/osp_types.hh
  2. 36
      src/osp_utils.hh

6
src/osp_types.hh

@ -1,6 +0,0 @@
#ifndef HECK_OSP_TYPES_HH
#define HECK_OSP_TYPES_HH
#include "dizzy_types.hh"
#endif

36
src/osp_utils.hh

@ -2,38 +2,8 @@
#define HECK_OSP_UTILS_HH
#include "daisy_seed.h"
#include "osp_types.hh"
#include "utils.hh"
namespace Heck::OSP {
template<typename T> class Observer {
public:
bool on_change(T val_new, std::function<void(T val_current)> fn)
{
if (val_new != val_current_) {
val_current_ = val_new;
fn(val_current_);
return true;
}
return false;
}
bool on_change_fuzzy(T val_new, T min_deviation, std::function<void(T val_current)> fn)
{
if (std::abs(val_new - val_current_) >= min_deviation) {
val_current_ = val_new;
fn(val_current_);
return true;
}
return false;
}
private:
T val_current_{};
};
} // namespace Heck::OSP
namespace Heck::OSP {
namespace Sig {
struct Delta {
@ -50,7 +20,8 @@ namespace Heck::OSP {
float history[1];
};
template<u32 SIZE> struct RingBuffer {
template<u32 SIZE>
struct RingBuffer {
void init(float* buffer)
{
buf_ = buffer;
@ -83,7 +54,8 @@ namespace Heck::OSP {
u32 size = SIZE;
};
template<int SIZE> struct Delay101 {
template<int SIZE>
struct Delay101 {
void init(Sig::RingBuffer<SIZE>* buff)
{
buff_ = buff;

Loading…
Cancel
Save