From 0af51076202b8bf01d336722a64aee56541d5f9e Mon Sep 17 00:00:00 2001 From: Peter Sobot Date: Wed, 10 Jul 2024 17:28:33 -0400 Subject: [PATCH] Allow passing NumPy arrays as impulse responses to the Convolution plugin. (#352) * Allow passing NumPy arrays as impulse responses to the Convolution plugin. * Ol' Gil, can always trust ol' Gil. --- docs/_static/documentation_options.js | 2 +- docs/compatibility.html | 8 +- docs/examples.html | 8 +- docs/faq.html | 8 +- docs/genindex.html | 6 +- docs/index.html | 8 +- docs/internals.html | 8 +- docs/license.html | 8 +- docs/py-modindex.html | 6 +- docs/reference/pedalboard.html | 492 +++++++++++++------------- docs/reference/pedalboard.io.html | 142 ++++---- docs/search.html | 6 +- pedalboard/plugins/Convolution.h | 111 ++++-- pedalboard/version.py | 2 +- pedalboard_native/__init__.pyi | 21 +- tests/test_native_module.py | 45 ++- 16 files changed, 505 insertions(+), 376 deletions(-) diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 86111649..9ed35a64 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: 'v0.9.9', + VERSION: 'v0.9.10', LANGUAGE: 'en', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/compatibility.html b/docs/compatibility.html index fc286e36..6e460b1d 100644 --- a/docs/compatibility.html +++ b/docs/compatibility.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - Plugin Compatibility - Pedalboard v0.9.9 Documentation + Plugin Compatibility - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/faq.html b/docs/faq.html index e290c460..a2b6b59e 100644 --- a/docs/faq.html +++ b/docs/faq.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - Frequently Asked Questions - Pedalboard v0.9.9 Documentation + Frequently Asked Questions - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/genindex.html b/docs/genindex.html index 99030eb1..3c43d026 100644 --- a/docs/genindex.html +++ b/docs/genindex.html @@ -4,7 +4,7 @@ - Index - Pedalboard v0.9.9 Documentation + Index - Pedalboard v0.9.10 Documentation @@ -122,7 +122,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -148,7 +148,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/index.html b/docs/index.html index 047e5780..81b08abf 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/internals.html b/docs/internals.html index 99e7ba81..9175dbb6 100644 --- a/docs/internals.html +++ b/docs/internals.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - Pedalboard Internals - Pedalboard v0.9.9 Documentation + Pedalboard Internals - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/license.html b/docs/license.html index e82dd87b..b912f7c4 100644 --- a/docs/license.html +++ b/docs/license.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - License - Pedalboard v0.9.9 Documentation + License - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/py-modindex.html b/docs/py-modindex.html index 872ab958..f862aafd 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -4,7 +4,7 @@ - Python Module Index - Pedalboard v0.9.9 Documentation + Python Module Index - Pedalboard v0.9.10 Documentation @@ -122,7 +122,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -148,7 +148,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/docs/reference/pedalboard.html b/docs/reference/pedalboard.html index 2cabafe6..f70e8204 100644 --- a/docs/reference/pedalboard.html +++ b/docs/reference/pedalboard.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - The pedalboard API - Pedalboard v0.9.9 Documentation + The pedalboard API - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@
-
Pedalboard v0.9.9 Documentation
+
Pedalboard v0.9.10 Documentation
@@ -158,7 +158,7 @@
- Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation @@ -246,7 +246,7 @@

The pedalboard<

The following documentation lists all of the available types of Plugin.

-class pedalboard.AudioProcessorParameter(plugin: ExternalPlugin, parameter_name: str, search_steps: int = 1000)#
+class pedalboard.AudioProcessorParameter(plugin: ExternalPlugin, parameter_name: str, search_steps: int = 1000)#

A wrapper around various different parameters exposed by VST3Plugin or AudioUnitPlugin instances.

AudioProcessorParameter objects are rarely used directly, @@ -271,7 +271,7 @@

The pedalboard<

-property label: Optional[str]#
+property label: Optional[str]#

The units used by this parameter (Hz, dB, etc).

May be None if the plugin does not expose units for this parameter or if automatic unit detection fails.

@@ -279,7 +279,7 @@

The pedalboard<
-property units: Optional[str]#
+property units: Optional[str]#

Alias for โ€œlabelโ€ - the units used by this parameter (Hz, dB, etc).

May be None if the plugin does not expose units for this parameter or if automatic unit detection fails.

@@ -294,17 +294,17 @@

The pedalboard<

Donโ€™t use this directly; use one of pedalboard.VST3Plugin or pedalboard.AudioUnitPlugin instead.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
-__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
+__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

Run an audio or MIDI buffer through this plugin, returning audio. Alias for process().

-process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

Pass a buffer of audio (as a 32- or 64-bit NumPy array) or a list of MIDI messages to this plugin, returning audio.

(If calling this multiple times with multiple effect plugins, consider @@ -380,21 +380,21 @@

The pedalboard<
-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -402,7 +402,7 @@

The pedalboard<
-class pedalboard.Pedalboard(plugins: Optional[List[Plugin]] = None)#
+class pedalboard.Pedalboard(plugins: Optional[List[Plugin]] = None)#

A container for a series of Plugin objects, to use for processing audio, like a guitar pedalboard.

Pedalboard objects act like regular Python List objects, @@ -421,39 +421,39 @@

The pedalboard<
-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-append(plugin: Plugin) None#
+append(plugin: Plugin) None#

Append a plugin to the end of this container.

-insert(index: int, plugin: Plugin) None#
+insert(index: int, plugin: Plugin) None#

Insert a plugin at the specified index.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -481,13 +481,13 @@

The pedalboard<
-remove(plugin: Plugin) None#
+remove(plugin: Plugin) None#

Remove a plugin by its value.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -495,7 +495,7 @@

The pedalboard<
-pedalboard.load_plugin(path_to_plugin_file: str, parameter_values: Dict[str, Union[str, int, float, bool]] = {}, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0) ExternalPlugin#
+pedalboard.load_plugin(path_to_plugin_file: str, parameter_values: Dict[str, Union[str, int, float, bool]] = {}, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0) ExternalPlugin#

Load an audio plugin.

Two plugin formats are supported:
    @@ -539,7 +539,7 @@

    The pedalboard<
    -class pedalboard.AudioUnitPlugin(path_to_plugin_file: str, parameter_values: Optional[object] = None, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0)#
    +class pedalboard.AudioUnitPlugin(path_to_plugin_file: str, parameter_values: Optional[object] = None, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0)#

    A wrapper around third-party, audio effect or instrument plugins in Appleโ€™s Audio Unit format.

    @@ -562,24 +562,24 @@

    The pedalboard<

    Support for loading AUv3 plugins (``.appex`` bundles) introduced in v0.9.5.

    -__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
    +__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
    -__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
    +__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

    Run an audio or MIDI buffer through this plugin, returning audio. Alias for process().

    -static get_plugin_names_for_file(filename: str) list[str]#
    +static get_plugin_names_for_file(filename: str) list[str]#

    Return a list of plugin names contained within a given Audio Unit bundle (i.e.: a .component or .appex file). If the provided file cannot be scanned, an ImportError will be raised.

    Note that most Audio Units have a single plugin inside, but this method can be useful to determine if multiple plugins are present in one bundle, and if so, what their names are.

    -process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
    +process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
    -process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
    +process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

    Pass a buffer of audio (as a 32- or 64-bit NumPy array) or a list of MIDI messages to this plugin, returning audio.

    (If calling this multiple times with multiple effect plugins, consider @@ -655,7 +655,7 @@

    The pedalboard<
    -show_editor(close_event: Optional[Event] = None) None#
    +show_editor(close_event: Optional[Event] = None) None#

    Show the UI of this plugin as a native window.

    This method may only be called on the main thread, and will block the main thread until any of the following things happens:

    @@ -664,8 +664,8 @@

    The pedalboard<
  • the window is closed by clicking the close button

  • the window is closed by pressing the appropriate (OS-specific) keyboard shortcut

  • a KeyboardInterrupt (Ctrl-C) is sent to the program

  • -
  • the threading.Event.set() method is called (by another thread) -on a provided threading.Event object

  • +
  • the threading.Event.set() method is called (by another thread) +on a provided threading.Event object

An example of how to programmatically close an editor window:

@@ -691,57 +691,57 @@

The pedalboard<
-property category: str#
+property category: str#

A category that this plugin falls into, such as โ€œDynamicsโ€, โ€œReverbsโ€, etc.

Introduced in v0.9.4.

-property descriptive_name: str#
+property descriptive_name: str#

A more descriptive name for this plugin. This may be the same as the โ€˜nameโ€™ field, but some plugins may provide an alternative name.

Introduced in v0.9.4.

-property has_shared_container: bool#
+property has_shared_container: bool#

True iff this plugin is part of a multi-plugin container.

Introduced in v0.9.4.

-property identifier: str#
+property identifier: str#

A string that can be saved and used to uniquely identify this plugin (and version) again.

Introduced in v0.9.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin identifies itself as an instrument (generator, synthesizer, etc) plugin.

Introduced in v0.9.4.

-property manufacturer_name: str#
+property manufacturer_name: str#

The name of the manufacturer of this plugin, as reported by the plugin itself.

Introduced in v0.9.4.

-property name: str#
+property name: str#

The name of this plugin.

-property raw_state: bytes#
-

A bytes object representing the pluginโ€™s internal state.

-

For the Audio Unit format, this is usually a binary property list that can be decoded or encoded with the built-in plistlib package.

+property raw_state: bytes# +

A bytes object representing the pluginโ€™s internal state.

+

For the Audio Unit format, this is usually a binary property list that can be decoded or encoded with the built-in plistlib package.

Warning

This property can be set to change the pluginโ€™s internal state, but providing invalid data may cause the plugin to crash, taking the entire Python process down with it.

@@ -750,21 +750,21 @@

The pedalboard<
-property version: str#
+property version: str#

The version string for this plugin, as reported by the plugin itself.

Introduced in v0.9.4.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -772,38 +772,38 @@

The pedalboard<
-class pedalboard.Bitcrush(bit_depth: float = 8)#
+class pedalboard.Bitcrush(bit_depth: float = 8)#

A plugin that reduces the signal to a given bit depth, giving the audio a lo-fi, digitized sound. Floating-point bit depths are supported.

Bitcrushing changes the amount of โ€œverticalโ€ resolution used for an audio signal (i.e.: how many unique values could be used to represent each sample). For an effect that changes the โ€œhorizontalโ€ resolution (i.e.: how many samples are available per second), see pedalboard.Resample.

-property bit_depth: float#
+property bit_depth: float#

The bit depth to quantize the signal to. Must be between 0 and 32 bits. May be an integer, decimal, or floating-point value. Each audio sample will be quantized onto 2 ** bit_depth values.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -831,7 +831,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -839,43 +839,43 @@

The pedalboard<
-class pedalboard.Chain(plugins: list[Plugin])#
+class pedalboard.Chain(plugins: list[Plugin])#

Run zero or more plugins as a plugin. Useful when used with the Mix plugin.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-append(plugin: Plugin) None#
+append(plugin: Plugin) None#

Append a plugin to the end of this container.

-insert(index: int, plugin: Plugin) None#
+insert(index: int, plugin: Plugin) None#

Insert a plugin at the specified index.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -903,13 +903,13 @@

The pedalboard<
-remove(plugin: Plugin) None#
+remove(plugin: Plugin) None#

Remove a plugin by its value.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -917,39 +917,39 @@

The pedalboard<
-class pedalboard.Chorus(rate_hz: float = 1.0, depth: float = 0.25, centre_delay_ms: float = 7.0, feedback: float = 0.0, mix: float = 0.5)#
+class pedalboard.Chorus(rate_hz: float = 1.0, depth: float = 0.25, centre_delay_ms: float = 7.0, feedback: float = 0.0, mix: float = 0.5)#

A basic chorus effect.

This audio effect can be controlled via the speed and depth of the LFO controlling the frequency response, a mix control, a feedback control, and the centre delay of the modulation.

Note: To get classic chorus sounds try to use a centre delay time around 7-8 ms with a low feeback volume and a low depth. This effect can also be used as a flanger with a lower centre delay time and a lot of feedback, and as a vibrato effect if the mix value is 1.

-property rate_hz: float#
+property rate_hz: float#

The speed of the chorus effectโ€™s low-frequency oscillator (LFO), in Hertz. This value must be between 0 Hz and 100 Hz.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -977,7 +977,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -985,31 +985,31 @@

The pedalboard<
-class pedalboard.Clipping(threshold_db: float = -6.0)#
+class pedalboard.Clipping(threshold_db: float = -6.0)#

A distortion plugin that adds hard distortion to the signal by clipping the signal at the provided threshold (in decibels).

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1037,7 +1037,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1045,32 +1045,32 @@

The pedalboard<
-class pedalboard.Compressor(threshold_db: float = 0, ratio: float = 1, attack_ms: float = 1.0, release_ms: float = 100)#
+class pedalboard.Compressor(threshold_db: float = 0, ratio: float = 1, attack_ms: float = 1.0, release_ms: float = 100)#

A dynamic range compressor, used to reduce the volume of loud sounds and โ€œcompressโ€ the loudness of the signal.

For a lossy compression algorithm that introduces noise or artifacts, see pedalboard.MP3Compressor or pedalboard.GSMCompressor.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1098,7 +1098,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1106,31 +1106,33 @@

The pedalboard<
-class pedalboard.Convolution(impulse_response_filename: str, mix: float = 1.0)#
+class pedalboard.Convolution(impulse_response_filename: Union[str, ndarray[Any, dtype[float32]]], mix: float = 1.0, sample_rate: Optional[float] = None)#

An audio convolution, suitable for things like speaker simulation or reverb modeling.

+

The convolution impulse response can be specified either by filename or as a 32-bit floating point NumPy array. If a NumPy array is provided, the sample_rate argument must also be provided to indicate the sample rate of the impulse response.

+

Support for passing NumPy arrays as impulse responses introduced in v0.9.10.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1158,7 +1160,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1166,31 +1168,31 @@

The pedalboard<
-class pedalboard.Delay(delay_seconds: float = 0.5, feedback: float = 0.0, mix: float = 0.5)#
+class pedalboard.Delay(delay_seconds: float = 0.5, feedback: float = 0.0, mix: float = 0.5)#

A digital delay plugin with controllable delay time, feedback percentage, and dry/wet mix.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1218,7 +1220,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1226,32 +1228,32 @@

The pedalboard<
-class pedalboard.Distortion(drive_db: float = 25)#
+class pedalboard.Distortion(drive_db: float = 25)#

A distortion effect, which applies a non-linear (tanh, or hyperbolic tangent) waveshaping function to apply harmonically pleasing distortion to a signal.

This plugin produces a signal that is roughly equivalent to running: def distortion(x): return tanh(x * db_to_gain(drive_db))

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1279,7 +1281,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1291,27 +1293,27 @@

The pedalboard<

An audio degradation/compression plugin that applies the GSM โ€œFull Rateโ€ compression algorithm to emulate the sound of a 2G cellular phone connection. This plugin internally resamples the input audio to a fixed sample rate of 8kHz (required by the GSM Full Rate codec), although the quality of the resampling algorithm can be specified.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1339,7 +1341,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1347,32 +1349,32 @@

The pedalboard<
-class pedalboard.Gain(gain_db: float = 1.0)#
+class pedalboard.Gain(gain_db: float = 1.0)#

A gain plugin that increases or decreases the volume of a signal by amplifying or attenuating it by the provided value (in decibels). No distortion or other effects are applied.

Think of this as a volume control.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1400,7 +1402,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1408,31 +1410,31 @@

The pedalboard<
-class pedalboard.HighShelfFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#
+class pedalboard.HighShelfFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#

A high shelf filter plugin with variable Q and gain, as would be used in an equalizer. Frequencies above the cutoff frequency will be boosted (or cut) by the provided gain (in decibels).

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1460,7 +1462,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1468,31 +1470,31 @@

The pedalboard<
-class pedalboard.HighpassFilter(cutoff_frequency_hz: float = 50)#
+class pedalboard.HighpassFilter(cutoff_frequency_hz: float = 50)#

Apply a first-order high-pass filter with a roll-off of 6dB/octave. The cutoff frequency will be attenuated by -3dB (i.e.: \(\frac{1}{\sqrt{2}}\) as loud, expressed as a gain factor) and lower frequencies will be attenuated by a further 6dB per octave.)

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1520,7 +1522,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1532,27 +1534,27 @@

The pedalboard<

An abstract class that implements various kinds of infinite impulse response (IIR) filter designs. This should not be used directly; use HighShelfFilter, LowShelfFilter, or PeakFilter directly instead.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1580,7 +1582,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1593,27 +1595,27 @@

The pedalboard<

Inverting a signal may be useful to cancel out signals in many cases; for instance, Invert can be used with the Mix plugin to remove the original signal from an effects chain that contains multiple signals.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1641,7 +1643,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1649,7 +1651,7 @@

The pedalboard<
-class pedalboard.LadderFilter(mode: Mode = Mode.LPF12, cutoff_hz: float = 200, resonance: float = 0, drive: float = 1.0)#
+class pedalboard.LadderFilter(mode: Mode = Mode.LPF12, cutoff_hz: float = 200, resonance: float = 0, drive: float = 1.0)#

A multi-mode audio filter based on the classic Moog synthesizer ladder filter, invented by Dr. Bob Moog in 1968.

Depending on the filterโ€™s mode, frequencies above, below, or on both sides of the cutoff frequency will be attenuated. Higher values for the resonance parameter may cause peaks in the frequency response around the cutoff frequency.

@@ -1696,27 +1698,27 @@

The pedalboard<
-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1744,7 +1746,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1752,31 +1754,31 @@

The pedalboard<
-class pedalboard.Limiter(threshold_db: float = -10.0, release_ms: float = 100.0)#
+class pedalboard.Limiter(threshold_db: float = -10.0, release_ms: float = 100.0)#

A simple limiter with standard threshold and release time controls, featuring two compressors and a hard clipper at 0 dB.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1804,7 +1806,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1812,31 +1814,31 @@

The pedalboard<
-class pedalboard.LowShelfFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#
+class pedalboard.LowShelfFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#

A low shelf filter with variable Q and gain, as would be used in an equalizer. Frequencies below the cutoff frequency will be boosted (or cut) by the provided gain value.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1864,7 +1866,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1872,31 +1874,31 @@

The pedalboard<
-class pedalboard.LowpassFilter(cutoff_frequency_hz: float = 50)#
+class pedalboard.LowpassFilter(cutoff_frequency_hz: float = 50)#

Apply a first-order low-pass filter with a roll-off of 6dB/octave. The cutoff frequency will be attenuated by -3dB (i.e.: 0.707x as loud).

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1924,7 +1926,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1932,33 +1934,33 @@

The pedalboard<
-class pedalboard.MP3Compressor(vbr_quality: float = 2.0)#
+class pedalboard.MP3Compressor(vbr_quality: float = 2.0)#

An MP3 compressor plugin that runs the LAME MP3 encoder in real-time to add compression artifacts to the audio stream.

Currently only supports variable bit-rate mode (VBR) and accepts a floating-point VBR quality value (between 0.0 and 10.0; lower is better).

Note that the MP3 format only supports 32kHz, 44.1kHz, and 48kHz audio; if an unsupported sample rate is provided, an exception will be thrown at processing time.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -1986,7 +1988,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -1994,43 +1996,43 @@

The pedalboard<
-class pedalboard.Mix(plugins: list[Plugin])#
+class pedalboard.Mix(plugins: list[Plugin])#

A utility plugin that allows running other plugins in parallel. All plugins provided will be mixed equally.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-append(plugin: Plugin) None#
+append(plugin: Plugin) None#

Append a plugin to the end of this container.

-insert(index: int, plugin: Plugin) None#
+insert(index: int, plugin: Plugin) None#

Insert a plugin at the specified index.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2058,13 +2060,13 @@

The pedalboard<
-remove(plugin: Plugin) None#
+remove(plugin: Plugin) None#

Remove a plugin by its value.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2072,31 +2074,31 @@

The pedalboard<
-class pedalboard.NoiseGate(threshold_db: float = -100.0, ratio: float = 10, attack_ms: float = 1.0, release_ms: float = 100.0)#
+class pedalboard.NoiseGate(threshold_db: float = -100.0, ratio: float = 10, attack_ms: float = 1.0, release_ms: float = 100.0)#

A simple noise gate with standard threshold, ratio, attack time and release time controls. Can be used as an expander if the ratio is low.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2124,7 +2126,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2132,31 +2134,31 @@

The pedalboard<
-class pedalboard.PeakFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#
+class pedalboard.PeakFilter(cutoff_frequency_hz: float = 440, gain_db: float = 0.0, q: float = 0.7071067690849304)#

A peak (or notch) filter with variable Q and gain, as would be used in an equalizer. Frequencies around the cutoff frequency will be boosted (or cut) by the provided gain value.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2184,7 +2186,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2192,31 +2194,31 @@

The pedalboard<
-class pedalboard.Phaser(rate_hz: float = 1.0, depth: float = 0.5, centre_frequency_hz: float = 1300.0, feedback: float = 0.0, mix: float = 0.5)#
+class pedalboard.Phaser(rate_hz: float = 1.0, depth: float = 0.5, centre_frequency_hz: float = 1300.0, feedback: float = 0.0, mix: float = 0.5)#

A 6 stage phaser that modulates first order all-pass filters to create sweeping notches in the magnitude frequency response. This audio effect can be controlled with standard phaser parameters: the speed and depth of the LFO controlling the frequency response, a mix control, a feedback control, and the centre frequency of the modulation.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2244,7 +2246,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2252,32 +2254,32 @@

The pedalboard<
-class pedalboard.PitchShift(semitones: float = 0.0)#
+class pedalboard.PitchShift(semitones: float = 0.0)#

A pitch shifting effect that can change the pitch of audio without affecting its duration.

This effect uses Chris Cannamโ€™s wonderful *Rubber Band* library audio stretching library.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2305,7 +2307,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2317,13 +2319,13 @@

The pedalboard<

A generic audio processing plugin. Base class of all Pedalboard plugins.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2351,20 +2353,20 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

@@ -2373,49 +2375,49 @@

The pedalboard<
-class pedalboard.PluginContainer(plugins: list[Plugin])#
+class pedalboard.PluginContainer(plugins: list[Plugin])#

A generic audio processing plugin that contains zero or more other plugins. Not intended for direct use.

-append(plugin: Plugin) None#
+append(plugin: Plugin) None#

Append a plugin to the end of this container.

-insert(index: int, plugin: Plugin) None#
+insert(index: int, plugin: Plugin) None#

Insert a plugin at the specified index.

-remove(plugin: Plugin) None#
+remove(plugin: Plugin) None#

Remove a plugin by its value.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2443,7 +2445,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2451,7 +2453,7 @@

The pedalboard<
-class pedalboard.Resample(target_sample_rate: float = 8000.0, quality: Quality = Quality.WindowedSinc)#
+class pedalboard.Resample(target_sample_rate: float = 8000.0, quality: Quality = Quality.WindowedSinc)#

A plugin that downsamples the input audio to the given sample rate, then upsamples it back to the original sample rate. Various quality settings will produce audible distortion and aliasing effects.

@@ -2491,27 +2493,27 @@

The pedalboard<
-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2539,7 +2541,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2551,7 +2553,7 @@

The pedalboard<
-property target_sample_rate: float#
+property target_sample_rate: float#

The sample rate to resample the input audio to. This value may be a floating-point number, in which case a floating-point sampling rate will be used. Note that the output of this plugin will still be at the original sample rate; this is merely the sample rate used for quality reduction.

@@ -2559,31 +2561,31 @@

The pedalboard<
-class pedalboard.Reverb(room_size: float = 0.5, damping: float = 0.5, wet_level: float = 0.33, dry_level: float = 0.4, width: float = 1.0, freeze_mode: float = 0.0)#
+class pedalboard.Reverb(room_size: float = 0.5, damping: float = 0.5, wet_level: float = 0.33, dry_level: float = 0.4, width: float = 1.0, freeze_mode: float = 0.0)#

A simple reverb effect. Uses a simple stereo reverb algorithm, based on the technique and tunings used in FreeVerb <https://ccrma.stanford.edu/~jos/pasp/Freeverb.html>_.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run an audio buffer through this plugin. Alias for process().

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-property is_instrument: bool#
+property is_instrument: bool#

True iff this plugin is not an audio effect and accepts only MIDI input, not audio.

Introduced in v0.7.4.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#

Run a 32-bit or 64-bit floating point audio buffer through this plugin. (If calling this multiple times with multiple plugins, consider creating a pedalboard.Pedalboard object instead.)

@@ -2611,7 +2613,7 @@

The pedalboard<
-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

@@ -2619,7 +2621,7 @@

The pedalboard<
-class pedalboard.VST3Plugin(path_to_plugin_file: str, parameter_values: Optional[object] = None, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0)#
+class pedalboard.VST3Plugin(path_to_plugin_file: str, parameter_values: Optional[object] = None, plugin_name: Optional[str] = None, initialization_timeout: float = 10.0)#

A wrapper around third-party, audio effect or instrument plugins in Steinberg GmbHโ€™s VST3ยฎ format.

@@ -2638,42 +2640,42 @@

The pedalboard<

Support for running VST3ยฎ plugins on background threads introduced in v0.8.8.

-property is_effect: bool#
+property is_effect: bool#

True iff this plugin is an audio effect and accepts audio as input.

Introduced in v0.7.4.

-reset() None#
+reset() None#

Clear any internal state stored by this plugin (e.g.: reverb tails, delay lines, LFO state, etc). The values of plugin parameters will remain unchanged.

-__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+__call__(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
-__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
+__call__(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

Run an audio or MIDI buffer through this plugin, returning audio. Alias for process().

-static get_plugin_names_for_file(arg0: str) list[str]#
+static get_plugin_names_for_file(arg0: str) list[str]#

Return a list of plugin names contained within a given VST3 plugin (i.e.: a โ€œ.vst3โ€). If the provided file cannot be scanned, an ImportError will be raised.

-load_preset(preset_file_path: str) None#
+load_preset(preset_file_path: str) None#

Load a VST3 preset file in .vstpreset format.

-process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
+process(input_array: ndarray, sample_rate: float, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]#
-process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]
+process(midi_messages: object, duration: float, sample_rate: float, num_channels: int = 2, buffer_size: int = 8192, reset: bool = True) ndarray[Any, dtype[float32]]

Pass a buffer of audio (as a 32- or 64-bit NumPy array) or a list of MIDI messages to this plugin, returning audio.

(If calling this multiple times with multiple effect plugins, consider @@ -2749,7 +2751,7 @@

The pedalboard<
-show_editor(close_event: Optional[Event] = None) None#
+show_editor(close_event: Optional[Event] = None) None#

Show the UI of this plugin as a native window.

This method may only be called on the main thread, and will block the main thread until any of the following things happens:

@@ -2758,8 +2760,8 @@

The pedalboard<
  • the window is closed by clicking the close button

  • the window is closed by pressing the appropriate (OS-specific) keyboard shortcut

  • a KeyboardInterrupt (Ctrl-C) is sent to the program

  • -
  • the threading.Event.set() method is called (by another thread) -on a provided threading.Event object

  • +
  • the threading.Event.set() method is called (by another thread) +on a provided threading.Event object

  • An example of how to programmatically close an editor window:

    @@ -2785,56 +2787,56 @@

    The pedalboard<
    -property category: str#
    +property category: str#

    A category that this plugin falls into, such as โ€œDynamicsโ€, โ€œReverbsโ€, etc.

    Introduced in v0.9.4.

    -property descriptive_name: str#
    +property descriptive_name: str#

    A more descriptive name for this plugin. This may be the same as the โ€˜nameโ€™ field, but some plugins may provide an alternative name.

    Introduced in v0.9.4.

    -property has_shared_container: bool#
    +property has_shared_container: bool#

    True iff this plugin is part of a multi-plugin container.

    Introduced in v0.9.4.

    -property identifier: str#
    +property identifier: str#

    A string that can be saved and used to uniquely identify this plugin (and version) again.

    Introduced in v0.9.4.

    -property is_instrument: bool#
    +property is_instrument: bool#

    True iff this plugin identifies itself as an instrument (generator, synthesizer, etc) plugin.

    Introduced in v0.9.4.

    -property manufacturer_name: str#
    +property manufacturer_name: str#

    The name of the manufacturer of this plugin, as reported by the plugin itself.

    Introduced in v0.9.4.

    -property name: str#
    +property name: str#

    The name of this plugin.

    -property raw_state: bytes#
    -

    A bytes object representing the pluginโ€™s internal state.

    +property raw_state: bytes# +

    A bytes object representing the pluginโ€™s internal state.

    For the VST3 format, this is usually an XML-encoded string prefixed with an 8-byte header and suffixed with a single null byte.

    Warning

    @@ -2844,7 +2846,7 @@

    The pedalboard<
    -property version: str#
    +property version: str#

    The version string for this plugin, as reported by the plugin itself.

    Introduced in v0.9.4.

    @@ -2853,7 +2855,7 @@

    The pedalboard<
    -pedalboard.time_stretch(input_audio: ndarray[Any, dtype[float32]], samplerate: float, stretch_factor: Union[float, ndarray[Any, dtype[float64]]] = 1.0, pitch_shift_in_semitones: Union[float, ndarray[Any, dtype[float64]]] = 0.0, high_quality: bool = True, transient_mode: str = 'crisp', transient_detector: str = 'compound', retain_phase_continuity: bool = True, use_long_fft_window: Optional[bool] = None, use_time_domain_smoothing: bool = False, preserve_formants: bool = True) ndarray[Any, dtype[float32]]#
    +pedalboard.time_stretch(input_audio: ndarray[Any, dtype[float32]], samplerate: float, stretch_factor: Union[float, ndarray[Any, dtype[float64]]] = 1.0, pitch_shift_in_semitones: Union[float, ndarray[Any, dtype[float64]]] = 0.0, high_quality: bool = True, transient_mode: str = 'crisp', transient_detector: str = 'compound', retain_phase_continuity: bool = True, use_long_fft_window: Optional[bool] = None, use_time_domain_smoothing: bool = False, preserve_formants: bool = True) ndarray[Any, dtype[float32]]#

    Time-stretch (and optionally pitch-shift) a buffer of audio, changing its length.

    Using a higher stretch_factor will shorten the audio - i.e., a stretch_factor of 2.0 will double the speed of the audio and halve the length of the audio, diff --git a/docs/reference/pedalboard.io.html b/docs/reference/pedalboard.io.html index b85da55a..f5fa40d0 100644 --- a/docs/reference/pedalboard.io.html +++ b/docs/reference/pedalboard.io.html @@ -6,7 +6,7 @@ - + @@ -14,7 +14,7 @@ - The pedalboard.io API - Pedalboard v0.9.9 Documentation + The pedalboard.io API - Pedalboard v0.9.10 Documentation @@ -132,7 +132,7 @@

    @@ -158,7 +158,7 @@
    - Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation @@ -250,13 +250,13 @@

    The pedalboard.

    The following documentation lists all of the available I/O classes.

    -class pedalboard.io.AudioFile(filename: str, mode: Literal['r'] = 'r')#
    +class pedalboard.io.AudioFile(filename: str, mode: Literal['r'] = 'r')#
    -class pedalboard.io.AudioFile(file_like: Union[BinaryIO, memoryview], mode: Literal['r'] = 'r')
    +class pedalboard.io.AudioFile(file_like: Union[BinaryIO, memoryview], mode: Literal['r'] = 'r')
    -class pedalboard.io.AudioFile(filename: str, mode: Literal['w'], samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None)
    +class pedalboard.io.AudioFile(filename: str, mode: Literal['w'], samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None)
    -class pedalboard.io.AudioFile(file_like: BinaryIO, mode: Literal['w'], samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None, format: Optional[str] = None)
    +class pedalboard.io.AudioFile(file_like: BinaryIO, mode: Literal['w'], samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None, format: Optional[str] = None)

    A base class for readable and writeable audio files.

    AudioFile may be used just like a regular Python open function call, to open an audio file for reading (with the default "r" mode) @@ -271,7 +271,7 @@

    The pedalboard.
  • A file-like object can be provided to AudioFile, allowing for reading and writing to in-memory streams or buffers. The provided file-like object must be seekable and must be opened in binary mode (i.e.: io.BytesIO instead of io.StringIO). -A memoryview object may also be provided when reading audio.

  • +A memoryview object may also be provided when reading audio.

    @@ -304,7 +304,7 @@

    The pedalboard. wav_buffer.getvalue() # do something with the file-like object

    -

    Encoding audio as wav, ogg, mp3, or flac as a bytes buffer in one line:

    +

    Encoding audio as wav, ogg, mp3, or flac as a bytes buffer in one line:

    sr = 44100
     num_channels = 2
     audio = np.random.rand(num_channels, sr)
    @@ -343,9 +343,9 @@ 

    The pedalboard.

    -static encode(samples: ndarray, samplerate: float, format: str, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None) bytes#
    -

    Encode an audio buffer to a Python bytes object.

    -

    This function will encode an entire audio buffer at once and return a bytes +static encode(samples: ndarray, samplerate: float, format: str, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None) bytes# +

    Encode an audio buffer to a Python bytes object.

    +

    This function will encode an entire audio buffer at once and return a bytes object representing the bytes of the resulting audio file.

    This function produces identical output to the following code:

    buf = io.BytesIO()
    @@ -373,7 +373,7 @@ 

    The pedalboard.
    -class pedalboard.io.AudioStream(input_device_name: str, output_device_name: str, plugins: Optional[Chain] = None, sample_rate: Optional[float] = None, buffer_size: int = 512, allow_feedback: bool = False)#
    +class pedalboard.io.AudioStream(input_device_name: str, output_device_name: str, plugins: Optional[Chain] = None, sample_rate: Optional[float] = None, buffer_size: int = 512, allow_feedback: bool = False)#

    A class that streams audio from an input audio device (i.e.: a microphone, audio interface, etc) to an output device (speaker, headphones), passing it through a pedalboard.Pedalboard to add effects.

    @@ -420,7 +420,7 @@

    The pedalboard. not in scope, etc), the audio stream will continue to play back forever, and wonโ€™t stop until the Python interpreter exits.

    To run an AudioStream in the background, use Pythonโ€™s -threading module to call the synchronous run() method on a +threading module to call the synchronous run() method on a background thread, allowing for easier cleanup.

    Introduced in v0.7.0. Not supported on Linux.

    @@ -432,14 +432,14 @@

    The pedalboard.
    -__exit__(arg0: object, arg1: object, arg2: object) None#
    +__exit__(arg0: object, arg1: object, arg2: object) None#

    Exit the context manager, ending the audio stream. Once called, the audio stream will be stopped (i.e.: running will be False).

    -run() None#
    -

    Start streaming audio from input to output, passing the audio stream through the plugins on this AudioStream object. This call will block the current thread until a KeyboardInterrupt (Ctrl-C) is received.

    +run() None# +

    Start streaming audio from input to output, passing the audio stream through the plugins on this AudioStream object. This call will block the current thread until a KeyboardInterrupt (Ctrl-C) is received.

    @@ -450,7 +450,7 @@

    The pedalboard.
    -property running: bool#
    +property running: bool#

    True if this stream is currently streaming live audio from input to output, False otherwise.

    @@ -458,9 +458,9 @@

    The pedalboard.
    -class pedalboard.io.ReadableAudioFile(filename: str)#
    +class pedalboard.io.ReadableAudioFile(filename: str)#
    -class pedalboard.io.ReadableAudioFile(file_like: Union[BinaryIO, memoryview])
    +class pedalboard.io.ReadableAudioFile(file_like: Union[BinaryIO, memoryview])

    A class that wraps an audio file for reading, with native support for Ogg Vorbis, MP3, WAV, FLAC, and AIFF files on all operating systems. Other formats may also be readable depending on the operating system and installed system libraries:

    @@ -497,19 +497,19 @@

    The pedalboard.
    -__exit__(arg0: object, arg1: object, arg2: object) None#
    +__exit__(arg0: object, arg1: object, arg2: object) None#

    Stop using this ReadableAudioFile as a context manager, close the file, release its resources.

    -close() None#
    +close() None#

    Close this file, rendering this object unusable.

    -read(num_frames: Union[float, int] = 0) ndarray[Any, dtype[float32]]#
    +read(num_frames: Union[float, int] = 0) ndarray[Any, dtype[float32]]#

    Read the given number of frames (samples in each channel) from this audio file at its current position.

    num_frames is a required argument, as audio files can be deceptively large. (Consider that an hour-long .ogg file may be only a handful of megabytes on disk, but may decompress to @@ -535,7 +535,7 @@

    The pedalboard.
    -read_raw(num_frames: Union[float, int] = 0) ndarray#
    +read_raw(num_frames: Union[float, int] = 0) ndarray#

    Read the given number of frames (samples in each channel) from this audio file at its current position.

    num_frames is a required argument, as audio files can be deceptively large. (Consider that an hour-long .ogg file may be only a handful of megabytes on disk, but may decompress to @@ -560,7 +560,7 @@

    The pedalboard.
    -resampled_to(target_sample_rate: float, quality: Quality = Quality.WindowedSinc) Union[ReadableAudioFile, ResampledReadableAudioFile]#
    +resampled_to(target_sample_rate: float, quality: Quality = Quality.WindowedSinc) Union[ReadableAudioFile, ResampledReadableAudioFile]#

    Return a ResampledReadableAudioFile that will automatically resample this ReadableAudioFile to the provided target_sample_rate, using a constant amount of memory.

    If target_sample_rate matches the existing sample rate of the file, the original file will be returned.

    Introduced in v0.6.0.

    @@ -568,31 +568,31 @@

    The pedalboard.
    -seek(position: int) None#
    +seek(position: int) None#

    Seek this file to the provided location in frames. Future reads will start from this position.

    -seekable() bool#
    +seekable() bool#

    Returns True if this file is currently open and calls to seek() will work.

    -tell() int#
    +tell() int#

    Return the current position of the read pointer in this audio file, in frames. This value will increase as read() is called, and may decrease if seek() is called.

    -property closed: bool#
    +property closed: bool#

    True iff this file is closed (and no longer usable), False otherwise.

    -property duration: float#
    +property duration: float#

    The duration of this file in seconds (frames divided by samplerate).

    Warning

    @@ -605,7 +605,7 @@

    The pedalboard.
    -property exact_duration_known: bool#
    +property exact_duration_known: bool#

    Returns True if this fileโ€™s frames and duration attributes are exact values, or False if the frames and duration attributes are estimates based @@ -625,14 +625,14 @@

    The pedalboard.
    -property file_dtype: str#
    +property file_dtype: str#

    The data type ("int16", "float32", etc) stored natively by this file.

    Note that read() will always return a float32 array, regardless of the value of this property. Use read_raw() to read data from the file in its file_dtype.

    -property frames: int#
    +property frames: int#

    The total number of frames (samples per channel) in this file.

    For example, if this file contains 10 seconds of stereo audio at sample rate of 44,100 Hz, frames will return 441,000.

    @@ -674,20 +674,20 @@

    The pedalboard.
    -property name: Optional[str]#
    +property name: Optional[str]#

    The name of this file.

    If this ReadableAudioFile was opened from a file-like object, this will be None.

    -property num_channels: int#
    +property num_channels: int#

    The number of channels in this file.

    -property samplerate: Union[float, int]#
    +property samplerate: Union[float, int]#

    The sample rate of this file in samples (per channel) per second (Hz). Sample rates are represented as floating-point numbers by default, but this property will be an integer if the fileโ€™s sample rate has no fractional part.

    @@ -695,7 +695,7 @@

    The pedalboard.
    -class pedalboard.io.ResampledReadableAudioFile(audio_file: ReadableAudioFile, target_sample_rate: float, resampling_quality: Quality = Quality.WindowedSinc)#
    +class pedalboard.io.ResampledReadableAudioFile(audio_file: ReadableAudioFile, target_sample_rate: float, resampling_quality: Quality = Quality.WindowedSinc)#

    A class that wraps an audio file for reading, while resampling the audio stream on-the-fly to a new sample rate.

    Introduced in v0.6.0.

    @@ -724,19 +724,19 @@

    The pedalboard.
    -__exit__(arg0: object, arg1: object, arg2: object) None#
    +__exit__(arg0: object, arg1: object, arg2: object) None#

    Stop using this ResampledReadableAudioFile as a context manager, close the file, release its resources.

    -close() None#
    +close() None#

    Close this file, rendering this object unusable. Note that the ReadableAudioFile instance that is wrapped by this object will not be closed, and will remain usable.

    -read(num_frames: Union[float, int] = 0) ndarray[Any, dtype[float32]]#
    +read(num_frames: Union[float, int] = 0) ndarray[Any, dtype[float32]]#

    Read the given number of frames (samples in each channel, at the target sample rate) from this audio file at its current position, automatically resampling on-the-fly to target_sample_rate.

    @@ -764,7 +764,7 @@

    The pedalboard.
    -seek(position: int) None#
    +seek(position: int) None#

    Seek this file to the provided location in frames at the target sample rate. Future reads will start from this position.

    Note

    @@ -774,25 +774,25 @@

    The pedalboard.
    -seekable() bool#
    +seekable() bool#

    Returns True if this file is currently open and calls to seek() will work.

    -tell() int#
    +tell() int#

    Return the current position of the read pointer in this audio file, in frames at the target sample rate. This value will increase as read() is called, and may decrease if seek() is called.

    -property closed: bool#
    +property closed: bool#

    True iff either this file or its wrapped ReadableAudioFile instance are closed (and no longer usable), False otherwise.

    -property duration: float#
    +property duration: float#

    The duration of this file in seconds (frames divided by samplerate).

    Warning

    @@ -802,7 +802,7 @@

    The pedalboard.
    -property exact_duration_known: bool#
    +property exact_duration_known: bool#

    Returns True if this fileโ€™s frames and duration attributes are exact values, or False if the frames and duration attributes are estimates based @@ -822,14 +822,14 @@

    The pedalboard.
    -property file_dtype: str#
    +property file_dtype: str#

    The data type ("int16", "float32", etc) stored natively by this file.

    Note that read() will always return a float32 array, regardless of the value of this property.

    -property frames: int#
    +property frames: int#

    The total number of frames (samples per channel) in this file, at the target sample rate.

    For example, if this file contains 10 seconds of stereo audio at sample rate of 44,100 Hz, and target_sample_rate is 22,050 Hz, frames will return 22,050.

    Note that different resampling_quality values used for resampling may cause frames to differ by ยฑ 1 from its expected value.

    @@ -841,14 +841,14 @@

    The pedalboard.
    -property name: Optional[str]#
    +property name: Optional[str]#

    The name of this file.

    If the ReadableAudioFile wrapped by this ResampledReadableAudioFile was opened from a file-like object, this will be None.

    -property num_channels: int#
    +property num_channels: int#

    The number of channels in this file.

    @@ -860,7 +860,7 @@

    The pedalboard.
    -property samplerate: Union[float, int]#
    +property samplerate: Union[float, int]#

    The sample rate of this file in samples (per channel) per second (Hz). This will be equal to the target_sample_rate parameter passed when this object was created. Sample rates are represented as floating-point numbers by default, but this property will be an integer if the fileโ€™s target sample rate has no fractional part.

    @@ -868,31 +868,31 @@

    The pedalboard.
    -class pedalboard.io.StreamResampler(source_sample_rate: float, target_sample_rate: float, num_channels: int, quality: Quality = Quality.WindowedSinc)#
    +class pedalboard.io.StreamResampler(source_sample_rate: float, target_sample_rate: float, num_channels: int, quality: Quality = Quality.WindowedSinc)#

    A streaming resampler that can change the sample rate of multiple chunks of audio in series, while using constant memory.

    For a resampling plug-in that can be used in Pedalboard objects, see pedalboard.Resample.

    Introduced in v0.6.0.

    -process(input: Optional[ndarray[Any, dtype[float32]]] = None) ndarray[Any, dtype[float32]]#
    +process(input: Optional[ndarray[Any, dtype[float32]]] = None) ndarray[Any, dtype[float32]]#

    Resample a 32-bit floating-point audio buffer. The returned buffer may be smaller than the provided buffer depending on the quality method used. Call process() without any arguments to flush the internal buffers and return all remaining audio.

    -reset() None#
    +reset() None#

    Used to reset the internal state of this resampler. Call this method when resampling a new audio stream to prevent audio from leaking between streams.

    -property input_latency: float#
    +property input_latency: float#

    The number of samples (in the input sample rate) that must be supplied before this resampler will begin returning output.

    -property num_channels: int#
    +property num_channels: int#

    The number of channels expected to be passed in every call to process().

    @@ -904,13 +904,13 @@

    The pedalboard.
    -property source_sample_rate: float#
    +property source_sample_rate: float#

    The source sample rate of the input audio that this resampler expects to be passed to process().

    -property target_sample_rate: float#
    +property target_sample_rate: float#

    The sample rate of the audio that this resampler will return from process().

    @@ -918,9 +918,9 @@

    The pedalboard.
    -class pedalboard.io.WriteableAudioFile(filename: str, samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None)#
    +class pedalboard.io.WriteableAudioFile(filename: str, samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None)#
    -class pedalboard.io.WriteableAudioFile(file_like: BinaryIO, samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None, format: Optional[str] = None)
    +class pedalboard.io.WriteableAudioFile(file_like: BinaryIO, samplerate: Optional[float] = None, num_channels: int = 1, bit_depth: int = 16, quality: Optional[Union[str, float]] = None, format: Optional[str] = None)

    A class that wraps an audio file for writing, with native support for Ogg Vorbis, MP3, WAV, FLAC, and AIFF files on all operating systems.

    Use pedalboard.io.get_supported_write_formats() to see which @@ -960,25 +960,25 @@

    The pedalboard.

    -close() None#
    +close() None#

    Close this file, flushing its contents to disk and rendering this object unusable for further writing.

    -flush() None#
    +flush() None#

    Attempt to flush this audio fileโ€™s contents to disk. Not all formats support flushing, so this may throw a RuntimeError. (If this happens, closing the file will reliably force a flush to occur.)

    -tell() int#
    +tell() int#

    Return the current position of the write pointer in this audio file, in frames at the target sample rate. This value will increase as write() is called, and will never decrease.

    -write(samples: ndarray) None#
    +write(samples: ndarray) None#

    Encode an array of audio data and write it to this file. The number of channels in the array must match the number of channels used to open the file. The array may contain audio in any shape. If the fileโ€™s bit depth or format does not match the provided data type, the audio will be automatically converted.

    Arrays of type int8, int16, int32, float32, and float64 are supported. If an array of an unsupported dtype is provided, a TypeError will be raised.

    @@ -1008,38 +1008,38 @@

    The pedalboard.
    -property closed: bool#
    +property closed: bool#

    If this file has been closed, this property will be True.

    -property file_dtype: str#
    +property file_dtype: str#

    The data type stored natively by this file. Note that write(โ€ฆ) will accept multiple datatypes, regardless of the value of this property.

    -property frames: int#
    +property frames: int#

    The total number of frames (samples per channel) written to this file so far.

    -property num_channels: int#
    +property num_channels: int#

    The number of channels in this file.

    -property quality: Optional[str]#
    +property quality: Optional[str]#

    The quality setting used to write this file. For many formats, this may be None.

    Quality options differ based on the audio codec used in the file. Most codecs specify a number of bits per second in 16- or 32-bit-per-second increments (128 kbps, 160 kbps, etc). Some codecs provide string-like options for variable bit-rate encoding (i.e. โ€œV0โ€ through โ€œV9โ€ for MP3). The strings "best", "worst", "fastest", and "slowest" will also work for any codec.

    -property samplerate: Union[float, int]#
    +property samplerate: Union[float, int]#

    The sample rate of this file in samples (per channel) per second (Hz). Sample rates are represented as floating-point numbers by default, but this property will be an integer if the fileโ€™s sample rate has no fractional part.

    diff --git a/docs/search.html b/docs/search.html index 77fca6f8..dca22e2a 100644 --- a/docs/search.html +++ b/docs/search.html @@ -4,7 +4,7 @@ - Search - Pedalboard v0.9.9 Documentation + Search - Pedalboard v0.9.10 Documentation @@ -121,7 +121,7 @@

    @@ -147,7 +147,7 @@
    - Pedalboard v0.9.9 Documentation + Pedalboard v0.9.10 Documentation diff --git a/pedalboard/plugins/Convolution.h b/pedalboard/plugins/Convolution.h index 12d654be..283127e9 100644 --- a/pedalboard/plugins/Convolution.h +++ b/pedalboard/plugins/Convolution.h @@ -47,10 +47,22 @@ class ConvolutionWithMix { impulseResponseFilename = filename; } - const std::string &getImpulseResponseFilename() const { + const std::optional &getImpulseResponseFilename() const { return impulseResponseFilename; } + void setImpulseResponse(juce::AudioBuffer &&ir) { + impulseResponse = {std::move(ir)}; + } + + const std::optional> &getImpulseResponse() const { + return {impulseResponse}; + } + + void setSampleRate(double sr) { sampleRate = {sr}; } + + const std::optional &getSampleRate() const { return sampleRate; } + void prepare(const juce::dsp::ProcessSpec &spec) { convolution.prepare(spec); mixer.prepare(spec); @@ -74,7 +86,9 @@ class ConvolutionWithMix { juce::dsp::BlockingConvolution convolution; juce::dsp::DryWetMixer mixer; float mix = 1.0; - std::string impulseResponseFilename; + std::optional impulseResponseFilename; + std::optional> impulseResponse; + std::optional sampleRate; }; inline void init_convolution(py::module &m) { @@ -82,35 +96,78 @@ inline void init_convolution(py::module &m) { std::shared_ptr>>( m, "Convolution", "An audio convolution, suitable for things like speaker simulation or " - "reverb modeling.") - .def(py::init([](std::string &impulseResponseFilename, float mix) { - py::gil_scoped_release release; + "reverb modeling.\n\n" + "The convolution impulse response can be specified either by filename or " + "as a 32-bit floating point NumPy array. If a NumPy array is provided, " + "the ``sample_rate`` argument must also be provided to indicate the " + "sample rate of the impulse response.\n\n*Support for passing NumPy " + "arrays as impulse responses introduced in v0.9.10.*") + .def(py::init([](std::variant> + impulseResponse, + float mix, std::optional sampleRate) { auto plugin = std::make_unique>(); - // Load the IR file on construction, to handle errors - auto inputFile = juce::File(impulseResponseFilename); - // Test opening the file before we pass it to - // loadImpulseResponse, which reloads it in the background: - { - juce::FileInputStream stream(inputFile); - if (!stream.openedOk()) { - throw std::runtime_error("Unable to load impulse response: " + - impulseResponseFilename); + + if (auto *impulseResponseFilename = + std::get_if(&impulseResponse)) { + py::gil_scoped_release release; + // Load the IR file on construction, to handle errors + auto inputFile = juce::File(*impulseResponseFilename); + // Test opening the file before we pass it to + // loadImpulseResponse, which reloads it in the background: + { + juce::FileInputStream stream(inputFile); + if (!stream.openedOk()) { + throw std::runtime_error( + "Unable to load impulse response: " + + *impulseResponseFilename); + } } - } - plugin->getDSP().getConvolution().loadImpulseResponse( - inputFile, juce::dsp::Convolution::Stereo::yes, - juce::dsp::Convolution::Trim::no, 0); + plugin->getDSP().getConvolution().loadImpulseResponse( + inputFile, juce::dsp::Convolution::Stereo::yes, + juce::dsp::Convolution::Trim::no, 0); + plugin->getDSP().setImpulseResponseFilename( + *impulseResponseFilename); + } else if (auto *inputArray = + std::get_if>( + &impulseResponse)) { + if (!sampleRate) { + throw std::runtime_error( + "sample_rate must be provided when passing a numpy array " + "as an impulse response."); + } + plugin->getDSP().getConvolution().loadImpulseResponse( + std::move(copyPyArrayIntoJuceBuffer(*inputArray)), + *sampleRate, juce::dsp::Convolution::Stereo::yes, + juce::dsp::Convolution::Trim::no, + juce::dsp::Convolution::Normalise::yes); + + plugin->getDSP().setImpulseResponse( + copyPyArrayIntoJuceBuffer(*inputArray)); + plugin->getDSP().setSampleRate(*sampleRate); + } plugin->getDSP().setMix(mix); return plugin; }), - py::arg("impulse_response_filename"), py::arg("mix") = 1.0) + py::arg("impulse_response_filename"), py::arg("mix") = 1.0, + py::arg("sample_rate") = py::none()) .def("__repr__", [](JucePlugin &plugin) { std::ostringstream ss; ss << "getNumSamples() + << " samples of " + << plugin.getDSP().getImpulseResponse()->getNumChannels() + << "-channel audio at " << *plugin.getDSP().getSampleRate() + << " Hz>"; + } + ss << " mix=" << plugin.getDSP().getMix(); ss << " at " << &plugin; ss << ">"; @@ -121,6 +178,18 @@ inline void init_convolution(py::module &m) { [](JucePlugin &plugin) { return plugin.getDSP().getImpulseResponseFilename(); }) + .def_property_readonly( + "impulse_response", + [](JucePlugin &plugin) + -> std::optional> { + if (plugin.getDSP().getImpulseResponse()) { + return {copyJuceBufferIntoPyArray( + *plugin.getDSP().getImpulseResponse(), + ChannelLayout::NotInterleaved, 0, 2)}; + } else { + return {}; + } + }) .def_property( "mix", [](JucePlugin &plugin) { diff --git a/pedalboard/version.py b/pedalboard/version.py index 78ce9d49..82dd788c 100644 --- a/pedalboard/version.py +++ b/pedalboard/version.py @@ -17,6 +17,6 @@ MAJOR = 0 MINOR = 9 -PATCH = 9 +PATCH = 10 __version__ = "%d.%d.%d" % (MAJOR, MINOR, PATCH) diff --git a/pedalboard_native/__init__.pyi b/pedalboard_native/__init__.pyi index afa6eae4..00a7ec21 100644 --- a/pedalboard_native/__init__.pyi +++ b/pedalboard_native/__init__.pyi @@ -304,12 +304,29 @@ class Compressor(Plugin): class Convolution(Plugin): """ An audio convolution, suitable for things like speaker simulation or reverb modeling. + + The convolution impulse response can be specified either by filename or as a 32-bit floating point NumPy array. If a NumPy array is provided, the ``sample_rate`` argument must also be provided to indicate the sample rate of the impulse response. + + *Support for passing NumPy arrays as impulse responses introduced in v0.9.10.* """ - def __init__(self, impulse_response_filename: str, mix: float = 1.0) -> None: ... + def __init__( + self, + impulse_response_filename: typing.Union[ + str, numpy.ndarray[typing.Any, numpy.dtype[numpy.float32]] + ], + mix: float = 1.0, + sample_rate: typing.Optional[float] = None, + ) -> None: ... def __repr__(self) -> str: ... @property - def impulse_response_filename(self) -> str: + def impulse_response( + self, + ) -> typing.Optional[numpy.ndarray[typing.Any, numpy.dtype[numpy.float32]]]: + """ """ + + @property + def impulse_response_filename(self) -> typing.Optional[str]: """ """ @property diff --git a/tests/test_native_module.py b/tests/test_native_module.py index dfc2fc65..1823b270 100644 --- a/tests/test_native_module.py +++ b/tests/test_native_module.py @@ -16,9 +16,21 @@ import os -import pytest + import numpy as np -from pedalboard import process, Delay, Distortion, Invert, Gain, Compressor, Convolution, Reverb +import pytest + +from pedalboard import ( + Compressor, + Convolution, + Delay, + Distortion, + Gain, + Invert, + Reverb, + process, +) +from pedalboard.io import AudioFile IMPULSE_RESPONSE_PATH = os.path.join(os.path.dirname(__file__), "impulse_response.wav") @@ -69,6 +81,15 @@ def test_convolution_works(sr=44100, duration=10): assert not np.allclose(full_scale_noise, result, rtol=0.1) +def test_convolution_works_with_buffer(sr=44100, duration=10): + full_scale_noise = np.random.rand(sr * duration).astype(np.float32) + + expected = Convolution(IMPULSE_RESPONSE_PATH, 0.5)(full_scale_noise, sr) + with AudioFile(IMPULSE_RESPONSE_PATH) as f: + actual = Convolution(f.read(f.frames), 0.5, sample_rate=sr)(full_scale_noise, sr) + np.testing.assert_allclose(expected, actual, atol=0.0001) + + def test_throw_on_inaccessible_convolution_file(): # Should work: Convolution(IMPULSE_RESPONSE_PATH) @@ -78,6 +99,26 @@ def test_throw_on_inaccessible_convolution_file(): Convolution("missing_impulse_response.wav") +def test_convolution_repr(): + assert IMPULSE_RESPONSE_PATH in repr(Convolution(IMPULSE_RESPONSE_PATH)) + assert "12345 samples of 2-channel audio at 44100 Hz" in repr( + Convolution(np.random.rand(12345, 2).astype(np.float32), 0.5, 44100) + ) + + +def test_convolution_filename(): + conv = Convolution(IMPULSE_RESPONSE_PATH) + assert conv.impulse_response_filename == IMPULSE_RESPONSE_PATH + assert conv.impulse_response is None + + +def test_convolution_impulse_response_storage(): + ir = np.random.rand(2, 12345).astype(np.float32) + conv = Convolution(ir, 0.5, 44100) + assert conv.impulse_response_filename is None + np.testing.assert_allclose(conv.impulse_response, ir) + + @pytest.mark.parametrize("gain_db", [-12, -6, 0, 1.1, 6, 12, 24, 48, 96]) @pytest.mark.parametrize("shape", [(44100,), (44100, 1), (44100, 2), (1, 44100), (2, 44100)]) def test_distortion(gain_db, shape, sr=44100):