Package wellen.dsp
Class DSP
java.lang.Object
wellen.dsp.DSP
- All Implemented Interfaces:
AudioBufferRenderer
handles audio signal processing. after
start(...)
is called the processing continously calls
audioblock(...)
requesting blocks of audio samples.-
Field Summary
Modifier and TypeFieldDescriptionboolean
enable to create a copy of a cached buffer for each call toaudioblock(...)
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 processingstatic float
linear_to_decibel
(float linear_value) Converts a linear to a dB value.static void
pause
(boolean pause_state) pause or resume audio processingstatic float
sound_pressure_level
(float[] buffer) returns sound pressure level in decibel for given bufferstatic DSP
static DSP
static DSP
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
stop()
-
Field Details
-
COPY_CACHED_BUFFER
public boolean COPY_CACHED_BUFFERenable to create a copy of a cached buffer for each call toaudioblock(...)
. this is useful if the processing of the audio signal is not thread-safe.
-
-
Constructor Details
-
DSP
- Parameters:
callback
- object which implements theaudioblock(...)
methodnumber_of_output_channels
- number of output channelsnumber_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 intowidth
- visual width of the drawn bufferheight
- 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
- Parameters:
callback
- object which implements theaudioblock(...)
method- Returns:
- reference to DSP instance
-
start
- Parameters:
callback
- object which implements theaudioblock(...)
methodnumber_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 theaudioblock(...)
methodnumber_of_output_channels
- number of output channelsnumber_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 theaudioblock(...)
methodoutput_device_name
- name of output devicenumber_of_output_channels
- number of output channelsinput_device_name
- name of input devicenumber_of_input_channels
- number of input channelssampling_rate
- sampling rateaudio_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 theaudioblock(...)
methodoutput_device_ID
- output device ID as returned byWellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
number_of_output_channels
- number of output channelsinput_device_ID
- input device ID as returned byWellen.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 theaudioblock(...)
methodoutput_device_ID
- output device ID as returned byWellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
number_of_output_channels
- number of output channelsinput_device_ID
- input device ID as returned byWellen.queryAudioInputAndOutputDevices(String, boolean, boolean)
number_of_input_channels
- number of input channelssampling_rate
- sampling rateaudio_block_size
- audio block size- Returns:
- reference to DSP instance
-
start
- Parameters:
callback
- object which implements theaudioblock(...)
methodconfiguration
- 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 interfaceAudioBufferRenderer
- Parameters:
output_signal
- output signalinput_signal
- input signal
-