Audacity 3.2.0
|
#include <LookAheadGainReduction.h>
Public Member Functions | |
LookAheadGainReduction () | |
~LookAheadGainReduction () | |
void | setDelayTime (float delayTimeInSeconds) |
const int | getDelayInSamples () |
void | prepare (const double sampleRate, const int blockSize) |
void | pushSamples (const float *src, const int numSamples) |
void | process () |
void | readSamples (float *dest, const int numSamples) |
Private Member Functions | |
void | getProcessPositions (int startIndex, int numSamples, int &blockSize1, int &blockSize2) |
void | getWritePositions (int numSamples, int &startIndex, int &blockSize1, int &blockSize2) |
void | getReadPositions (int numSamples, int &startIndex, int &blockSize1, int &blockSize2) |
Private Attributes | |
double | sampleRate |
int | blockSize |
float | delay |
int | delayInSamples = 0 |
int | writePosition = 0 |
int | lastPushedSamples = 0 |
std::vector< float > | buffer |
This class acts as a delay line for gain-reduction samples, which additionally fades in high gain-reduction values in order to avoid distortion when limiting an audio signal.
Definition at line 26 of file LookAheadGainReduction.h.
|
inline |
Definition at line 29 of file LookAheadGainReduction.h.
|
inline |
Definition at line 30 of file LookAheadGainReduction.h.
|
inline |
Definition at line 34 of file LookAheadGainReduction.h.
References delayInSamples.
|
inlineprivate |
A little helper-function which calulcates how many samples we should process in a first step before we have to wrap around, as our buffer is a ring-buffer.
Definition at line 213 of file LookAheadGainReduction.cpp.
References min().
Referenced by process().
|
inlineprivate |
Definition at line 252 of file LookAheadGainReduction.cpp.
References buffer, delayInSamples, lastPushedSamples, min(), and writePosition.
Referenced by readSamples().
|
inlineprivate |
Definition at line 228 of file LookAheadGainReduction.cpp.
References buffer, min(), and writePosition.
Referenced by pushSamples().
void DanielRudrich::LookAheadGainReduction::prepare | ( | const double | sampleRate, |
const int | blockSize | ||
) |
Prepares the processor so it can resize the buffers depending on samplerate and the expected buffersize.
Definition at line 36 of file LookAheadGainReduction.cpp.
References blockSize, buffer, delay, delayInSamples, sampleRate, and writePosition.
Referenced by setDelayTime().
void DanielRudrich::LookAheadGainReduction::process | ( | ) |
Processes the data within the delay line, i.e. fades-in high gain-reduction, in order to reduce distortions.
The basic idea here is to look for high gain-reduction values in the signal, and apply a fade which starts exactly delayInSamples
many samples before that value appears. Depending on the value itself, the slope of the fade will vary.
Some things to note:
step
nextGainReductionValue
Definition at line 68 of file LookAheadGainReduction.cpp.
References buffer, delayInSamples, getProcessPositions(), lastPushedSamples, and writePosition.
void DanielRudrich::LookAheadGainReduction::pushSamples | ( | const float * | src, |
const int | numSamples | ||
) |
Writes gain-reduction samples into the delay-line. Make sure you call process() afterwards, and read the same amount of samples with the readSamples method. Make also sure the pushed samples are decibel values.
Definition at line 48 of file LookAheadGainReduction.cpp.
References buffer, getWritePositions(), lastPushedSamples, and writePosition.
void DanielRudrich::LookAheadGainReduction::readSamples | ( | float * | dest, |
const int | numSamples | ||
) |
Reads smoothed gain-reduction samples back to the destination. Make sure you read as many samples as you've pushed before!
Definition at line 197 of file LookAheadGainReduction.cpp.
References buffer, and getReadPositions().
void DanielRudrich::LookAheadGainReduction::setDelayTime | ( | float | delayTimeInSeconds | ) |
Definition at line 25 of file LookAheadGainReduction.cpp.
References blockSize, delay, prepare(), and sampleRate.
|
private |
Definition at line 66 of file LookAheadGainReduction.h.
Referenced by prepare(), and setDelayTime().
|
private |
Definition at line 72 of file LookAheadGainReduction.h.
Referenced by getReadPositions(), getWritePositions(), prepare(), process(), pushSamples(), and readSamples().
|
private |
Definition at line 68 of file LookAheadGainReduction.h.
Referenced by prepare(), and setDelayTime().
|
private |
Definition at line 69 of file LookAheadGainReduction.h.
Referenced by getDelayInSamples(), getReadPositions(), prepare(), and process().
|
private |
Definition at line 71 of file LookAheadGainReduction.h.
Referenced by getReadPositions(), process(), and pushSamples().
|
private |
Definition at line 65 of file LookAheadGainReduction.h.
Referenced by prepare(), and setDelayTime().
|
private |
Definition at line 70 of file LookAheadGainReduction.h.
Referenced by getReadPositions(), getWritePositions(), prepare(), process(), and pushSamples().