2022-03-25 05:00:26 -04:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: WaveMix.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2022-11-27 04:36:01 -05:00
|
|
|
// VERSION: 0.1.3
|
2022-03-26 06:33:27 -04:00
|
|
|
// PURPOSE: Arduino library to mix two signals (A and B) with an adaptive weight.
|
|
|
|
// URL: https://github.com/RobTillaart/WaveMix
|
2022-03-25 05:00:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
2022-11-27 04:36:01 -05:00
|
|
|
#define WAVEMIX_LIB_VERSION (F("0.1.3"))
|
2022-03-25 05:00:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
class WaveMix
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WaveMix();
|
|
|
|
|
2022-03-26 06:33:27 -04:00
|
|
|
// weight1 + weight2 != 0
|
2022-11-27 04:36:01 -05:00
|
|
|
bool setWeight(float weight1, float weight2);
|
2022-03-26 06:33:27 -04:00
|
|
|
float getW1() { return _weight[0]; };
|
|
|
|
float getW2() { return _weight[1]; };
|
|
|
|
// preferably 0 <= percentage <= 100
|
2022-11-27 04:36:01 -05:00
|
|
|
bool setPercentage(float percentage);
|
2022-03-25 05:00:26 -04:00
|
|
|
|
2022-11-27 04:36:01 -05:00
|
|
|
void setGain(float gain);
|
|
|
|
float getGain();
|
2022-03-26 06:33:27 -04:00
|
|
|
|
2022-11-27 04:36:01 -05:00
|
|
|
void setOffset(float offset);
|
|
|
|
float getOffset();
|
2022-03-27 04:26:59 -04:00
|
|
|
|
2022-03-26 06:33:27 -04:00
|
|
|
float mix(float s1, float s2 = 0);
|
2022-03-25 05:00:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2022-03-26 06:33:27 -04:00
|
|
|
float _weight[2] = { 0.5, 0.5 };
|
|
|
|
float _gain = 1.0;
|
2022-03-27 04:26:59 -04:00
|
|
|
float _offset = 0.0;
|
2022-03-26 06:33:27 -04:00
|
|
|
|
2022-03-25 05:00:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|