Om
1.0.0
A universal framework for multimedia simulation
|
A class that stores a sequence of frequency-dependent values in sorted order. More...
#include <omSoundFrequencyData.h>
Public Member Functions | |
FrequencyData () | |
Create a frequency data response with no data points. More... | |
FrequencyData (Float data) | |
Create a frequency data response with the specified value across all frequencies. More... | |
Size | getPointCount () const |
Return the number of frequency data points there are in this response. More... | |
Float | getFrequency (Index pointIndex) const |
Return the frequency for the specified point index within this response. More... | |
Float | getData (Index pointIndex) const |
Return the data value for the specified point index within this response. More... | |
void | setData (Index pointIndex, Float data) |
Set the data value for the specified point index within this response. More... | |
void | addPoint (Float frequency, Float data) |
Add the specified frequency data point to this response. More... | |
Bool | removePoint (Index pointIndex) |
Remove the frequency data point at the specified index in this response. More... | |
Bool | removeFrequency (Float frequency) |
Remove the data point with the specified frequency in this response. More... | |
void | clear () |
Remove all frequency data points from this frequency data response. More... | |
Float | interpolate (Float frequency) const |
Return the interpolated gain for the specified frequency. More... | |
Float | getMax () const |
Return the maximum value over all frequencies. More... | |
Float | getAverage () const |
Return the average gain of this FrequencyData over its entire range. More... | |
Float | getBandAverage (Float minFrequency, Float maxFrequency) const |
Return the average data value over the specified frequency range. More... | |
Float | getBandAverage (const AABB1f &bandRange) const |
Return the average data value over the specified frequency range. More... | |
A class that stores a sequence of frequency-dependent values in sorted order.
The typical use of this class is to store a frequency response that is sampled at irregular intervals.
om::sound::base::FrequencyData::FrequencyData | ( | ) |
Create a frequency data response with no data points.
om::sound::base::FrequencyData::FrequencyData | ( | Float | data | ) |
Create a frequency data response with the specified value across all frequencies.
This constructor creates a response with two frequency response points: 20 Hz and 20 kHz with the given value.
data | - the initial data value used for all frequencies. |
|
inline |
Return the number of frequency data points there are in this response.
Return the frequency for the specified point index within this response.
The frequency index must be less than the total number of frequencies in the response.
Return the data value for the specified point index within this response.
The frequency index must be less than the total number of frequencies in the response.
Set the data value for the specified point index within this response.
The frequency index must be less than the total number of frequencies in the response.
Add the specified frequency data point to this response.
The new frequency is inserted in the internal list of frequencies at the correct sorted position in the list. If there is a previously-existing frequency data point for that frequency, the data replaces the previous data without adding a new point.
It is most efficient to add data points in sorted order.
Remove the frequency data point at the specified index in this response.
The method returns whether or not the frequency at that index was able to be removed.
Remove the data point with the specified frequency in this response.
If there is no data point with that frequency, FALSE is returned and the response is not modified. Otherwise, the method succeeds and TRUE is returned.
void om::sound::base::FrequencyData::clear | ( | ) |
Remove all frequency data points from this frequency data response.
Return the interpolated gain for the specified frequency.
This method interpolates between the two nearest frequencies to the specified frequency. It returns the linearly interpolated gain value of this response at that frequency.
If there are no data points, a value of 0 is returned.
Float om::sound::base::FrequencyData::getMax | ( | ) | const |
Return the maximum value over all frequencies.
Float om::sound::base::FrequencyData::getAverage | ( | ) | const |
Return the average gain of this FrequencyData over its entire range.
This method integrates the interpolated gain coefficients across the frequency response and returns the average coefficient.
Float om::sound::base::FrequencyData::getBandAverage | ( | Float | minFrequency, |
Float | maxFrequency | ||
) | const |
Return the average data value over the specified frequency range.
This method is useful when mapping higher-resolution frequency data down to lower-resolution frequency data. The band boundaries are clamped to the minimum and maximum frequencies in this frequency data response and will be swaped if they are not specified in ascending order.
The method returns the average value over the specified frequency band range via trapezoidal integration.
|
inline |
Return the average data value over the specified frequency range.