π π A Python library for audio.
C audioaudio-processingaudio-productionaudio-researchaudio-unitaugmentationjucemachine-learningpybind11pythonvst3vst3-host
Temp
Peter Sobotd159171e5502
diff --git a/pedalboard/__init__.pyi b/pedalboard/__init__.pyiindex b345a9c..b9e9c7f 100644--- a/pedalboard/__init__.pyi+++ b/pedalboard/__init__.pyi@@ -974,3 +974,113 @@ class GSMFullRateCompressor(Plugin):def quality(self, arg1: Resample.Quality) -> None:passpass++from _typeshed import Incomplete+from pedalboard_native import (+ Plugin as Plugin,+ _AudioProcessorParameter,+ _AudioUnitPlugin,+ _VST3Plugin,+)+from pedalboard_native.utils import Chain+from typing import Dict, List, Optional, Union++class Pedalboard(Chain):+ def __init__(self, plugins: Optional[List[Plugin]] = ...) -> None: ...++FLOAT_SUFFIXES_TO_IGNORE: Incomplete++def strip_common_float_suffixes(+ s: Union[float, str, bool], strip_si_prefixes: bool = ...+) -> Union[float, str, bool]: ...+def looks_like_float(s: Union[float, str]) -> bool: ...++class ReadOnlyDictWrapper(dict):+ def __setitem__(self, name, value) -> None: ...++def wrap_type(base_type): ...++class WrappedBool:+ def __init__(self, value) -> None: ...+ def __eq__(self, o: object) -> bool: ...+ def __hash__(self) -> int: ...+ def __bool__(self) -> bool: ...+ def __getattr__(self, attr: str): ...+ def __hasattr__(self, attr: str): ...++StringWithParameter: Incomplete+FloatWithParameter: Incomplete+BooleanWithParameter: Incomplete+PARAMETER_NAME_REGEXES_TO_IGNORE: Incomplete+TRUE_BOOLEANS: Incomplete++def get_text_for_raw_value(+ cpp_parameter: _AudioProcessorParameter, raw_value: float, slow: bool = ...+) -> Optional[str]: ...++class AudioProcessorParameter:+ ranges: Incomplete+ python_name: Incomplete+ min_value: Incomplete+ max_value: Incomplete+ step_size: Incomplete+ approximate_step_size: Incomplete+ type: Incomplete+ valid_values: Incomplete+ range: Incomplete+ def __init__(self, plugin, parameter_name, search_steps: int = ...) -> None: ...+ @property+ def label(self) -> Optional[str]: ...+ @property+ def units(self) -> Optional[str]: ...+ def __getattr__(self, name: str): ...+ def __setattr__(self, name: str, value): ...+ def get_raw_value_for(self, new_value: Union[float, str, bool]) -> float: ...++def to_python_parameter_name(parameter: _AudioProcessorParameter) -> Optional[str]: ...+def normalize_python_parameter_name(name: str) -> str: ...++class ExternalPlugin(Plugin):+ def __init__(+ self,+ path_to_plugin_file: str,+ parameter_values: Dict[str, Union[str, int, float, bool]] = ...,+ plugin_name: Optional[str] = ...,+ ) -> None: ...+ @classmethod+ def get_plugin_names_for_file(cls, filename: str) -> List[str]: ...+ def show_editor(self) -> None: ...+ @property+ def name(self) -> str: ...+ def __set_initial_parameter_values__(+ self, parameter_values: Dict[str, Union[str, int, float, bool]] = ...+ ): ...+ @property+ def parameters(self) -> Dict[str, AudioProcessorParameter]: ...+ def __dir__(self): ...+ def __getattr__(self, name: str): ...+ def __setattr__(self, name: str, value): ...++class VST3Plugin(_VST3Plugin, ExternalPlugin):+ def __init__(+ self,+ path_to_plugin_file: str,+ parameter_values: Dict[str, Union[str, int, float, bool]] = ...,+ plugin_name: Optional[str] = ...,+ ) -> None: ...++class AudioUnitPlugin(_AudioUnitPlugin, ExternalPlugin):+ def __init__(+ self,+ path_to_plugin_file: str,+ parameter_values: Dict[str, Union[str, int, float, bool]] = ...,+ plugin_name: Optional[str] = ...,+ ) -> None: ...++def load_plugin(+ path_to_plugin_file: str,+ parameter_values: Dict[str, Union[str, int, float, bool]] = ...,+ plugin_name: Union[str, None] = ...,+) -> ExternalPlugin: ...++from pedalboard.utils import *diff --git a/pedalboard/io/__init__.pyi b/pedalboard/io/__init__.pyiindex d895e15..a351136 100644--- a/pedalboard/io/__init__.pyi+++ b/pedalboard/io/__init__.pyi@@ -8,11 +8,14 @@ import typingfrom typing_extensions import Literalfrom enum import Enumimport numpy+import pedalboard_native.utils # type: ignore # type: ignore+import pedalboard # type: ignore_Shape = typing.Tuple[int, ...]__all__ = ["AudioFile",+ "AudioStream","ReadableAudioFile","ResampledReadableAudioFile","StreamResampler",@@ -135,6 +138,105 @@ class AudioFile:) -> WriteableAudioFile: ...pass+class AudioStream:+ """+ 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 to add effects.++ :class:`AudioStream` may be used as a context manager::++ input_device_name = AudioStream.input_device_names[0]+ output_device_name = AudioStream.output_device_names[0]+ with AudioStream(input_device_name, output_device_name) as stream:+ # In this block, audio is streaming through `stream`!+ # Audio will be coming out of your speakers at this point.++ # Add plugins to the live audio stream:+ reverb = Reverb()+ stream.plugins.append(reverb)++ # Change plugin properties as the stream is running:+ reverb.wet_level = 1.0++ # Delete plugins:+ del stream.plugins[0]+++ :class:`AudioStream` may also be used synchronously::++ stream = AudioStream(ogg_buffer)+ stream.plugins.append(Reverb(wet_level=1.0))+ stream.run() # Run the stream until Ctrl-C is received++ .. note::+ This class uses C++ under the hood to ensure speed, thread safety,+ and avoid any locking concerns with Python's Global Interpreter Lock.+ Audio data processed by :class:`AudioStream` is not available to+ Python code; the only way to interact with the audio stream is through+ the :py:attr:`plugins` attribute.++ .. warning::+ The :class:`AudioStream` class implements a context manager interface+ to ensure that audio streams are never left "dangling" (i.e.: running in+ the background without being stopped).++ While it is possible to call the :meth:`__enter__` method directly to run an+ audio stream in the background, this can have some nasty side effects. If the+ :class:`AudioStream` object is no longer reachable (not bound to a variable,+ 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 :class:`AudioStream` in the background, use Python's+ :py:mod:`threading` module to call the synchronous :meth:`run` method on a+ background thread, allowing for easier cleanup.++ *Introduced in v0.6.9. Not supported on Linux.*+ """++ def __enter__(self) -> AudioStream: ...+ def __exit__(self, arg0: object, arg1: object, arg2: object) -> None: ...+ def __init__(+ self,+ input_device_name: str,+ output_device_name: str,+ plugins: typing.Optional[pedalboard_native.utils.Chain] = None,+ sample_rate: typing.Optional[float] = None,+ buffer_size: int = 512,+ allow_feedback: bool = False,+ ) -> None: ...+ def __repr__(self) -> str: ...+ def run(self) -> None:+ """+ Start streaming audio from input to output, passing the audio stream through the :py:attr:`plugins` on this AudioStream object. This call will block the current thread until a KeyboardInterrupt (Ctrl-C) is received.+ """+ @property+ def plugins(self) -> pedalboard_native.utils.Chain:+ """+ The Pedalboard object that this AudioStream will use to process audio.+++ """+ @plugins.setter+ def plugins(self, arg1: pedalboard_native.utils.Chain) -> None:+ """+ The Pedalboard object that this AudioStream will use to process audio.+ """+ @property+ def running(self) -> bool:+ """+ True if this stream is currently streaming live audio from input to output, False otherwise.+++ """+ input_device_names = [+ "Peter Sobotβs iPhone Microphone",+ "BlackHole 2ch",+ "MacBook Pro Microphone",+ ]+ output_device_names = ["BlackHole 2ch", "MacBook Pro Speakers"]+ pass+class ReadableAudioFile(AudioFile):"""A class that wraps an audio file for reading, with native support for Ogg Vorbis,diff --git a/scripts/generate_type_stubs_and_docs.py b/scripts/generate_type_stubs_and_docs.pyindex d287ebb..c55fd50 100644--- a/scripts/generate_type_stubs_and_docs.py+++ b/scripts/generate_type_stubs_and_docs.py@@ -7,6 +7,7 @@ import shutilimport difflibimport importlibimport traceback+import subprocessfrom tempfile import TemporaryDirectoryfrom contextlib import contextmanagerfrom typing import List@@ -240,6 +241,9 @@ def main():if not args.skip_regenerating_type_hints:with TemporaryDirectory() as tempdir, isolated_imports({"pedalboard", "pedalboard.io"}):+ print("Generating type stubs from pure-Python code...")+ subprocess.check_call(["stubgen", "-o", tempdir, "pedalboard/pedalboard.py"])+# Generate .pyi stubs files from Pedalboard's native (Pybind11) source.# Documentation will be copied from the Pybind11 docstrings, and these stubs# files will be used as the "source of truth" for both IDE autocompletion@@ -253,6 +257,7 @@ def main():postprocess_type_hints_main([tempdir, "pedalboard"] + (["--check"] if args.check else []))+ breakpoint()# Run mypy.stubtest to ensure that the results are correct and nothing got missed:if sys.version_info > (3, 6):