Skip to content

Commit

Permalink
docs: add code annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
zsliu98 committed Dec 26, 2023
1 parent c8e0e45 commit 00316e6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
10 changes: 9 additions & 1 deletion source/dsp/compressor/computer/knee_computer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
#include "virtual_computer.h"

namespace zlCompressor {

/**
* a computer that computes the current compression
* @tparam FloatType
*/
template<typename FloatType>
class KneeComputer : VirtualComputer<FloatType> {
public:
Expand All @@ -29,6 +32,11 @@ namespace zlCompressor {

FloatType eval(FloatType x);

/**
* computes the current compression
* @param x input level (in dB)
* @return current compression (in dB)
*/
FloatType process(FloatType x) override;

inline void setThreshold(FloatType v) {
Expand Down
10 changes: 9 additions & 1 deletion source/dsp/compressor/detector/detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
#include "iter_funcs.h"

namespace zlCompressor {

/**
* a detector that performs attack/release on the input gain
* @tparam FloatType
*/
template<typename FloatType>
class Detector {
public:
Expand All @@ -33,6 +36,11 @@ namespace zlCompressor {

void prepare(const juce::dsp::ProcessSpec &spec);

/**
* apply attack/release on the target gain and return the current gain
* @param target the target gain
* @return the current gain
*/
FloatType process(FloatType target);

inline void setAStyle(IterType idx) { aStyle.store(idx); }
Expand Down
9 changes: 9 additions & 0 deletions source/dsp/compressor/forward_compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@
#include "tracker/tracker.h"

namespace zlCompressor {
/**
* a forward compressor
* @tparam FloatType
*/
template<typename FloatType>
class ForwardCompressor {
public:
ForwardCompressor() = default;

void prepare(const juce::dsp::ProcessSpec &spec);

/**
* process the audio buffer and return the compression gain (in gain)
* @param buffer side chain audio buffer
* @return gain (in gain)
*/
FloatType process(juce::AudioBuffer<FloatType> buffer);

inline KneeComputer<FloatType> &getComputer() { return computer; }
Expand Down
5 changes: 4 additions & 1 deletion source/dsp/compressor/tracker/rms_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
#include "virtual_tracker.h"

namespace zlCompressor {

/**
* a tracker that tracks the momentary RMS loudness of the audio signal
* @tparam FloatType
*/
template<typename FloatType>
class RMSTracker : VirtualTracker<FloatType> {
public:
Expand Down
13 changes: 11 additions & 2 deletions source/dsp/dynamic_filter/dynamic_iir_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
namespace zlDynamicFilter {
/**
* a dynamic IIR filter which holds a main filter, a target filter and a side filter
* the output signal is a mix of the signal from the main filter and the signal from the target filter
* the mix portion is controlled by a compressor on the signal from the side filter
* the output signal is a mix of the signal from the main/target filter (on the main chain)
* the mix portion is controlled by a compressor on the signal from the side filter (on the side chain)
* @tparam FloatType
*/
template<typename FloatType>
Expand All @@ -30,6 +30,11 @@ namespace zlDynamicFilter {

void prepare(const juce::dsp::ProcessSpec &spec);

/**
* process the audio buffer
* @param mBuffer main chain audio buffer
* @param sBuffer side chain audio buffer
*/
void process(juce::AudioBuffer<FloatType> &mBuffer, juce::AudioBuffer<FloatType> &sBuffer);

inline zlIIR::Filter<FloatType> &getMainFilter() { return mFilter; }
Expand All @@ -40,6 +45,10 @@ namespace zlDynamicFilter {

inline void setDynamicON(bool x) { dynamicON.store(x); }

/**
* calculate the default frequency of the side filter
* @return the default frequency of the side filter
*/
FloatType getSideDefaultFreq();

void addDBs(std::array<FloatType, zlIIR::frequencies.size()> &x);
Expand Down
6 changes: 5 additions & 1 deletion source/dsp/iir_filter/single_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "coeff/design_filter.h"

namespace zlIIR {
// sd does not support constexpr log/pow, np.logspace(1, np.log10(20000), 200)
/** stl does not support constexpr log/pow, np.logspace(1, np.log10(20000), 200) */
constexpr std::array<double, 200> frequencies = {1.00000000e+01, 1.03893431e+01, 1.07938451e+01, 1.12140960e+01,
1.16507092e+01, 1.21043215e+01, 1.25755950e+01, 1.30652172e+01,
1.35739024e+01, 1.41023930e+01, 1.46514600e+01, 1.52219046e+01,
Expand Down Expand Up @@ -71,6 +71,10 @@ namespace zlIIR {
1.53078206e+04, 1.59038200e+04, 1.65230244e+04, 1.71663370e+04,
1.78346965e+04, 1.85290782e+04, 1.92504952e+04, 2.00000000e+04};

/**
* a static IIR filter
* @tparam FloatType
*/
template<typename FloatType>
class Filter {
public:
Expand Down
12 changes: 12 additions & 0 deletions source/dsp/splitter/lr_splitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@
#include <juce_dsp/juce_dsp.h>

namespace zlSplitter {
/**
* a splitter that splits the stereo audio signal input left signal and right signal
* @tparam FloatType
*/
template<typename FloatType>
class LRSplitter {
public:
LRSplitter() = default;

void prepare(const juce::dsp::ProcessSpec &spec);

/**
* split the audio buffer into internal left buffer and right buffer
* @param buffer
*/
void split(juce::AudioBuffer<FloatType> &buffer);

/**
* combine the internal left buffer and right buffer into the audio buffer
* @param buffer
*/
void combine(juce::AudioBuffer<FloatType> &buffer);

inline juce::AudioBuffer<FloatType> &getLBuffer() { return lBuffer; }
Expand Down
12 changes: 12 additions & 0 deletions source/dsp/splitter/ms_splitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@
#include <juce_dsp/juce_dsp.h>

namespace zlSplitter {
/**
* a splitter that splits the stereo audio signal input mid signal and side signal
* @tparam FloatType
*/
template<typename FloatType>
class MSSplitter {
public:
MSSplitter() = default;

void prepare(const juce::dsp::ProcessSpec &spec);

/**
* split the audio buffer into internal mid buffer and side buffer
* @param buffer
*/
void split(juce::AudioBuffer <FloatType> &buffer);

/**
* combine the internal mid buffer and side buffer into the audio buffer
* @param buffer
*/
void combine(juce::AudioBuffer <FloatType> &buffer);

inline juce::AudioBuffer<FloatType> &getMBuffer() { return mBuffer; }
Expand Down

0 comments on commit 00316e6

Please sign in to comment.