Skip to content

Commit

Permalink
Deprecate things in dplug.dsp.fir, because it's not good enough.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Piolat committed Dec 12, 2024
1 parent 4ea18a1 commit ccc8729
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
4 changes: 2 additions & 2 deletions core/dplug/core/vec.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
Defines `Vec`, `reallocBuffer` and memory functions.
Copyright: Guillaume Piolat 2015-2016.
Copyright: Guillaume Piolat 2015-2024.
License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
Authors: Guillaume Piolat
*/
Expand Down Expand Up @@ -1070,7 +1070,7 @@ unittest
assert(ma._allocation == null);
}

// Should be valid to allocate nothing with a MergedAllocation.
// test stomping detection
unittest
{
MergedAllocation ma;
Expand Down
40 changes: 9 additions & 31 deletions dsp/dplug/dsp/fir.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import dplug.dsp.window;

// Basic sinc impulse functions

/// Generates a sinc lowpass impulse, centered on floor(output.length / 2).
// Generates a sinc lowpass impulse, centered on floor(output.length / 2).
deprecated("This will be removed in Dplug v16")
void generateLowpassImpulse(T)(T[] output, double cutoff, double samplerate) nothrow @nogc
{
checkFilterParams(output.length, cutoff, samplerate);
Expand All @@ -39,8 +40,9 @@ void generateLowpassImpulse(T)(T[] output, double cutoff, double samplerate) not
}
}

/// Generates a sinc highpass impulse, centered on floor(output.length / 2).
/// When convolved with, preserve amplitude of the pass-band.
// Generates a sinc highpass impulse, centered on floor(output.length / 2).
// When convolved with, preserve amplitude of the pass-band.
deprecated("This will be removed in Dplug v16")
void generateHighpassImpulse(T)(T[] output, double cutoff, double samplerate) nothrow @nogc
{
checkFilterParams(output.length, cutoff, samplerate);
Expand All @@ -58,7 +60,8 @@ void generateHighpassImpulse(T)(T[] output, double cutoff, double samplerate) no
}
}

/// Generates a hilbert transformer impulse, centered on floor(output.length / 2).
// Generates a hilbert transformer impulse, centered on floor(output.length / 2).
deprecated("This will be removed in Dplug v16")
void generateHilbertTransformer(T)(T[] outImpulse, WindowDesc windowDesc, double samplerate) nothrow @nogc
{
static bool isOdd(int i) pure nothrow @nogc @safe
Expand Down Expand Up @@ -103,25 +106,8 @@ private static void checkFilterParams(size_t length, double cutoff, double sampl
assert(cutoff * 2 < sampleRate, "2x the cutoff exceed sampling rate, Nyquist disapproving");
}

unittest
{
double[256] lp_impulse;
double[256] hp_impulse;
generateLowpassImpulse(lp_impulse[], 40.0, 44100.0);
generateHighpassImpulse(hp_impulse[], 40.0, 44100.0);
}

unittest
{
double[256] lp_impulse;
generateHilbertTransformer(lp_impulse[0..$-1],
WindowDesc(WindowType.blackmannHarris,
WindowAlignment.right), 44100.0);
}


// Composed of a delay-line, and an inpulse.
struct FIR(T)
// Composed of a delay-line, and an inpulse. It's a bad convolver.
deprecated("This will be removed in Dplug v16") struct FIR(T)
{
/// Initializes the FIR filter. It's up to you to fill the impulse with something worthwhile.
void initialize(int sizeOfImpulse) nothrow @nogc
Expand Down Expand Up @@ -181,11 +167,3 @@ private:
Delayline!T _delayline;
T[] _windowBuffer;
}

unittest
{
FIR!double fir;
fir.initialize(32);
generateLowpassImpulse(fir.impulse(), 40.0, 44100.0);
fir.applyWindow(WindowDesc(WindowType.hann, WindowAlignment.right));
}

0 comments on commit ccc8729

Please sign in to comment.