Skip to content

Commit

Permalink
test lpf reinit
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnm committed Jun 12, 2024
1 parent b7d507e commit be6bfb1
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit be6bfb1

Please sign in to comment.