From be6bfb1a7f88f88b5a033427debfd262665a1f1f Mon Sep 17 00:00:00 2001 From: fgnm Date: Wed, 12 Jun 2024 08:32:23 +0200 Subject: [PATCH] test lpf reinit --- .../miniaudio/filter/MALowPassFilter.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/games/rednblack/miniaudio/filter/MALowPassFilter.java b/src/main/java/games/rednblack/miniaudio/filter/MALowPassFilter.java index 55a267e..19eb2dd 100644 --- a/src/main/java/games/rednblack/miniaudio/filter/MALowPassFilter.java +++ b/src/main/java/games/rednblack/miniaudio/filter/MALowPassFilter.java @@ -16,6 +16,8 @@ public class MALowPassFilter extends MANode { #include "miniaudio.h" */ + private final int order; + public MALowPassFilter(MiniAudio miniAudio, double cutoffFrequency, int order) { this(miniAudio, cutoffFrequency, order, -1); } @@ -24,6 +26,7 @@ public MALowPassFilter(MiniAudio miniAudio, double cutoffFrequency, int order, i super(miniAudio); address = jniCreateNode(miniAudio.getEngineAddress(), cutoffFrequency, order, customChannels); + this.order = order; if (MAResult.checkErrors(address)) { throw new MiniAudioException("Error while creating low pass filter node", (int) address); @@ -50,6 +53,22 @@ public MALowPassFilter(MiniAudio miniAudio, double cutoffFrequency, int order, i return (jlong) g_Node; */ + public void reinit(double cutoffFrequency) { + int result = jniReinitNode(miniAudio.getEngineAddress(), address, cutoffFrequency, order); + if (result != MAResult.MA_SUCCESS) { + throw new MiniAudioException("Unable reinit low pass filter", result); + } + } + + private native int jniReinitNode(long graphAddress, long nodeAddress, double cutoffFrequency, int order);/* + ma_engine* g_engine = (ma_engine*) graphAddress; + ma_lpf_node* g_Node = (ma_lpf_node*) nodeAddress; + + ma_lpf_config config = ma_lpf_config_init(g_Node->lpf.format, g_Node->lpf.channels, g_Node->lpf.sampleRate, cutoffFrequency, order); + + return ma_lpf_node_reinit(&config, g_Node); + */ + @Override public int getSupportedOutputs() { return 1;