Skip to content

title: daisy::AnalogControl summary: Hardware Interface for control inputs Primarily designed for ADC input controls such as potentiometers, and control voltage. .


daisy::AnalogControl

Module: LIBDAISY / HUMAN_INTERFACE / CONTROLS

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

#include <ctrl.h>

Public Functions

Name
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)
uint16_t GetRawValue()
float GetRawFloat()
void SetSampleRate(float sample_rate)

Detailed Description

class daisy::AnalogControl;

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

Author: Stephen Hensley

Date: November 2019

Public Functions Documentation

function AnalogControl

inline AnalogControl()

Constructor


function ~AnalogControl

inline ~AnalogControl()

destructor


function Init

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

Parameters:

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

Initializes the control


function InitBipolarCv

void InitBipolarCv(
    uint16_t * adcptr,
    float sr
)

Parameters:

  • ***adcptr** Pointer to analog digital converter
  • sr Audio engine sample rate

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


function Process

float 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


function Value

inline float Value() const

Returns the current stored value, without reprocessing


function SetCoeff

inline void SetCoeff(
    float val
)

Parameters:

  • val Value to set coefficient to. Max of 1, min of 0.

Directly set the Coefficient of the one pole smoothing filter.


function GetRawValue

inline uint16_t GetRawValue()

Returns the raw unsigned 16-bit value from the ADC


function GetRawFloat

inline float GetRawFloat()

Returns a normalized float value representing the current ADC value.


function SetSampleRate

void SetSampleRate(
    float sample_rate
)

Parameters:

  • sample_rate New update rate for the switch in hz

Set a new sample rate after the ctrl has been initialized

---

Updated on 2024-01-03 at 19:41:01 +0000