Base class for detectors using different numerical methods.
More...
#include <detectors.h>
|
| 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...
|
|
virtual void | reset ()=0 |
| Reset the internal values used to calculate z to 0. More...
|
|
|
virtual void | process (discriminator_t *target, const inputSample_t *start, std::size_t count)=0 |
| This method gets overridden in derived classes to produce an unnormalised version of the required output.
|
|
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 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...
|
|
|
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 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 |
|
|
class | cereal::access |
|
template<class Archive > |
void | DetectorBank::save (Archive &) const |
| Permit cereal and the archive functions of the DetectorBank with which this detector is composed to read protected variables for archival purposes.
|
|
template<class Archive > |
void | DetectorBank::load (Archive &) |
| Permit cereal and the archive functions of the DetectorBank with which this detector is composed to write protected variables for archival purposes.
|
|
Base class for detectors using different numerical methods.
The process() method must be supplied by the derived classes.
Definition at line 21 of file detectors.h.
◆ AbstractDetector()
AbstractDetector::AbstractDetector |
( |
parameter_t |
f, |
|
|
parameter_t |
mu, |
|
|
parameter_t |
d, |
|
|
parameter_t |
sr, |
|
|
parameter_t |
detBw, |
|
|
parameter_t |
gain |
|
) |
| |
- Parameters
-
f | Detector centre frequency (Hz) |
mu | Detector control parameter (should be in the region of 0) |
d | Detector damping ratio |
sr | Sample rate of input audio (should be 44.1kHz or 48kHz) |
detBw | Detector bandwidth (Hz) |
gain | Detector gain |
◆ amplitudeNormalize()
bool AbstractDetector::amplitudeNormalize |
( |
const parameter_t |
forcing_amplitude | ) |
|
Set the detector's a and iScale attributes by profiling an ideal detector response.
These can then be used to normalise the detector's amplitude response to the range 0-1.
- Parameters
-
forcingAmplitude | Gain that was applied to the input signal |
- Returns
- true
- Exceptions
-
std::string | Invalid detector type while attempting amplitude normalization |
◆ generateTone()
void AbstractDetector::generateTone |
( |
inputSample_t * |
tone, |
|
|
const std::size_t |
duration, |
|
|
const parameter_t |
frequency |
|
) |
| |
Generate a sine tone.
- Parameters
-
tone | Array for output tone |
duration | Tone duration (in samples) |
frequency | Frequency at which to generate tone (Hz) |
◆ getLyapunov()
static const parameter_t AbstractDetector::getLyapunov |
( |
const parameter_t |
bw, |
|
|
const parameter_t |
amp |
|
) |
| |
|
staticprotected |
Find the first Lyapunov coefficient required for a given bandwidth, with a given forcing amplitude.
If the desired bandwidth is given as zero, the returned value will be zero. This will create a detetor with the narrowest possible bandwidth (~1.5Hz)
- Parameters
-
bw | Desired bandwidth |
amp | Forcing amplitude |
- Returns
- First Lyapunov coefficient
◆ getW()
parameter_t AbstractDetector::getW |
( |
void |
| ) |
const |
|
inline |
Find the speficied characteristic frequency for this detector (post-modulation and -normalisation)
- Returns
- Characterisic frequency in rad/s
Definition at line 104 of file detectors.h.
◆ load()
template<class Archive >
void AbstractDetector::load |
( |
Archive & |
archive | ) |
|
|
inlineprotected |
Load the DetectorBank from a cereal archive.
- Parameters
-
archive | The archive from which properties are read. |
Definition at line 164 of file detectors.h.
◆ processAudio()
void AbstractDetector::processAudio |
( |
discriminator_t * |
target, |
|
|
const inputSample_t * |
start, |
|
|
std::size_t |
count |
|
) |
| |
Process audio using the numerical method appropriate to the derived class.
The derived class's process() method is called and if amplitude normalisation is required, the predetermined gain and stiffness constant is applied to the result.
- Parameters
-
target | Pointer to output array. This should have the correct dimensions for your desired detector bank: height = number of detectors, length = length of audio input. |
start | Pointer to beginning of audio |
count | Number of frames to process |
◆ reset()
virtual void AbstractDetector::reset |
( |
| ) |
|
|
pure virtual |
◆ save()
template<class Archive >
void AbstractDetector::save |
( |
Archive & |
archive | ) |
const |
|
inlineprotected |
Save the DetectorBank as a cereal archive.
- Parameters
-
archive | The archive to which properties are written. |
Definition at line 150 of file detectors.h.
◆ searchNormalize()
bool AbstractDetector::searchNormalize |
( |
parameter_t |
searchStart, |
|
|
parameter_t |
searchEnd, |
|
|
const parameter_t |
toneDuration, |
|
|
const parameter_t |
forcing_amplitude |
|
) |
| |
Normalise the detector frequency using an iterative scheme.
The lower and upper bounds of the search must be respectively lower and higher than the actual characteristic frequency of the detector. The search iterates by moving the worst performing bounding frequency half way towards the mean of the two current bounds until the maximum number of iterations or is exceeded or the specified accuracy is achieved (see maxNormIterations and normConverged).
- Parameters
-
searchStart | Lower bound of search (ratio of specified f0) |
searchEnd | Upper bound of search (ratio of specified f0) |
toneDuration | Length constant test tone to be generaated |
- Exceptions
-
std::string | Invalid detector type while attempting search-normalisation |
std::string | Searching for normalised charactersitc frequency: test range does not span maximum response. |
◆ normConverged
constexpr double AbstractDetector::normConverged { 1.0028922878693671 } |
|
staticprotected |
Ratio of discovered frequency to specification frequency to be considered "close enough" during seach_normalization.
1.0057929410678534 = 2^(1/120) = 10 cents; 1.0028922878693671 = 2^(1/240) = 5 cents
Definition at line 196 of file detectors.h.
The documentation for this class was generated from the following file: