libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::AnalogControl Class Reference

Hardware Interface for control inputs
Primarily designed for ADC input controls such as
potentiometers, and control voltage.
. More...

Detailed Description

Hardware Interface for control inputs
Primarily designed for ADC input controls such as
potentiometers, and control voltage.
.

Author
Stephen Hensley
Date
November 2019

#include <ctrl.h>

Public Member Functions

 AnalogControl ()
 
 ~AnalogControl ()
 
void Init (uint16_t *adcptr, float sr, bool flip=false, bool invert=false, float slew_seconds=0.002f)
 
void InitBipolarCv (uint16_t *adcptr, float sr)
 
float Process ()
 
float Value () const
 
void SetCoeff (float val)
 
void SetScale (const float scale)
 
void SetOffset (const float offset)
 
uint16_t GetRawValue ()
 
float GetRawFloat ()
 
void SetSampleRate (float sample_rate)
 

Constructor & Destructor Documentation

◆ AnalogControl()

daisy::AnalogControl::AnalogControl ( )
inline

Constructor

◆ ~AnalogControl()

daisy::AnalogControl::~AnalogControl ( )
inline

destructor

Member Function Documentation

◆ GetRawFloat()

float daisy::AnalogControl::GetRawFloat ( )
inline

Returns a normalized float value representing the current ADC value.

◆ GetRawValue()

uint16_t daisy::AnalogControl::GetRawValue ( )
inline

Returns the raw unsigned 16-bit value from the ADC

◆ Init()

void daisy::AnalogControl::Init ( uint16_t adcptr,
float  sr,
bool  flip = false,
bool  invert = false,
float  slew_seconds = 0.002f 
)

Initializes the control

Parameters
*adcptris a pointer to the raw adc read value – This can be acquired with dsy_adc_get_rawptr(), or dsy_adc_get_mux_rawptr()
sris the samplerate in Hz that the Process function will be called at.
flipdetermines whether the input is flipped (i.e. 1.f - input) or not before being processed.1
invertdetermines whether the input is inverted (i.e. -1.f * input) or note before being processed.
slew_secondsis the slew time in seconds that it takes for the control to change to a new value.

◆ InitBipolarCv()

void daisy::AnalogControl::InitBipolarCv ( uint16_t adcptr,
float  sr 
)

This Initializes the AnalogControl for a -5V to 5V inverted input All of the Init details are the same otherwise

Parameters
*adcptrPointer to analog digital converter
srAudio engine sample rate

◆ Process()

float daisy::AnalogControl::Process ( )

Filters, and transforms a raw ADC read into a normalized range. this should be called at the rate of specified by samplerate at Init time. Default Initializations will return 0.0 -> 1.0 Bi-polar CV inputs will return -1.0 -> 1.0

◆ SetCoeff()

void daisy::AnalogControl::SetCoeff ( float  val)
inline

Directly set the Coefficient of the one pole smoothing filter.

Parameters
valValue to set coefficient to. Max of 1, min of 0.

◆ SetOffset()

void daisy::AnalogControl::SetOffset ( const float  offset)
inline

Directly set the offset used by the process function Normally this will be set during initialization, but the can be used when calibartion data is used to adjust the control.

◆ SetSampleRate()

void daisy::AnalogControl::SetSampleRate ( float  sample_rate)

Set a new sample rate after the ctrl has been initialized

Parameters
sample_rateNew update rate for the switch in hz

◆ SetScale()

void daisy::AnalogControl::SetScale ( const float  scale)
inline

Directly set the scaling factor used by the process function Normally this will be set during initialization, but the can be used when calibartion data is used to adjust the control.

◆ Value()

float daisy::AnalogControl::Value ( ) const
inline

Returns the current stored value, without reprocessing


The documentation for this class was generated from the following file: