Package wellen.dsp

Class DSP

java.lang.Object
wellen.dsp.DSP
All Implemented Interfaces:
AudioBufferRenderer

public class DSP extends Object implements AudioBufferRenderer
handles audio signal processing. after start(...) is called the processing continously calls audioblock(...) requesting blocks of audio samples.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    enable to create a copy of a cached buffer for each call to audioblock(...).
  • Constructor Summary

    Constructors
    Constructor
    Description
    DSP(Object callback, int number_of_output_channels, int number_of_input_channels)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    audioblock(float[][] output_signal, float[][] input_signal)
     
    static float
    calculate_RMS(float[] buffer)
    Calculates and returns the root mean square of the signal.
    static void
    draw_buffers(processing.core.PGraphics g, float width, float height)
     
    static int
     
    static float[]
     
    static float[]
     
    static float[]
     
    static float[]
     
    static float[]
     
    static int
     
    static boolean
    querry the pause state of the audio processing
    static float
    linear_to_decibel(float linear_value)
    Converts a linear to a dB value.
    static void
    pause(boolean pause_state)
    pause or resume audio processing
    static float
    sound_pressure_level(float[] buffer)
    returns sound pressure level in decibel for given buffer
    static DSP
    start(Object callback)
     
    static DSP
    start(Object callback, int number_of_output_channels)
     
    static DSP
    start(Object callback, int number_of_output_channels, int number_of_input_channels)
     
    static DSP
    start(Object callback, int output_device_ID, int number_of_output_channels, int input_device_ID, int number_of_input_channels)
     
    static DSP
    start(Object callback, int output_device_ID, int number_of_output_channels, int input_device_ID, int number_of_input_channels, int sampling_rate, int audio_block_size)
     
    static DSP
    start(Object callback, String output_device_name, int number_of_output_channels, String input_device_name, int number_of_input_channels, int sampling_rate, int audio_block_size)
     
    static DSP
    start(Object callback, AudioDeviceConfiguration configuration)
     
    static void
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • COPY_CACHED_BUFFER

      public boolean COPY_CACHED_BUFFER
      enable to create a copy of a cached buffer for each call to audioblock(...). this is useful if the processing of the audio signal is not thread-safe.
  • Constructor Details

    • DSP

      public DSP(Object callback, int number_of_output_channels, int number_of_input_channels)
      Parameters:
      callback - object which implements the audioblock(...) method
      number_of_output_channels - number of output channels
      number_of_input_channels - number of input channels
  • Method Details

    • pause

      public static void pause(boolean pause_state)
      pause or resume audio processing
      Parameters:
      pause_state - true to pause audio processing, false to resume
    • is_paused

      public static boolean is_paused()
      querry the pause state of the audio processing
      Returns:
      true if audio processing is paused, false otherwise
    • calculate_RMS

      public static float calculate_RMS(float[] buffer)
      Calculates and returns the root mean square of the signal. Please cache the result since it is calculated every time.
      Parameters:
      buffer - The audio buffer to calculate the RMS for.
      Returns:
      The RMS of the signal present in the current buffer.
    • draw_buffers

      public static void draw_buffers(processing.core.PGraphics g, float width, float height)
      Parameters:
      g - graphics context to draw into
      width - visual width of the drawn buffer
      height - visual height of the drawn buffer
    • get_buffer_size

      public static int get_buffer_size()
      Returns:
      audio block or buffer size
    • get_input_buffer_left

      public static float[] get_input_buffer_left()
      Returns:
      reference to left input buffer
    • get_input_buffer_right

      public static float[] get_input_buffer_right()
      Returns:
      reference to right input buffer
    • get_output_buffer

      public static float[] get_output_buffer()
      Returns:
      reference to output buffer
    • get_output_buffer_left

      public static float[] get_output_buffer_left()
      Returns:
      reference to left output buffer
    • get_output_buffer_right

      public static float[] get_output_buffer_right()
      Returns:
      reference to right output buffer
    • get_sample_rate

      public static int get_sample_rate()
      Returns:
      sample rate
    • linear_to_decibel

      public static float linear_to_decibel(float linear_value)
      Converts a linear to a dB value.
      Parameters:
      linear_value - linear value to convert
      Returns:
      converted value in decibel
    • sound_pressure_level

      public static float sound_pressure_level(float[] buffer)
      returns sound pressure level in decibel for given buffer
      Parameters:
      buffer - buffer with signal
      Returns:
      level for buffer in decibel
    • start

      public static DSP start(Object callback)
      Parameters:
      callback - object which implements the audioblock(...) method
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, int number_of_output_channels)
      Parameters:
      callback - object which implements the audioblock(...) method
      number_of_output_channels - number of output channels
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, int number_of_output_channels, int number_of_input_channels)
      Parameters:
      callback - object which implements the audioblock(...) method
      number_of_output_channels - number of output channels
      number_of_input_channels - number of input channels
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, String output_device_name, int number_of_output_channels, String input_device_name, int number_of_input_channels, int sampling_rate, int audio_block_size)
      Parameters:
      callback - object which implements the audioblock(...) method
      output_device_name - name of output device
      number_of_output_channels - number of output channels
      input_device_name - name of input device
      number_of_input_channels - number of input channels
      sampling_rate - sampling rate
      audio_block_size - audio block size
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, int output_device_ID, int number_of_output_channels, int input_device_ID, int number_of_input_channels)
      Parameters:
      callback - object which implements the audioblock(...) method
      output_device_ID - output device ID as returned by Wellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
      number_of_output_channels - number of output channels
      input_device_ID - input device ID as returned by Wellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
      number_of_input_channels - number of input channels
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, int output_device_ID, int number_of_output_channels, int input_device_ID, int number_of_input_channels, int sampling_rate, int audio_block_size)
      Parameters:
      callback - object which implements the audioblock(...) method
      output_device_ID - output device ID as returned by Wellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
      number_of_output_channels - number of output channels
      input_device_ID - input device ID as returned by Wellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
      number_of_input_channels - number of input channels
      sampling_rate - sampling rate
      audio_block_size - audio block size
      Returns:
      reference to DSP instance
    • start

      public static DSP start(Object callback, AudioDeviceConfiguration configuration)
      Parameters:
      callback - object which implements the audioblock(...) method
      configuration - audio device configuration
      Returns:
      reference to DSP instance
    • stop

      public static void stop()
    • audioblock

      public void audioblock(float[][] output_signal, float[][] input_signal)
      Specified by:
      audioblock in interface AudioBufferRenderer
      Parameters:
      output_signal - output signal
      input_signal - input signal