### Executing Pyo Class Examples Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/gettingstarted.rst.txt Demonstrates how to run the built-in examples provided with each Pyo class, useful for understanding their usage and capabilities. ```python from pyo import * example(Harmonizer) ``` -------------------------------- ### Executing a Pyo Class Example Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Demonstrates how to run the built-in examples provided with each Pyo class. This allows users to quickly see a class in action and understand its typical usage by calling the `example()` function with the class name. ```python from pyo import * example(Harmonizer) ``` -------------------------------- ### Initialize Pyo Server and Generate Basic Sine Wave Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/gettingstarted.rst.txt Demonstrates how to boot and start the Pyo audio server, create a simple sine wave oscillator, and output its sound. Includes examples for interactive Python shells and non-interactive scripts using a GUI or time delay. ```python from pyo import * s = Server().boot() s.start() a = Sine(mul=0.01).out() s.stop() ``` ```python from pyo import * s = Server().boot() s.start() a = Sine(mul=0.01).out() s.gui(locals()) ``` ```python from pyo import * import time s = Server().boot() a = Sine(440, 0, 0.1).out() s.start() time.sleep(1) s.stop() ``` -------------------------------- ### Get Pyo Examples Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/util.html Returns a dictionary containing a listing of the example files installed with pyo. Users can choose to retrieve either just the filenames or their full paths. This is useful for exploring bundled examples. ```APIDOC getPyoExamples(fullpath=False) Parameters: fullpath: boolean - If True, the full path of each file is returned. Otherwise, only the filenames are listed. Returns: dict - A listing of the examples installed with pyo. ``` ```Python examples = getPyoExamples() ``` -------------------------------- ### Booting and Starting the Pyo Server with a Basic Sine Wave Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Demonstrates the fundamental steps to initialize the Pyo audio server and generate a simple sine wave. It shows how to import the `pyo` module, boot and start the `Server` instance, and create an `Sine` object with a reduced amplitude to prevent clipping. It also includes how to stop the server. ```python from pyo import * s = Server().boot() s.start() a = Sine(mul=0.01).out() ``` ```python s.stop() ``` -------------------------------- ### Pyo Server Initialization Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/utils.html A basic Python example demonstrating how to initialize and start a Pyo Server instance. This is a common first step for any Pyo audio application. ```python s = Server().boot() s.start() ``` -------------------------------- ### Pyo: Retrieve Installed Examples Function Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo.html This entry provides both the API documentation and the Python implementation for the `getPyoExamples` function from the `pyo` library. This function allows users to programmatically retrieve a structured listing of example files bundled with the `pyo` installation, with an option to return full paths. ```APIDOC pyo.getPyoExamples(fullpath=False): Returns a listing of the examples, as a dictionary, installed with pyo. Args: fullpath: boolean If True, the full path of each file is returned. Otherwise, only the filenames are listed. Example Usage: >>> examples = getPyoExamples() ``` ```Python def getPyoExamples(fullpath=False): folder = "examples" filedir = os.path.dirname(os.path.abspath(__file__)) subfolders = [f for f in os.listdir(os.path.join(filedir, folder)) if not f.startswith("__") and not f == "snds"] examples = {} for subfolder in sorted(subfolders): path = os.path.join(filedir, folder, subfolder) if fullpath: files = [os.path.join(path, f) for f in os.listdir(path) if not f.startswith("__")] else: files = [f for f in os.listdir(path) if not f.startswith("__")] examples[subfolder] = files return examples ``` -------------------------------- ### Chaining Pyo Objects for Complex Synthesis Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/gettingstarted.rst.txt Shows how to connect the output of one Pyo object as an input to another, enabling complex sound synthesis techniques like frequency modulation and envelope shaping. Both examples use the server GUI to keep the script running. ```python from pyo import * s = Server().boot() mod = Sine(freq=6, mul=50) a = Sine(freq=mod + 440, mul=0.1).out() s.gui(locals()) ``` ```python from pyo import * s = Server().boot() f = Adsr(attack=.01, decay=.2, sustain=.5, release=.1, dur=5, mul=.5) a = Sine(mul=f).out() f.play() s.gui(locals()) ``` -------------------------------- ### Pyo Server Initialization Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/dynamics.html An example demonstrating how to initialize and start the Pyo audio server using the `Server` class. ```Python s = Server().boot() s.start() ``` -------------------------------- ### Pyo Compress Class: Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/dynamics.html Illustrates a basic example of using the Pyo `Compress` class. This snippet demonstrates how to boot and start a Pyo server, load an audio file, and apply compression with specific threshold, ratio, and time parameters. ```Python s = Server().boot() s.start() a = SfPlayer(SNDS_PATH + '/transparent.aif', loop=True) b = Compress(a, thresh=-24, ratio=6, risetime=.01, falltime=.2, knee=0.5).mix(2).out() ``` -------------------------------- ### Python Example: Initializing pyo.Server for SLMap Usage Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/map.html Shows the initial setup for using `SLMap` by booting and starting a `pyo.Server` instance. This server initialization is a prerequisite for `SLMap` to effectively manage control sliders and process audio signals. ```Python s = Server().boot() s.start() ``` -------------------------------- ### Pyo Server and Sine Wave Initialization Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/analysis.html An example demonstrating how to initialize a pyo server, start it, and create a sine wave generator with specific frequencies and a multiplier. ```Python s = Server().boot() s.start() a = Sine([100,100.2], mul=0.7) ``` -------------------------------- ### Pyo Server Boot and SfPlayer Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/fourier.html Demonstrates how to boot and start a Pyo server, load a sound file using SfPlayer, and initialize a NewMatrix for Fourier analysis. This example sets up a basic audio processing chain. ```Python s = Server().boot() s.start() snd = SNDS_PATH + '/transparent.aif' size, hop = 1024, 256 nframes = int(sndinfo(snd)[0] / size) + 1 a = SfPlayer(snd, mul=.3) m_mag = [NewMatrix(width=size, height=nframes) for i in range(4)] ``` -------------------------------- ### Example Usage of pyo.Sine Wave Oscillator Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/generators.html Demonstrates how to initialize a pyo Server, start it, and create a basic sine wave oscillator with specified frequency and amplitude. This snippet shows a minimal setup for audio synthesis using pyo. ```python s = Server().boot() s.start() sine = Sine(freq=[400,500], mul=.2).out() ``` -------------------------------- ### Pyo Server Initialization Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/midi.html A concise Python code example demonstrating the essential steps to initialize and start the Pyo audio server. This snippet is a foundational step for any Pyo application, preparing the environment for audio synthesis and processing. ```Python s = Server().boot() s.start() ``` -------------------------------- ### Install pyo and its Dependencies on macOS Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/compiling.rst.txt This snippet provides a sequence of commands to set up the pyo library. It starts by installing necessary audio and MIDI libraries using Homebrew, then clones the pyo source repository, builds the project with CoreAudio and double-precision support, and finally installs the compiled wheel file. ```bash brew install liblo libsndfile portaudio portmidi git clone https://github.com/belangeo/pyo.git cd pyo python3 -m build --config-setting="--build-option=--use-coreaudio" --config-setting="--build-option=--use-double" python3 -m pip install --user dist/ ``` -------------------------------- ### Complete Pyo Example: Server Setup and Event Sequences Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/examples/x22-events/01-simple-sequences.rst.txt A comprehensive example demonstrating the initialization of a Pyo server, setting its amplitude, and playing various types of event sequences. It includes an infinite sequence using EventSeq, a constant frequency, and a GUI for interaction. ```python from pyo import * s = Server().boot() s.amp = 0.25 # Simple infinite sequence. e = Events(freq=EventSeq([250, 300, 350, 400])).play() # This will play the same note forever. e3 = Events(freq=200).play() s.gui(locals()) ``` -------------------------------- ### Pyo Audio Configuration API Reference Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/api/functions/audio.rst.txt Reference documentation for pyo's audio setup functions, providing details on how to retrieve information about Portaudio installations, host APIs, and audio devices. These functions are available only if pyo is built with Portaudio support. ```APIDOC pyo.pa_get_version(): Returns the version number, as an integer, of the current portaudio installation. pyo.pa_get_version_text(): Returns the textual description of the current portaudio installation. pyo.pa_count_host_apis(): Returns the number of host apis found by Portaudio. pyo.pa_list_host_apis(): Prints a list of all host apis found by Portaudio. pyo.pa_get_default_host_api(): Returns the index number of Portaudio’s default host api. pyo.pa_get_default_devices_from_host(): Returns the default input and output devices for a given audio host. pyo.pa_count_devices(): Returns the number of devices found by Portaudio. pyo.pa_list_devices(): Prints a list of all devices found by Portaudio. pyo.pa_get_devices_infos(): Returns informations about all devices found by Portaudio. pyo.pa_get_input_devices(): Returns input devices (device names, device indexes) found by Portaudio. pyo.pa_get_output_devices(): Returns output devices (device names, device indexes) found by Portaudio. pyo.pa_get_default_input(): Returns the index number of Portaudio’s default input device. pyo.pa_get_default_output(): Returns the index number of Portaudio’s default output device. pyo.pa_get_input_max_channels(x): Retrieve the maximum number of input channels for the specified device. pyo.pa_get_output_max_channels(x): Retrieve the maximum number of output channels for the specified device. ``` -------------------------------- ### Initialize and Start a Pyo Server Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/server.html This Python snippet demonstrates how to create and boot a `pyo.Server` instance with specific audio settings, including a sampling rate of 48000 Hz, 8 channels, a buffer size of 512, and duplex mode enabled. After booting, the server is started to begin audio processing. ```Python # For an 8 channels server in duplex mode with # a sampling rate of 48000 Hz and buffer size of 512 s = Server(sr=48000, nchnls=8, buffersize=512, duplex=1).boot() s.start() ``` -------------------------------- ### List PortAudio Host APIs in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/audio.html Provides an example of printing a detailed list of all host APIs found by PortAudio using `pyo`. ```Python pa_list_host_apis() index: 0, id: 5, name: Core Audio, num devices: 6, default in: 0, default out: 2 ``` -------------------------------- ### Python SigTo Class Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/controls.html An example demonstrating how to use the `SigTo` class to apply a linear portamento to audio signals. It shows server setup, `SigTo` instantiation, and dynamic frequency changes using a `Pattern`. ```python >>> import random >>> s = Server().boot() >>> s.start() >>> fr = SigTo(value=200, time=0.5, init=200) >>> a = SineLoop(freq=fr, feedback=0.08, mul=.3).out() >>> b = SineLoop(freq=fr*1.005, feedback=0.08, mul=.3).out(1) >>> def pick_new_freq(): ... fr.value = random.randrange(200,501,50) >>> pat = Pattern(function=pick_new_freq, time=1).play() ``` -------------------------------- ### Pyo Server Initialization and Signal Generation Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/fourier.html An example demonstrating how to initialize a Pyo server, load an audio file using `SfPlayer`, and generate a frequency modulated (FM) synthesis signal using the `FM` class. This snippet showcases basic audio setup and signal source creation in Pyo. ```Python s = Server().boot() snd1 = SfPlayer(SNDS_PATH+"/transparent.aif", loop=True, mul=.7).mix(2) snd2 = FM(carrier=[75,100,125,150], ratio=[.499,.5,.501,.502], index=20, mul=.1).mix(2) ``` -------------------------------- ### Install Pyo Audio DSP Library from Source Source: https://github.com/belangeo/pyo/blob/master/documentation/source/compiling.rst This bash script provides a step-by-step guide to install the Pyo audio DSP library. It begins by installing essential audio-related dependencies (liblo, libsndfile, portaudio, portmidi) using Homebrew. Following this, it clones the Pyo source code from GitHub, builds the project using `python3 -m build` with specific configuration settings for CoreAudio and double-precision floating-point support, and concludes by installing the generated Python wheel file into the user's environment using pip. ```bash brew install liblo libsndfile portaudio portmidi git clone https://github.com/belangeo/pyo.git cd pyo python3 -m build --config-setting="--build-option=--use-coreaudio" --config-setting="--build-option=--use-double" python3 -m pip install --user dist/ ``` -------------------------------- ### Example Usage of Pyo OscListener Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/listener.html Demonstrates how to instantiate and start an `OscListener` to receive OSC messages. It shows how to define a callback function that processes the received address and arguments, and how to boot a `Server` instance (though not directly related to `OscListener`'s core function, it's part of the example context). The listener is set up on port 9901. ```Python s = Server().boot() def call(address, *args): print(address, args) listen = OscListener(call, 9901) listen.start() ``` -------------------------------- ### Pyo Noise Generator Instantiation and Playback Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/generators.html Demonstrates how to instantiate and play a white noise generator using the Pyo library. This example boots and starts a Pyo server, then creates a `Noise` object, mixes its output, and sends it to the audio output. ```python s = Server().boot() s.start() a = Noise(.1).mix(2).out() ``` -------------------------------- ### Pyo ControlRead Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/utils.html This Python example demonstrates how to initialize a Pyo Server, create a ControlRead object to read control data from a file, and then use this data to control the frequency of a SineLoop synthesizer. It shows the basic setup for audio processing with `pyo`. ```python s = Server().boot() s.start() rnds = ControlRead(SNDS_PATH+"/ControlRead_example_test", rate=100, loop=True) sines = SineLoop(freq=rnds, feedback=.05, mul=.15).out() ``` -------------------------------- ### API Reference: PortAudio Version Information Source: https://github.com/belangeo/pyo/blob/master/documentation/source/api/functions/audio.rst Provides functions to retrieve the version number and textual description of the underlying PortAudio installation. ```APIDOC pa_get_version() -> int Returns: The version number, as an integer, of the current PortAudio installation. ``` ```APIDOC pa_get_version_text() -> str Returns: The textual description of the current PortAudio installation. ``` -------------------------------- ### Complete example: Pyo server and event sequences Source: https://github.com/belangeo/pyo/blob/master/docs/examples/x22-events/01-simple-sequences.html A full runnable example demonstrating how to initialize a `pyo` server, set its amplitude, create an infinite frequency sequence using `EventSeq`, and play a continuous tone from a single frequency value. Includes GUI setup for interaction. ```python from pyo import * s = Server().boot() s.amp = 0.25 # Simple infinite sequence. e = Events(freq=EventSeq([250, 300, 350, 400])).play() # This will play the same note forever. e3 = Events(freq=200).play() s.gui(locals()) ``` -------------------------------- ### Initialize and start pyo audio server Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/examples/x01-intro/01-audio-server.rst.txt This snippet demonstrates the fundamental steps to set up and activate the pyo audio server. It covers creating the Server object, booting audio and MIDI streams, starting the processing loop, and launching the graphical user interface for interaction and program longevity. ```python from pyo import * # Creates a Server object with default arguments. # See the manual about how to change the sampling rate, the buffer # size, the number of channels or one of the other global settings. s = Server() # Boots the server. This step initializes audio and midi streams. # Audio and midi configurations (if any) must be done before that call. s.boot() # Starts the server. This step activates the server processing loop. s.start() # Here comes the processing chain... # The Server object provides a Graphical User Interface with the # gui() method. One of its purpose is to keep the program alive # while computing samples over time. If the locals dictionary is # given as argument, the user can continue to send commands to the # python interpreter from the GUI. s.gui(locals()) ``` -------------------------------- ### Get PortAudio Version Text in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/audio.html Shows how to obtain the textual description of the PortAudio installation from `pyo`. ```Python desc = pa_get_version_text() print(desc) PortAudio V19-devel (built Oct 8 2012 16:25:16) ``` -------------------------------- ### Get PortAudio Version in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/audio.html Demonstrates how to retrieve the integer version number of the PortAudio installation used by `pyo`. ```Python v = pa_get_version() print(v) 1899 ``` -------------------------------- ### Initialize and Boot Pyo Audio Server Source: https://github.com/belangeo/pyo/blob/master/docs/examples/x01-intro/01-audio-server.html This Python snippet demonstrates the essential steps to set up and start the Pyo audio server. It involves creating a Server object, booting it to initialize audio and MIDI streams, starting the server's processing loop, and launching a GUI to keep the program alive and enable interactive commands. ```Python from pyo import * # Creates a Server object with default arguments. # See the manual about how to change the sampling rate, the buffer # size, the number of channels or one of the other global settings. s = Server() # Boots the server. This step initializes audio and midi streams. # Audio and midi configurations (if any) must be done before that call. s.boot() # Starts the server. This step activates the server processing loop. s.start() # Here comes the processing chain... # The Server object provides a Graphical User Interface with the # gui() method. One of its purpose is to keep the program alive # while computing samples over time. If the locals dictionary is # given as argument, the user can continue to send commands to the # python interpreter from the GUI. s.gui(locals()) ``` -------------------------------- ### Booting and Starting Pyo Server and Generating Sound (Interactive) Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html This snippet demonstrates how to import the pyo module, boot and start the audio server, and create a basic sine wave oscillator. It's intended for interactive Python sessions where the sound plays immediately. ```Python >>> from pyo import * >>> s = Server().boot() >>> s.start() >>> a = Sine(mul=0.01).out() ``` -------------------------------- ### Creating an Envelope for a Sine Wave Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Shows how to apply an envelope to a sound object using the `Adsr` class. This example creates an Attack-Decay-Sustain-Release (ADSR) envelope and uses it to control the amplitude of a `Sine` wave, shaping its temporal characteristics. ```python from pyo import * s = Server().boot() f = Adsr(attack=.01, decay=.2, sustain=.5, release=.1, dur=5, mul=.5) a = Sine(mul=f).out() f.play() s.gui(locals()) ``` -------------------------------- ### Modifying Pyo Object Attributes Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/gettingstarted.rst.txt Illustrates different ways to set and modify attributes of Pyo objects after creation. Examples include setting parameters during instantiation, using dedicated setter methods, and direct attribute assignment. ```python a = Sine(mul=0.1).out() ``` ```python a.setFreq(1000) ``` ```python a.freq = 1000 ``` -------------------------------- ### Modifying Object Attributes Directly Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Illustrates an alternative, more direct way to modify an object's attributes by accessing them as properties. This example shows how to change the frequency of a `Sine` object by directly assigning a new value to its `freq` attribute. ```python a.freq = 1000 ``` -------------------------------- ### Initialize and Start Pyo Server Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/generators.html Demonstrates how to initialize and start a `pyo` audio server, which is a prerequisite for most audio processing operations in the library. This snippet shows the basic steps to boot and start the server. ```python s = Server().boot() s.start() ``` -------------------------------- ### Get Default MIDI Input Device Index in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/midi.html Retrieves the index number of Portmidi's default input device. This example shows how to use `pm_get_default_input` with `pm_get_input_devices` to identify the name of the default input device. ```Python names, indexes = pm_get_input_devices() name = names[indexes.index(pm_get_default_input())] print(name) ``` -------------------------------- ### Get Default MIDI Output Device Index in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/midi.html Retrieves the index number of Portmidi's default output device. This example demonstrates how to use `pm_get_default_output` in conjunction with `pm_get_output_devices` to find the name of the default output device. ```Python names, indexes = pm_get_output_devices() name = names[indexes.index(pm_get_default_output())] print(name) ``` -------------------------------- ### Execute Class Example in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html This Python snippet demonstrates how to execute the built-in example for a specific Pyo class, such as `Harmonizer`. It imports the Pyo library and then calls the `example()` utility function with the desired class as an argument, which will typically show and run a demonstration of that class's functionality. ```python from pyo import * example(Harmonizer) ``` -------------------------------- ### Initialize and Start Pyo Server Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/server.html This Python snippet demonstrates how to instantiate and boot a `pyo.Server` object with specific audio settings, such as sampling rate, number of channels, and buffer size. After booting, the server is started to begin audio processing. ```Python s = Server(sr=48000, nchnls=8, buffersize=512, duplex=1).boot() s.start() ``` -------------------------------- ### Chaining Objects for Frequency Modulation (FM) Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Explains how to chain Pyo objects, using the output of one oscillator as an input to another. This example demonstrates frequency modulation (FM) by using a `Sine` object to control the frequency of another `Sine` object, creating complex sounds. ```python from pyo import * s = Server().boot() mod = Sine(freq=6, mul=50) a = Sine(freq=mod + 440, mul=0.1).out() s.gui(locals()) ``` -------------------------------- ### Pyo Server and Table Initialization Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/utils.html Demonstrates the basic setup of a Pyo server, creation of a SquareTable waveform, a CosTable envelope, and a Metro object for triggering events. This snippet illustrates fundamental Pyo object instantiation and server control for audio synthesis. ```python s = Server().boot() s.start() wav = SquareTable() env = CosTable([(0,0), (100,1), (500,.3), (8191,0)]) met = Metro(.125, 8).play() ``` -------------------------------- ### Get Maximum Input Channels for Audio Device (pyo) Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/audio.html Explains how to retrieve the maximum number of input channels supported by a specific audio device using `pyo`'s `pa_get_input_max_channels` function. The example also shows how to identify a device by name and then query its capabilities. ```APIDOC pa_get_input_max_channels(x) x: int Device index as listed by Portaudio (see pa_get_input_devices). ``` ```Python device = 'HDA Intel PCH: STAC92xx Analog (hw:0,0)' dev_list, dev_index = pa_get_output_devices() dev = dev_index[dev_list.index(device)] print('Device index:', dev) maxouts = pa_get_output_max_channels(dev) maxins = pa_get_input_max_channels(dev) print('Max outputs', maxouts) print('Max inputs:', maxins) if maxouts >= 2 and maxins >= 2: nchnls = 2 else: nchnls = 1 ``` -------------------------------- ### Get Maximum Output Channels for Audio Device (pyo) Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/audio.html Details how to retrieve the maximum number of output channels supported by a specific audio device using `pyo`'s `pa_get_output_max_channels` function. The provided example demonstrates how to select a device and then query both its input and output channel limits. ```APIDOC pa_get_output_max_channels(x) x: int Device index as listed by Portaudio (see pa_get_output_devices). ``` ```Python device = 'HDA Intel PCH: STAC92xx Analog (hw:0,0)' dev_list, dev_index = pa_get_output_devices() dev = dev_index[dev_list.index(device)] print('Device index:', dev) maxouts = pa_get_output_max_channels(dev) maxins = pa_get_input_max_channels(dev) print('Max outputs:', maxouts) print('Max inputs:', maxins) if maxouts >= 2 and maxins >= 2: nchnls = 2 else: nchnls = 1 ``` -------------------------------- ### Install Pyo Python DSP Library Source: https://github.com/belangeo/pyo/blob/master/release-notes/pyo_release_1.0.2.txt Instructions to install the pyo digital signal processing library using pip. This command installs the latest compatible version of pyo for Python 3.6, 3.7, and 3.8. ```Shell python -m pip install pyo ``` -------------------------------- ### Chaining Pyo Objects for Modulation (Partial Example) Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html An introductory snippet showing the initial import statement for a script that would demonstrate chaining Pyo objects, such as using an oscillator as input for frequency modulation. ```Python from pyo import * ``` -------------------------------- ### Install WxPython for pyo GUI Features Source: https://github.com/belangeo/pyo/blob/master/docs/download.html Command to install the WxPython library, which is a dependency for using all of pyo's graphical user interface features. This installation is typically done via pip for the current Python distribution. ```Shell pip install --user wxPython ``` -------------------------------- ### pyo.getPyoExamples Function Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/api/functions/util.rst.txt Provides a dictionary listing of all examples installed alongside the pyo library. Each entry typically maps an example name to its content or path, allowing users to browse and run built-in examples. ```APIDOC pyo.getPyoExamples() -> dict Returns: A dictionary listing of the examples installed with pyo, where keys are example names and values are example details. ``` -------------------------------- ### Pyo Server Initialization Examples Source: https://github.com/belangeo/pyo/blob/master/documentation/source/winaudioinspect.rst These examples demonstrate how to initialize the Pyo Server object with various configurations. They cover setting different sampling rates (sr), buffer sizes (buffersize), channel counts (nchnls), duplex modes (duplex), and specifying Windows host APIs (winhost) such as DIRECTSOUND, WASAPI, and ASIO. ```python # sampling rate = 44100 Hz, buffer size = 256, channels = 2, full duplex, host = DIRECTSOUND s = Server() # sampling rate = 48000 Hz, buffer size = 1024, channels = 2, full duplex, host = DIRECTSOUND s = Server(sr=48000, buffersize=1024) # sampling rate = 48000 Hz, buffer size = 512, channels = 2, full duplex, host = WASAPI s = Server(sr=48000, buffersize=512, winhost="wasapi") # sampling rate = 48000 Hz, buffer size = 512, channels = 2, output only, host = ASIO s = Server(sr=48000, buffersize=512, duplex=0, winhost="asio") # sampling rate = 96000 Hz, buffer size = 128, channels = 1, full duplex, host = ASIO s = Server(sr=96000, nchnls=1, buffersize=128, duplex=1, winhost="asio") ``` -------------------------------- ### Instantiating Pyo Sine with Named Parameters Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html Illustrates how to instantiate the `Sine` object by explicitly naming parameters, allowing other parameters to retain their default values. ```Python a = Sine(mul=0.1).out() ``` -------------------------------- ### Remove Older pyo Versions on MacOS Source: https://github.com/belangeo/pyo/blob/master/docs/download.html Command to run a cleanup script on MacOS to remove older pyo installations (prior to version 1.0.0) that were installed using binary installers. This step is crucial to avoid conflicts with newer pip-installed versions. The script needs to be run with sudo for the specific Python version where the old pyo was installed. ```Shell sudo python3.6 cleanup_older_pyo_versions.py ``` -------------------------------- ### pyo.getPyoExamples Function Source: https://github.com/belangeo/pyo/blob/master/documentation/source/api/functions/util.rst Returns a dictionary listing the examples installed with pyo, allowing users to access and run built-in examples. This is a convenient way to learn from practical demonstrations. ```APIDOC Function: getPyoExamples Description: Returns a listing of the examples, as a dictionary, installed with pyo. ``` -------------------------------- ### Install pyo Python Module using pip Source: https://github.com/belangeo/pyo/blob/master/docs/download.html Provides various pip commands to install the pyo audio processing module for Python. These commands cover general user installations, specific Python version targeting (e.g., Python 3.13), Windows-specific invocations, and system-wide installations on MacOS or Linux. Pyo supports Python versions 3.9 to 3.13. ```Shell pip install --user pyo ``` ```Shell python3.13 -m pip install --user pyo ``` ```Shell py -3.13 -m pip install --user pyo ``` ```Shell sudo python3 -m pip install pyo ``` -------------------------------- ### Python: Basic SfPlayer Initialization and Playback Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/players.html This example initializes a `pyo.Server` and demonstrates the basic usage of the `SfPlayer` object. It shows how to load and play a sound file, applying custom speed (pitch), looping behavior, and output volume. ```Python s = Server().boot() s.start() snd = SNDS_PATH + "/transparent.aif" sf = SfPlayer(snd, speed=[.75,.8], loop=True, mul=.3).out() ``` -------------------------------- ### Pyo Server Initialization Examples Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/winaudioinspect.rst.txt This snippet provides various examples of initializing the `pyo.Server` object with different parameters. It demonstrates how to set sampling rate (`sr`), buffer size (`buffersize`), number of channels (`nchnls`), duplex mode (`duplex`), and the specific Windows audio host API (`winhost`) for diverse audio configurations. ```python # sampling rate = 44100 Hz, buffer size = 256, channels = 2, full duplex, host = DIRECTSOUND s = Server() # sampling rate = 48000 Hz, buffer size = 1024, channels = 2, full duplex, host = DIRECTSOUND s = Server(sr=48000, buffersize=1024) # sampling rate = 48000 Hz, buffer size = 512, channels = 2, full duplex, host = WASAPI s = Server(sr=48000, buffersize=512, winhost="wasapi") # sampling rate = 48000 Hz, buffer size = 512, channels = 2, output only, host = ASIO s = Server(sr=48000, buffersize=512, duplex=0, winhost="asio") # sampling rate = 96000 Hz, buffer size = 128, channels = 1, full duplex, host = ASIO s = Server(sr=96000, nchnls=1, buffersize=128, duplex=1, winhost="asio") ``` -------------------------------- ### Pyo Server Pre-Boot Configuration Methods Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/server.html This section outlines essential methods of the `pyo.Server` class that must be invoked to configure audio and MIDI devices, channel offsets, sampling rate, buffer size, and other core settings before the server is booted. These methods prepare the server for audio processing. ```APIDOC setInOutDevice(x): Set both input and output devices. See `pa_list_devices()`. setInputDevice(x): Set the audio input device number. See `pa_list_devices()`. setOutputDevice(x): Set the audio output device number. See `pa_list_devices()`. setInputOffset(x): Set the first physical input channel. setOutputOffset(x): Set the first physical output channel. setInOutOffset(x): Set the first physical input and output channels. setMidiInputDevice(x): Set the MIDI input device number. See `pm_list_devices()`. setMidiOutputDevice(x): Set the MIDI output device number. See `pm_list_devices()`. setSamplingRate(x): Set the sampling rate used by the server. setBufferSize(x): Set the buffer size used by the server. setNchnls(x): Set the number of output (and input if `ichnls` = None) channels used by the server. setIchnls(x): Set the number of input channels (if different of output channels) used by the server. setDuplex(x): Set the duplex mode used by the server. setVerbosity(x): Set the server's verbosity. reinit(sr, nchnls, buffersize, duplex, audio, jackname): Reinit the server's settings. deactivateMidi(): Deactivate Midi callback. setIsJackTransportSlave(x): Set if pyo's server is slave to jack transport or not. allowMicrosoftMidiDevices(): Allows the Microsoft Midi Mapper or GS Wavetable Synth devices. ``` -------------------------------- ### Launch EPyo text editor Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/download.rst.txt This command starts the EPyo text editor, which is distributed with pyo. It assumes that the Python Scripts/bin directory is in the system's PATH environment variable and WxPython is installed. ```bash epyo ``` -------------------------------- ### Python: MatrixPointer Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/matrixprocess.html A basic Python example demonstrating the initialization of a `MatrixPointer` object. It sets up a Pyo server, starts it, and creates a `NewMatrix` of a specified size, ready to be used with `MatrixPointer`. ```Python s = Server().boot() s.start() SIZE = 256 mm = NewMatrix(SIZE, SIZE) ``` -------------------------------- ### Record Synthesized Audio to WAV File using pyo Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/examples/x04-soundfiles/04-record-perf.rst.txt This Python script demonstrates how to initialize a `pyo` server, configure it to record synthesized audio to a WAV file for 10 seconds, and then play a simple FM synthesizer. It uses `os.path` to define the output file path on the user's desktop and `Server.recordOptions` to set recording parameters before calling `Server.recstart()` to begin recording. ```python from pyo import * import os s = Server().boot() # Path of the recorded sound file. path = os.path.join(os.path.expanduser("~"), "Desktop", "synth.wav") # Record for 10 seconds a 24-bit wav file. s.recordOptions(dur=10, filename=path, fileformat=0, sampletype=1) # Creates an amplitude envelope amp = Fader(fadein=1, fadeout=1, dur=10, mul=0.3).play() # A Simple synth lfo = Sine(freq=[0.15, 0.16]).range(1.25, 1.5) fm2 = CrossFM(carrier=200, ratio=lfo, ind1=10, ind2=2, mul=amp).out() # Starts the recording for 10 seconds... s.recstart() s.gui(locals()) ``` -------------------------------- ### Pyo Server Boot and Audio Source Initialization Source: https://github.com/belangeo/pyo/blob/master/docs/examples/x19-multirate/01-multi-rate-processing.html This snippet demonstrates the basic setup for a Pyo application, including booting the audio server and initializing two different audio sources (a sine wave and a flute melody) for testing purposes. The `ctrl` method is used to add a control interface for the sine wave's frequency. ```python s = Server().boot() # Two different sources for testing, a sine wave and a flute melody. src1 = Sine(freq=722, mul=0.7) src1.ctrl([SLMapFreq(722)], title="Sine frequency") ``` -------------------------------- ### Get default MIDI input device index (pyo) Source: https://github.com/belangeo/pyo/blob/master/documentation/source/api/functions/midi.rst Retrieves the index number of the default MIDI input device as identified by Portmidi. This function is part of the pyo library's MIDI setup utilities. ```APIDOC pyo.pm_get_default_input() Returns: int - The index number of Portmidi's default input device. ``` -------------------------------- ### Get default MIDI output device index (pyo) Source: https://github.com/belangeo/pyo/blob/master/documentation/source/api/functions/midi.rst Retrieves the index number of the default MIDI output device as identified by Portmidi. This function is part of the pyo library's MIDI setup utilities. ```APIDOC pyo.pm_get_default_output() Returns: int - The index number of Portmidi's default output device. ``` -------------------------------- ### Initialize and Start Pyo Server Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/opensndctrl.html A basic Python example demonstrating how to initialize and start the `pyo` audio server. This is a common prerequisite for using `pyo` objects like `OscReceive` to process audio. ```python s = Server().boot() s.start() ``` -------------------------------- ### Pyo RingMod: Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_sources/tutorials/pyoobject1.rst.txt Demonstrates a complete example of setting up a `pyo` server, loading an audio file, creating a low-frequency oscillator (LFO), and applying ring modulation using the `RingMod` object. The processed audio is then routed to the output, and a GUI is launched for interactive control of the `pyo` environment. ```Python if __name__ == "__main__": s = Server().boot() src = SfPlayer(SNDS_PATH+"/transparent.aif", loop=True, mul=.3) lfo = Sine(.25, phase=[0,.5], mul=.5, add=.5) ring = RingMod(src, freq=[800,1000], mul=lfo).out() s.gui(locals()) ``` -------------------------------- ### pyo Linseg Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/controls.html Demonstrates how to create and use a `Linseg` object in `pyo`. This example sets up a server, defines an envelope with several break-points, and uses it to control the frequency of a sine wave, then starts the envelope. ```Python s = Server().boot() s.start() l = Linseg([(0,500),(.03,1000),(.1,700),(1,500),(2,500)], loop=True) a = Sine(freq=l, mul=.3).mix(2).out() # then call: l.play() ``` -------------------------------- ### Generate Sine Wave with Modulated Frequency in Pyo Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html This Python example demonstrates how to create a sine wave with a frequency modulated by another sine wave using the Pyo audio DSP library. It initializes a Pyo server, creates a modulating sine object, and then an audible sine wave whose frequency is dynamically controlled by the modulator, finally outputting the sound and launching a GUI. ```python s = Server().boot() mod = Sine(freq=6, mul=50) a = Sine(freq=mod + 440, mul=0.1).out() s.gui(locals()) ``` -------------------------------- ### Pyo Sig Class Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/controls.html A basic Python example demonstrating how to initialize a `pyo.Server` and create a `pyo.Sig` object with a specified value. This snippet shows the fundamental steps to get a signal running in `pyo`. ```Python import random s = Server().boot() s.start() fr = Sig(value=400) ``` -------------------------------- ### Play a Sound with Pyo Source: https://github.com/belangeo/pyo/blob/master/README.md This snippet demonstrates the basic setup for audio playback in Pyo. It initializes a Pyo server, starts it, and then uses `SfPlayer` to load and play an audio file, outputting it to the default audio device. ```python from pyo import * s = Server().boot() s.start() sf = SfPlayer("path/to/your/sound.aif", speed=1, loop=True).out() ``` -------------------------------- ### Pyo Server: Boot Server Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/server.html Initializes and boots the server, making it ready for defining signal processing chains. Server parameters become effective after this call. The 'newBuffer' argument controls buffer allocation. ```APIDOC Server.boot(newBuffer: bool = True) newBuffer: Specify if the buffers need to be allocated or not. Useful to limit the allocation of new buffers when the buffer size hasn’t change. Defaults to True. ``` -------------------------------- ### Pyo BrownNoise Generator Instantiation and Playback Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/generators.html Demonstrates how to instantiate and play a brown noise generator using the Pyo library. This example boots and starts a Pyo server, then creates a `BrownNoise` object, mixes its output, and sends it to the audio output. ```python s = Server().boot() s.start() a = BrownNoise(.1).mix(2).out() ``` -------------------------------- ### Pyo PinkNoise Generator Instantiation and Playback Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/generators.html Demonstrates how to instantiate and play a pink noise generator using the Pyo library. This example boots and starts a Pyo server, then creates a `PinkNoise` object, mixes its output, and sends it to the audio output. ```python s = Server().boot() s.start() a = PinkNoise(.1).mix(2).out() ``` -------------------------------- ### Running Pyo Non-Interactively with a GUI Source: https://github.com/belangeo/pyo/blob/master/documentation/source/gettingstarted.rst Explains how to run Pyo scripts non-interactively by using the `Server.gui()` method. This method creates a control GUI that keeps the script running, allowing interaction with the server, volume control, and audio recording, addressing the issue of scripts finishing before audio is processed. ```python from pyo import * s = Server().boot() s.start() a = Sine(mul=0.01).out() s.gui(locals()) ``` -------------------------------- ### Initialize Pyo Server Instance and Attributes Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/server.html This Python code snippet demonstrates the initialization of a Pyo server instance, setting up essential attributes like channel counts, audio backend, and default input/output devices, particularly for Windows platforms. It configures the server's core operational parameters upon creation. ```python self._gui_frame = None self._nchnls = nchnls if ichnls is None: self._ichnls = nchnls else: self._ichnls = ichnls self._audio = audio self._winhost = winhost self._amp = 1.0 self._verbosity = 7 self._startoffset = 0 self._dur = -1 self._filename = None self._fileformat = 0 self._sampletype = 0 self._globalseed = 0 self._resampling = 1 self._isJackTransportSlave = False self._server.__init__(sr, nchnls, buffersize, duplex, audio, jackname, self._ichnls, midi) if sys.platform.startswith("win"): host_default_in, host_default_out = pa_get_default_devices_from_host(winhost) self._server.setInputDevice(host_default_in) self._server.setOutputDevice(host_default_out) ``` -------------------------------- ### Pyo PVBufTabLoops: Basic Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/phasevoc.html Demonstrates a basic setup and usage of `PVBufTabLoops` in Pyo. This example initializes a server, loads a sound file, performs phase vocoder analysis, and synthesizes the output using `PVBufTabLoops` for bin-independent playback. ```python s = Server().boot() s.start() f = SNDS_PATH+'/transparent.aif' f_len = sndinfo(f)[1] src = SfPlayer(f, mul=0.5) spd = ExpTable([(0,1), (512,0.5)], exp=6, size=512) pva = PVAnal(src, size=1024, overlaps=8) pvb = PVBufTabLoops(pva, spd, length=f_len) pvs = PVSynth(pvb).out() ``` -------------------------------- ### pyo.Snap Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/utils.html A Python code example demonstrating the initialization and use of the `pyo.Snap` object. This snippet sets up a Pyo server, generates a noisy MIDI signal, and then quantizes it to a specific scale using `Snap` before driving an oscillator's frequency. ```python s = Server().boot() s.start() wav = SquareTable() env = CosTable([(0,0), (100,1), (500,.3), (8191,0)]) met = Metro(.125, 8).play() amp = TrigEnv(met, table=env, mul=.2) pit = TrigXnoiseMidi(met, dist=4, x1=20, mrange=(48,84)) hertz = Snap(pit, choice=[0,2,3,5,7,8,10], scale=1) a = Osc(table=wav, freq=hertz, phase=0, mul=amp).out() ``` -------------------------------- ### Pyo Server Initialization and Basic Signal Chain Example Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/arithmetic.html Demonstrates how to initialize a `pyo` server, start it, and set up a basic audio processing chain using `SndTable` for sound loading and `Phasor` as a signal generator. This snippet illustrates the fundamental steps for creating and playing audio with `pyo`. ```Python s = Server().boot() s.start() # Back-and-Forth playback t = SndTable(SNDS_PATH + "/transparent.aif") a = Phasor(freq=t.getRate()*0.5, mul=2, add=-1) ``` -------------------------------- ### Pyo Expseg Class Usage Example Source: https://github.com/belangeo/pyo/blob/master/docs/_modules/pyo/lib/controls.html This Python example demonstrates how to initialize a Pyo server, create an `Expseg` object with a list of time-value points and enable looping, and then use it to control the frequency of a `Sine` oscillator. The `play()` method is called to start the envelope. ```Python s = Server().boot() s.start() l = Expseg([(0,500),(.03,1000),(.1,700),(1,500),(2,500)], loop=True) a = Sine(freq=l, mul=.3).mix(2).out() # then call: l.play() ``` -------------------------------- ### Initialize Pyo Server Source: https://github.com/belangeo/pyo/blob/master/docs/api/classes/arithmetic.html Demonstrates how to boot the Pyo audio server, a common first step in Pyo applications to prepare the audio engine for processing. ```Python s = Server().boot() ``` -------------------------------- ### Get Pyo Installation Version Number Source: https://github.com/belangeo/pyo/blob/master/docs/api/functions/util.html This function returns the version number of the current pyo installation. The version is provided as a 3-integer tuple, representing (major, minor, rev). For instance, version '0.4.1' would be returned as (0, 4, 1). ```APIDOC getVersion() Returns: tuple (major, minor, rev) ``` ```Python >>> print(getVersion()) >>> (0, 5, 1) ``` -------------------------------- ### Pyo Sine Class Constructor Definition Source: https://github.com/belangeo/pyo/blob/master/docs/gettingstarted.html API documentation for the `Sine` class constructor in Pyo, detailing its parameters: frequency, starting phase, amplitude multiplier, and DC offset value. ```APIDOC Sine(self, freq=1000, phase=0, mul=1, add=0) ```