DaisySP
Loading...
Searching...
No Matches
KarplusString.h
Go to the documentation of this file.
1/*
2Copyright (c) 2020 Electrosmith, Corp, Emilie Gillet
3
4Use of this source code is governed by an MIT-style
5license that can be found in the LICENSE file or at
6https://opensource.org/licenses/MIT.
7*/
8
9#pragma once
10#ifndef DSY_STRING_H
11#define DSY_STRING_H
12
13#include <stdint.h>
14
15#include "Dynamics/crossfade.h"
16#include "Utility/dcblock.h"
17#include "Utility/delayline.h"
18#include "Filters/onepole.h"
19
20#ifdef __cplusplus
21
24namespace daisysp
25{
35class String
36{
37 public:
38 String() {}
39 ~String() {}
40
44 void Init(float sample_rate);
45
47 void Reset();
48
52 float Process(const float in);
53
57 void SetFreq(float freq);
58
62 void SetNonLinearity(float non_linearity_amount);
63
67 void SetBrightness(float brightness);
68
72 void SetDamping(float damping);
73
74
75 private:
76 static constexpr size_t kDelayLineSize = 1024;
77
78 enum StringNonLinearity
79 {
80 NON_LINEARITY_CURVED_BRIDGE,
81 NON_LINEARITY_DISPERSION
82 };
83
84 template <String::StringNonLinearity non_linearity>
85 float ProcessInternal(const float in);
86
88 DelayLine<float, kDelayLineSize / 4> stretch_;
89
90 float frequency_, non_linearity_amount_, brightness_, damping_;
91
92 float sample_rate_;
93
94 OnePole iir_damping_filter_;
95
96 DcBlock dc_blocker_;
97
98 CrossFade crossfade_;
99
100 float dispersion_noise_;
101 float curved_bridge_;
102
103 // Very crappy linear interpolation upsampler used for low pitches that
104 // do not fit the delay line. Rarely used.
105 float src_phase_;
106 float out_sample_[2];
107};
108} // namespace daisysp
109#endif
110#endif
Definition crossfade.h:42
Definition dcblock.h:19
Definition delayline.h:29
One Pole Lowpass / Highpass Filter.
Definition onepole.h:27
Comb filter / KS string.
Definition KarplusString.h:36
float Process(const float in)
Definition KarplusString.cpp:43
void SetBrightness(float brightness)
Definition KarplusString.cpp:69
void Init(float sample_rate)
Definition KarplusString.cpp:8
void SetFreq(float freq)
Definition KarplusString.cpp:58
void SetDamping(float damping)
Definition KarplusString.cpp:74
void SetNonLinearity(float non_linearity_amount)
Definition KarplusString.cpp:64
void Reset()
Definition KarplusString.cpp:29
FIR Filter implementation, generic and ARM CMSIS DSP based.
Definition adenv.h:16