Skip to content

Commit

Permalink
Rename dsp namespace to sfdsp
Browse files Browse the repository at this point in the history
  • Loading branch information
Segfault1602 committed Nov 9, 2023
1 parent 19abe45 commit afee123
Show file tree
Hide file tree
Showing 66 changed files with 654 additions and 320 deletions.
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"request": "launch",
"program": "${workspaceFolder}/build/tests/libdsp_tests.exe",
"args": [
"--gtest_filter=WaveguideGatesTest.ClosedGates"
"--gtest_filter=WaveguideGatesTest.SineWave"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
Expand Down Expand Up @@ -115,9 +115,8 @@
"request": "launch",
"program": "${workspaceFolder}/build/tools/effect_player.exe",
"args": [
"-r",
"-t",
"8"
"10"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
Expand Down
4 changes: 2 additions & 2 deletions include/basic_oscillators.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

namespace dsp
namespace sfdsp
{
/// @brief Simple sine wave
/// @param phase Phase of the sine wave
Expand All @@ -25,4 +25,4 @@ float Square(float phase);
/// @brief Simple noise generator
/// @return
float Noise();
} // namespace dsp
} // namespace sfdsp
6 changes: 3 additions & 3 deletions include/bow_table.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

namespace dsp
namespace sfdsp
{
/// @brief Simple bowed string non-linear function taken from the STK.
/// https://github.com/thestk/stk/blob/master/include/BowTable.h
Expand All @@ -14,7 +14,7 @@ class BowTable
/// @param f Force of the bow
void SetForce(float f)
{
force_ = 5.f - (4.5f * f);
force_ = 5.f - (4.f * f);
}

/// @brief Returns the force of the bow
Expand Down Expand Up @@ -43,4 +43,4 @@ class BowTable
float force_ = 3.f;
float offset_ = 0.001f;
};
} // namespace dsp
} // namespace sfdsp
12 changes: 9 additions & 3 deletions include/bowed_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#include "rms.h"
#include "termination.h"
#include "waveguide.h"
#include "waveguide_gate.h"

#include <algorithm>

namespace dsp
namespace sfdsp
{

/// @brief Implements a bowed string model using a waveguide composed of a right traveling wave and a left traveling
Expand Down Expand Up @@ -84,11 +85,16 @@ class BowedString
/// @return The output sample at the bridge.
float Tick(float input = 0.f);

/// @brief Set the finger pressure.
/// @param pressure 0 is no pressure, 1 is full pressure.
void SetFingerPressure(float pressure);

private:
Waveguide waveguide_;
WaveguideGate gate_;

float bow_position_ = 0.f;
float relative_bow_position_ = 0.2f;
float relative_bow_position_ = 0.15f;

Termination nut_;
Termination bridge_;
Expand All @@ -107,4 +113,4 @@ class BowedString
OnePoleFilter decay_filter_;
OnePoleFilter noise_lp_filter_;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/chorus.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "dsp_base.h"
#include <cmath>

namespace dsp
namespace sfdsp
{
/// @brief Simple chorus effect.
class Chorus : public DspBase
Expand Down Expand Up @@ -79,4 +79,4 @@ class Chorus : public DspBase
float chorus_mix_ = 0.5f;
float input_mix_ = 0.5f;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "dsp_base.h"

namespace dsp
namespace sfdsp
{
/// @brief Simple circular buffer.
/// @tparam CONTAINER_SIZE
Expand Down Expand Up @@ -141,4 +141,4 @@ const float& CircularBuffer<CONTAINER_SIZE>::operator[](size_t idx) const
auto real_idx = (read_ + idx) % CONTAINER_SIZE;
return buffer_[real_idx];
}
} // namespace dsp
} // namespace sfdsp
7 changes: 2 additions & 5 deletions include/delayline.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "dsp_base.h"
#include "interpolation_strategy.h"

namespace dsp
namespace sfdsp
{

/// @brief Simple delayline.
Expand Down Expand Up @@ -69,9 +69,6 @@ class Delayline
/// @param input Input sample
void SetIn(float delay, float input);

/// @brief Move the write pointer of the delayline back one sample.
void Rewind();

float& operator[](size_t index) const;
float& operator[](size_t index);

Expand All @@ -89,4 +86,4 @@ class Delayline
std::unique_ptr<InterpolationStrategy> interpolation_strategy_;
std::unique_ptr<float[]> line_;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/delayline_linear.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "delayline.h"
#include "dsp_base.h"

namespace dsp
namespace sfdsp
{

/// @brief Implements a linear delayline with a maximum delay of MAX_DELAY
Expand All @@ -34,4 +34,4 @@ class LinearDelayline : public Delayline
float next_out_ = 0.f;
float last_out_ = 0.f;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/dsp_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define TWO_PI (2.0f * PI_F)

namespace dsp
namespace sfdsp
{
class DspBase
{
Expand Down Expand Up @@ -66,4 +66,4 @@ constexpr float midi_to_freq[128] = {
7902.1328201f, 8372.01808962f, 8869.84419126f, 9397.27257336f, 9956.06347911f, 10548.0818212f, 11175.3034059f,
11839.8215268f,
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <cstddef>
#include <cstdint>

namespace dsp
namespace sfdsp
{
/// @brief Base class for filters
class Filter
Expand Down Expand Up @@ -112,4 +112,4 @@ class Biquad : public Filter

float Tick(float in) override;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/interpolation_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <cstddef>

namespace dsp
namespace sfdsp
{

enum class InterpolationType
Expand Down Expand Up @@ -60,4 +60,4 @@ class AllpassInterpolation : public InterpolationStrategy
float last_out_;
float allpass_input_;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/junction.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "delayline.h"
#include <array>

namespace dsp
namespace sfdsp
{

/// @brief Implements a junction point between two delaylines
Expand All @@ -24,4 +24,4 @@ class Junction
float delay_ = 0;
// float gain_ = 1.f;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <cstdint>

namespace dsp
namespace sfdsp
{
/// @brief Simple ramp generator.
class Line
Expand All @@ -20,4 +20,4 @@ class Line
float output_ = 0.f;
float increment_ = 0.f;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/phaseshapers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "dsp_base.h"

namespace dsp
namespace sfdsp
{

/// @brief Phaseshaper oscillator that can morph between different waveforms
Expand Down Expand Up @@ -99,4 +99,4 @@ class Phaseshaper

float m_mod = 0.f;
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/rms.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "delayline.h"

namespace dsp
namespace sfdsp
{

/// @brief Root Mean Square calculator
Expand Down Expand Up @@ -30,4 +30,4 @@ class RMS
float last_out_ = 0.f;
};

} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/sin_table.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Auto-generated file from make_sine_table.py
#pragma once

namespace dsp
namespace sfdsp
{
constexpr size_t SIN_LUT_SIZE = 512;
const float sin_lut[SIN_LUT_SIZE + 1] = {
Expand Down Expand Up @@ -72,4 +72,4 @@ const float sin_lut[SIN_LUT_SIZE + 1] = {
-0.09801714f, -0.08579731f, -0.07356456f, -0.06132074f, -0.04906767f, -0.03680722f, -0.02454123f, -0.01227154f,
-0.00000000f,
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/sinc_resampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <stdlib.h>

namespace dsp
namespace sfdsp
{
/// @brief Resamples the input signal by the given ratio using a windowed sinc filter
/// @param in Input signal
Expand All @@ -16,4 +16,4 @@ namespace dsp
/// @param out Output signal
/// @param[in, out] out_size Size of the output signal
void sinc_resample(const float* in, size_t input_size, float ratio, float* out, size_t& out_size);
} // namespace dsp
} // namespace sfdsp
11 changes: 8 additions & 3 deletions include/string_ensemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "bowed_string.h"
#include "dsp_base.h"

namespace dsp
namespace sfdsp
{

constexpr size_t kStringCount = 4;
Expand Down Expand Up @@ -57,13 +57,18 @@ class StringEnsemble
/// @param string_number
void FingerOff(uint8_t string_number);

/// @brief Set the amount of energy transmitted from one string to the others
/// @param t
void SetBridgeTransmission(float t);

float Tick();

private:
std::array<dsp::BowedString, kStringCount> strings_;
std::array<sfdsp::BowedString, kStringCount> strings_;
std::array<float, kStringCount> openTuning_;
float bridgeTransmission_ = 0.1f;

OnePoleFilter transmission_filter_;
Biquad body_filters_[6];
};
} // namespace dsp
} // namespace sfdsp
4 changes: 2 additions & 2 deletions include/termination.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "delayline.h"
#include "filter.h"

namespace dsp
namespace sfdsp
{
/// @brief Base class for termination points between two delaylines
/// @note For now, a termination is simply a gain and a filter and the class mostly exists for readability.
Expand Down Expand Up @@ -35,4 +35,4 @@ class Termination
float gain_ = -1.f;
Filter* filter_ = nullptr;
};
} // namespace dsp
} // namespace sfdsp
Loading

0 comments on commit afee123

Please sign in to comment.