-
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.
Merge pull request #5 from lnd3/version-0.1.5
Upcoming version 0.1.5
- Loading branch information
Showing
65 changed files
with
6,485 additions
and
3,202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,8 @@ else() | |
meta | ||
memory | ||
math | ||
hid | ||
audio | ||
hid | ||
nodegraph | ||
|
||
concurrency | ||
|
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 |
---|---|---|
@@ -1,9 +1,95 @@ | ||
#pragma once | ||
|
||
#include "math/MathAll.h" | ||
|
||
#include <functional> | ||
|
||
namespace l::audio { | ||
|
||
class INoteProcessor { | ||
public: | ||
virtual ~INoteProcessor() = default; | ||
virtual void NoteOn(int32_t, int32_t = 127) {} | ||
virtual void NoteOff() {} | ||
virtual void NoteOff(int32_t) {} | ||
virtual void NoteSustain(bool) {} | ||
}; | ||
|
||
extern const float gNoNote_f; | ||
extern const int32_t gNoNote; | ||
float GetFrequencyFromNote(float note); | ||
double GetPhaseModifier(double note, double modifier); | ||
float BatchUpdate(float updateSamples, float samplesLeft, int32_t start, int32_t end, std::function<void()> update, std::function<void(int32_t, int32_t, bool)> process); | ||
|
||
int32_t GetAudioTicksFromMS(float ms, float sampleRate = 44100.0f); | ||
float GetMSFromAudioTicks(float numTicks, float sampleRate = 44100.0f); | ||
|
||
float GetRWAFactorFromMS(float numMS, float limit = 0.0001f, float rwaUpdateRate = 1.0f, float sampleRate = 44100.0f); | ||
float GetRWAFactorFromMSSkewed(float ms, float limit = 0.0001f, float rwaUpdateRate = 1.0f, float sampleRate = 44100.0f); | ||
|
||
|
||
float BatchUpdate(float updateSamples, float samplesLeft, int32_t start, int32_t end, std::function<float()> update, std::function<void(int32_t, int32_t, bool)> process); | ||
|
||
template<class T> | ||
class FilterRWA { | ||
public: | ||
|
||
FilterRWA() : | ||
mSmooth(static_cast<T>(0.005)), | ||
mValue(static_cast<T>(0)), | ||
mTargetValue(static_cast<T>(0)), | ||
mRWAUpdateRate(static_cast<T>(1.0)) | ||
{} | ||
~FilterRWA() = default; | ||
|
||
bool SnapAt(T value = static_cast<T>(0), T proximity = static_cast<T>(0.00001)) { | ||
if (l::math::functions::abs(mValue - value) < proximity) { | ||
mValue = value; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
FilterRWA<T>& SetConvergenceInMs(T convergenceInMS, T limit = static_cast<T>(0.0001), T sampleRate = static_cast<T>(44100.0)) { | ||
mSmooth = GetRWAFactorFromMS(convergenceInMS, limit, mRWAUpdateRate, sampleRate); | ||
return *this; | ||
} | ||
|
||
FilterRWA<T>& SetConvergenceFactor(T smooth = static_cast<T>(0.005)) { | ||
mSmooth = smooth; | ||
return *this; | ||
} | ||
|
||
FilterRWA<T>& SetConvergenceInTicks(T ticks, T limit = static_cast<T>(0.001)) { | ||
mSmooth = l::math::tween::GetRWAFactor(static_cast<int32_t>(ticks), limit); | ||
return *this; | ||
} | ||
|
||
FilterRWA<T>& SetRWAUpdateRate(T fetchesPerUpdate = static_cast<float>(1.0)) { | ||
mRWAUpdateRate = l::math::functions::max(fetchesPerUpdate, static_cast<float>(1.0)); | ||
return *this; | ||
} | ||
|
||
FilterRWA<T>& SetTarget(T target) { | ||
mTargetValue = target; | ||
return *this; | ||
} | ||
|
||
T Next() { | ||
mValue += mSmooth * (mTargetValue - mValue); | ||
return mValue; | ||
} | ||
|
||
T& Value() { | ||
return mValue; | ||
} | ||
|
||
protected: | ||
T mSmooth; | ||
T mValue; | ||
T mTargetValue; | ||
T mRWAUpdateRate; | ||
}; | ||
|
||
using FilterRWAFloat = FilterRWA<float>; | ||
|
||
} |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ set(deps | |
testing | ||
|
||
math | ||
audio | ||
) | ||
|
||
bs_generate_package(hid "tier1" "${deps}" "") |
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
Oops, something went wrong.