2022-03-25 05:00:26 -04:00
|
|
|
#pragma once
|
|
|
|
//
|
|
|
|
// FILE: WaveMix.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2022-03-26 06:33:27 -04:00
|
|
|
// VERSION: 0.1.1
|
|
|
|
// 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-03-26 06:33:27 -04:00
|
|
|
#define WAVEMIX_LIB_VERSION (F("0.1.1"))
|
2022-03-25 05:00:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
class WaveMix
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit WaveMix();
|
|
|
|
|
2022-03-26 06:33:27 -04:00
|
|
|
// weight1 + weight2 != 0
|
|
|
|
void setWeight(float weight1, float weight2);
|
|
|
|
float getW1() { return _weight[0]; };
|
|
|
|
float getW2() { return _weight[1]; };
|
|
|
|
// preferably 0 <= percentage <= 100
|
|
|
|
void setPercentage(float percentage);
|
2022-03-25 05:00:26 -04:00
|
|
|
|
2022-03-26 06:33:27 -04:00
|
|
|
void setGain(float gain) { _gain = gain; };
|
|
|
|
float getGain() { return _gain; };
|
|
|
|
|
|
|
|
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-25 05:00:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|