Tracking the phase of the sine directly instead of recomputing it
This commit is contained in:
parent
a885bf0c72
commit
1cd4a95246
1 changed files with 4 additions and 2 deletions
|
|
@ -165,9 +165,10 @@ public:
|
|||
return;
|
||||
|
||||
float step = baseFrequency * twoPi<float> / sampleRate;
|
||||
::linearRamp<float>(tempSpan1.first(buffer.size()), sourcePosition * step, step);
|
||||
::sin<float>(tempSpan1, buffer.left());
|
||||
phase = ::linearRamp<float>(tempSpan1, phase, step);
|
||||
::sin<float>(tempSpan1.first(buffer.size()), buffer.left());
|
||||
absl::c_copy(buffer.left(), buffer.right().begin());
|
||||
|
||||
sourcePosition += buffer.size();
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +239,7 @@ private:
|
|||
float pitchRatio { 1.0 };
|
||||
float baseGain { 1.0 };
|
||||
float baseFrequency { 440.0 };
|
||||
float phase { 0.0f };
|
||||
|
||||
uint32_t sourcePosition { 0 };
|
||||
uint32_t initialDelay { 0 };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue