A Hopf, Skip and a Jump
Public Member Functions | Private Attributes | List of all members
RK4Detector Class Reference

Use the fourth order Runge-Kutta method to calculate the output. More...

#include <detectors.h>

Inheritance diagram for RK4Detector:
Inheritance graph
[legend]
Collaboration diagram for RK4Detector:
Collaboration graph
[legend]

Public Member Functions

 RK4Detector (const parameter_t f, const parameter_t mu, const parameter_t d, const parameter_t sr, const parameter_t detBw, const parameter_t gain)
 
virtual void reset ()
 Reset internal values to 0 This is invoked when Detect.seek() is called.
 
virtual void process (discriminator_t *target, const inputSample_t *start, const std::size_t count) override
 Method to process audio using fourth order Runge-Kutta approximation. More...
 
- Public Member Functions inherited from AbstractDetector
 AbstractDetector (parameter_t f, parameter_t mu, parameter_t d, parameter_t sr, parameter_t detBw, parameter_t gain)
 
void processAudio (discriminator_t *target, const inputSample_t *start, std::size_t count)
 Process audio using the numerical method appropriate to the derived class. More...
 
bool searchNormalize (parameter_t searchStart, parameter_t searchEnd, const parameter_t toneDuration, const parameter_t forcing_amplitude)
 Normalise the detector frequency using an iterative scheme. More...
 
bool amplitudeNormalize (const parameter_t forcing_amplitude)
 Set the detector's a and iScale attributes by profiling an ideal detector response. More...
 
void scaleAmplitude ()
 Calculate amplitude scale factor.
 
void generateTone (inputSample_t *tone, const std::size_t duration, const parameter_t frequency)
 Generate a sine tone. More...
 
parameter_t getW (void) const
 Find the speficied characteristic frequency for this detector (post-modulation and -normalisation) More...
 

Private Attributes

std::complex< parameter_t > zp
 previous z value
 
std::complex< parameter_t > zpp
 z value two samples ago
 
inputSample_t xp
 previous audio input sample
 
inputSample_t xpp
 audio input sample two samples ago
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractDetector
template<class Archive >
void save (Archive &archive) const
 Save the DetectorBank as a cereal archive. More...
 
template<class Archive >
void load (Archive &archive)
 Load the DetectorBank from a cereal archive. More...
 
void makeScaleVectors ()
 Make freq and factor vectors for given method and normalisation.
 
void getScaleValue (const parameter_t fr)
 Get a scale value for a given frequency.
 
- Static Protected Member Functions inherited from AbstractDetector
static const parameter_t getLyapunov (const parameter_t bw, const parameter_t amp)
 Find the first Lyapunov coefficient required for a given bandwidth, with a given forcing amplitude. More...
 
- Protected Attributes inherited from AbstractDetector
parameter_t w
 Characteristic frequency.
 
parameter_t const mu
 Distance from the bifurcation point.
 
parameter_t const d
 Detector damping factor.
 
parameter_t const sr
 Sample rate.
 
parameter_t const detBw
 Detector bandwidth.
 
parameter_t const gain
 Detector gain.
 
discriminator_t aScale
 Amplitude scaling factor.
 
parameter_t iScale
 Scaling factor for imaginary part.
 
parameter_t b
 Detector's first Lyapunov coefficent.
 
discriminator_t scale
 Detector's scale factor.
 
bool nrml { false }
 If search normalisation has been applied.
 
std::vector< parameter_t > detScaleFreqs
 
std::vector< discriminator_t > detScaleFactors
 
- Static Protected Attributes inherited from AbstractDetector
static constexpr int maxNormIterations { 100 }
 The maximum number of iterations to find best response during search_normalization.
 
static constexpr double normConverged { 1.0028922878693671 }
 Ratio of discovered frequency to specification frequency to be considered "close enough" during seach_normalization. More...
 
static const std::array< std::vector< parameter_t >, 8 > scaleFreqs
 
static const std::array< std::vector< discriminator_t >, 8 > scaleFactors
 

Detailed Description

Use the fourth order Runge-Kutta method to calculate the output.

Uses the discrete Runge-Kutta method to solve the first order differential equation \(y'=f(y, t)\). Let:

\begin{eqnarray*} k_0 & = & f(y_n, n-2) \\ k_1 & = & f(y_n + k_0\delta, n-1) \\ k_2 & = & f(y_n + k_1\delta, n) \\ k_3 & = & f(y_n + k_22\delta, n) \end{eqnarray*}

where \(\delta\) is the time step between samples,

then:

\[ y_{n+1} = y_n + \frac\delta 3(k_0 + 2k_1 + 2k_2 + k_3). \]

This procedure is used iterativey to find output samples of the Hopf bifurcation

\[\dot z=(\mu+j\omega_0)z + b|z|^2z + X\]

with control parameter \(\mu\), first Lyapunov coeffcient \(b\) (real) and driving force \(X\). For a supercritical bifurcation, \(b < 0\). \(b = 0\) yeilds a degenerate ("Bautin") bifurcation, and \(b > 0\) yeilds a subcritical bifurcation which is unstable.

Definition at line 291 of file detectors.h.

Constructor & Destructor Documentation

◆ RK4Detector()

RK4Detector::RK4Detector ( const parameter_t  f,
const parameter_t  mu,
const parameter_t  d,
const parameter_t  sr,
const parameter_t  detBw,
const parameter_t  gain 
)
Parameters
fDetector centre frequency (Hz)
muDetector control parameter. (Setting mu = 0 positions the system at the bifurcation point)
dDetector damping ratio
srSample rate of input audio
detBwDetector bandwidth
gainDetector gain

Member Function Documentation

◆ process()

virtual void RK4Detector::process ( discriminator_t *  target,
const inputSample_t *  start,
const std::size_t  count 
)
overridevirtual

Method to process audio using fourth order Runge-Kutta approximation.

Called by runChannels() in DetectorBank.

Parameters
targetOutput array. This should have the correct dimensions for your desired detector bank: height = number of detectors, length = length of audio input.
startCurrent audio sample
countNumber of frames to process

Implements AbstractDetector.


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