-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64b79a1
commit 6f65580
Showing
6 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "dsp_base.h" | ||
|
||
#include "delayline.h" | ||
|
||
namespace dsp | ||
{ | ||
|
||
class WaveguideGates | ||
{ | ||
public: | ||
WaveguideGates(); | ||
~WaveguideGates() = default; | ||
|
||
void SetDelay(float delay); | ||
float GetDelay() const; | ||
|
||
void SetCoeff(float c); | ||
|
||
void Process(Delayline& left_traveling_line, Delayline& right_traveling_line); | ||
|
||
private: | ||
float coeff_ = 0.f; | ||
float delay_ = 0.f; | ||
size_t delay_integer_ = 0; | ||
float delay_fractional_ = 0.f; | ||
float inv_delay_fractional_ = 0.f; | ||
Delayline delay_left_; | ||
Delayline delay_right_; | ||
}; | ||
} // namespace dsp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,6 @@ def tick(self, input): | |
|
||
return a + (b - a) * self.delay_frac | ||
|
||
|
||
|
||
Fs = 48000 | ||
|
||
# Waveguide Length | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "waveguide_gates.h" | ||
|
||
namespace dsp | ||
{ | ||
|
||
WaveguideGates::WaveguideGates() : delay_left_(8), delay_right_(8) | ||
{ | ||
} | ||
|
||
void WaveguideGates::SetDelay(float delay) | ||
{ | ||
delay_ = delay; | ||
delay_integer_ = static_cast<int>(delay); | ||
delay_fractional_ = delay - delay_integer_; | ||
inv_delay_fractional_ = 1.f - delay_fractional_; | ||
|
||
delay_left_.SetDelay(delay_fractional_ * 2.f); | ||
delay_right_.SetDelay(inv_delay_fractional_ * 2.f); | ||
} | ||
|
||
float WaveguideGates::GetDelay() const | ||
{ | ||
return delay_; | ||
} | ||
|
||
void WaveguideGates::SetCoeff(float c) | ||
{ | ||
coeff_ = c; | ||
} | ||
|
||
void WaveguideGates::Process(Delayline& left_traveling_line, Delayline& right_traveling_line) | ||
{ | ||
const float kLeftGate = delay_integer_ - 1; | ||
const float kRightGate = delay_integer_ + 1; | ||
|
||
float left_input = right_traveling_line.TapOut(kLeftGate); | ||
float left_interpolated = delay_left_.Tick(left_input); | ||
float left_gate_sample = left_traveling_line.TapOut(delay_integer_); | ||
float new_sample = left_gate_sample * (1 - coeff_) + left_interpolated * (coeff_); | ||
left_traveling_line.SetIn(delay_integer_, left_interpolated); | ||
|
||
float right_input = left_traveling_line.TapOut(kRightGate); | ||
float right_interpolated = delay_right_.Tick(right_input); | ||
float right_gate_sample = right_traveling_line.TapOut(delay_integer_); | ||
new_sample += right_gate_sample * (1 - coeff_) + right_interpolated * (coeff_); | ||
right_traveling_line.SetIn(delay_integer_, right_interpolated); | ||
} | ||
|
||
} // namespace dsp |