类 WasapiBridge

java.lang.Object
wasapibridge.WasapiBridge

public class WasapiBridge extends Object
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.
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static interface 
     
  • 构造器概要

    构造器
    构造器
    说明
    Constructs a new WasapiBridge instance.
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    Starts recording the system audio output to a WAV file.
    boolean
    Stops the current recording session and finalizes the WAV file header.
    float[]
    Gets processed levels for three frequency bands: [Bass, Mid, Hi].
    void
    getBands(float[] out3)
     
    float[]
    Gets real-time beat sizes: [Kick, Snare, Hat].
    float[]
    getFFT(int n)
    Gets the full FFT spectrum.
    int
    Gets the current system sample rate.
    float
    Gets the overall RMS volume of the system audio.
    boolean
    Initializes the WASAPI capture engine.
    void
    setBandSensitivity(float l, float m, float h)
    Sets the normalization threshold for Bass, Mid, and Hi bands.
    void
    setBeatSensitivity(float k, float s, float h)
    Sets the energy threshold for beat detection.
    void
    setGain(float gain)
    Sets a global multiplier for all returned audio values.
    void
    Stops the WASAPI capture engine and releases system resources.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • 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 by setBandSensitivity(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

      public boolean beginRecord(String path)
      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) sensitivity
      m - Mid sensitivity
      h - 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).