类 WasapiBridge
java.lang.Object
wasapibridge.WasapiBridge
WASAPI_p5: A high-performance audio processing bridge for Windows WASAPI.
This library allows real-time capture of system audio for Processing (p5),
featuring FFT analysis, beat detection, and recording capabilities.
-
嵌套类概要
嵌套类 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明booleanbeginRecord(String path) Starts recording the system audio output to a WAV file.booleanStops the current recording session and finalizes the WAV file header.float[]getBands()Gets processed levels for three frequency bands: [Bass, Mid, Hi].voidgetBands(float[] out3) float[]getBeats()Gets real-time beat sizes: [Kick, Snare, Hat].float[]getFFT(int n) Gets the full FFT spectrum.intGets the current system sample rate.floatGets the overall RMS volume of the system audio.booleaninit()Initializes the WASAPI capture engine.voidsetBandSensitivity(float l, float m, float h) Sets the normalization threshold for Bass, Mid, and Hi bands.voidsetBeatSensitivity(float k, float s, float h) Sets the energy threshold for beat detection.voidsetGain(float gain) Sets a global multiplier for all returned audio values.voidstop()Stops the WASAPI capture engine and releases system resources.
-
构造器详细资料
-
WasapiBridge
public WasapiBridge()Constructs a new WasapiBridge instance. Automatically sets up JNA library paths to locate the native wasapi_bridge.dll.
-
-
方法详细资料
-
init
public boolean init()Initializes the WASAPI capture engine. This method must be called before using any audio data retrieval methods.- 返回:
- true if initialization was successful, false otherwise.
-
stop
public void stop()Stops the WASAPI capture engine and releases system resources. -
getVolume
public float getVolume()Gets the overall RMS volume of the system audio.- 返回:
- The current volume, typically in the range [0.0, 1.0].
-
getBands
public float[] getBands()Gets processed levels for three frequency bands: [Bass, Mid, Hi]. Normalization is controlled bysetBandSensitivity(float, float, float).- 返回:
- A float array of size 3.
-
getBands
public void getBands(float[] out3) -
getFFT
public float[] getFFT(int n) Gets the full FFT spectrum.- 参数:
n- The number of frequency bins to return (e.g., 512, 1024).- 返回:
- A float array of sized n containing the spectrum magnitudes.
-
beginRecord
Starts recording the system audio output to a WAV file.- 参数:
path- The absolute or relative path to the output .wav file.- 返回:
- true if recording started successfully.
-
endRecord
public boolean endRecord()Stops the current recording session and finalizes the WAV file header.- 返回:
- true if recording was stopped and finalized correctly.
-
setGain
public void setGain(float gain) Sets a global multiplier for all returned audio values.- 参数:
gain- The multiplier (default is 1.0).
-
setBeatSensitivity
public void setBeatSensitivity(float k, float s, float h) Sets the energy threshold for beat detection.- 参数:
k- Kick sensitivity (default ~1.5)s- Snare sensitivity (default ~1.6)h- Hat sensitivity (default ~1.5)
-
setBandSensitivity
public void setBandSensitivity(float l, float m, float h) Sets the normalization threshold for Bass, Mid, and Hi bands. Lower values make the bands more sensitive.- 参数:
l- Low (Bass) sensitivitym- Mid sensitivityh- High sensitivity
-
getBeats
public float[] getBeats()Gets real-time beat sizes: [Kick, Snare, Hat]. Values are 1.0 when a beat is triggered and decay rapidly to 0.- 返回:
- A float array of size 3.
-
getSampleRate
public int getSampleRate()Gets the current system sample rate.- 返回:
- The sample rate in Hz (e.g., 44100).
-