-
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.
Showing
7 changed files
with
170 additions
and
132 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
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,11 @@ | ||
#pragma once | ||
|
||
namespace siderialib { | ||
constexpr int DISPERSE_NUM_VOICES = 6; | ||
|
||
constexpr sfloat DISPERSE_MAX_TIME = 0.5f; | ||
constexpr sfloat DISPERSE_MAX_MOD_RATE = 0.2f; | ||
constexpr sfloat DISPERSE_MAX_DELAY_MS = 5000.0f; | ||
constexpr sfloat DISPERSE_MIN_DELAY_MS = 100.0f; | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
siderialib/include/effects/disperse/DisperseParallelVoice.h
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,64 @@ | ||
#pragma once | ||
|
||
|
||
#include <cstdarg> | ||
#include "effects/delay/ModulatedDelay.h" | ||
#include "DisperseConstants.h" | ||
|
||
namespace siderialib { | ||
class DisperseParallelVoice { | ||
private: | ||
ModulatedDelay* _delays[DISPERSE_NUM_VOICES] = { | ||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr | ||
}; | ||
int _numActiveVoices = 0; | ||
|
||
sfloat _lastOutL = 0.0; | ||
sfloat _lastOutR = 0.0; | ||
public: | ||
DisperseParallelVoice() = default; | ||
|
||
void addVoice(ModulatedDelay* delay) { | ||
if (_numActiveVoices >= DISPERSE_NUM_VOICES) { | ||
return; | ||
} | ||
|
||
_delays[_numActiveVoices] = delay; | ||
_numActiveVoices++; | ||
} | ||
|
||
void clearVoices() { | ||
for (int i = 0; i < _numActiveVoices; i++) { | ||
_delays[i] = nullptr; | ||
} | ||
|
||
_numActiveVoices = 0; | ||
} | ||
|
||
void initialize() { | ||
} | ||
|
||
void tick(sfloat L, sfloat R) { | ||
sfloat parallelL = L; | ||
sfloat parallelR = R; | ||
|
||
for (int i = 0; i < _numActiveVoices; i++) { | ||
_delays[i]->tick(L, R); | ||
parallelL = _delays[i]->lastOutL(); | ||
parallelR = _delays[i]->lastOutR(); | ||
} | ||
|
||
_lastOutL = parallelL; | ||
_lastOutR = parallelR; | ||
} | ||
|
||
sfloat lastOutL() const { | ||
return _lastOutL; | ||
} | ||
|
||
sfloat lastOutR() const { | ||
return _lastOutR; | ||
} | ||
}; | ||
} | ||
|
Oops, something went wrong.