def soundInit(device=''): global soundPresent, mixer, server, pyoPresent try: pa_device_index = Ice.Application.communicator().getProperties().getPropertyWithDefault('RenderingEngine.PADevice', None) except: pa_device_index = None if pyoPresent: try: pyo.pa_list_devices() server = pyo.Server() server.setDuplex(0) pai = None if pa_device_index: try: pai = int(pa_device_index) server.setOutputDevice(pai) Logger.trace("info", "Sound system using device" + str(pai) + " (was defined in RenderingEngine.PADevice)") except: Logger.warning("Sound system was passed an invalid device from ICE, trying default device") if not pai and hasattr(pyo, "PYO_VERSION") and pyo.PYO_VERSION == "0.4.0": # only try to use ASIO if the new version of pyo is installed out_devices = pyo.pa_get_output_devices() od_index = 0 for od in out_devices[0]: if "ASIO" in od: pai = int(out_devices[1][od_index]) server.setOutputDevice(pai) Logger.trace("info", "Found ASIO device, using device " + str(pai)) break od_index += 1 if not pai: Logger.trace("info", "Sound system using default device " + str(pyo.pa_get_default_output())) server.boot() server.start() if server.getIsStarted() == 0: Logger.warning("Sound has not started up, trying mono") server.setNchnls(1) server.boot() server.start() if server.getIsStarted() == 0: Logger.warning("Sound has still not started up, giving up") soundPresent = False else: # server.gui(locals()) mixer = pyo.Mixer() mixer.out() soundPresent = True Logger.trace("info", "Sound system up and running") except: Logger.warning("SoundInit failed, pyaudio could not initialise, sound will not be available") soundPresent = False raise if not soundPresent: Logger.warning("pyo is not present, sound will not be available")
def _query_devices(): f = StringIO() with redirect_stdout(f): pyo.pa_list_devices() s = f.getvalue().strip().split("\n")[1:] devices = [] for device in s: info = {} for v in device.split(",")[1:]: info[v.strip().split(": ")[0]] = v.strip().split(": ")[1] info["id"], info["type"] = device.split(",")[0].split(": ") devices.append(info) return devices
def main(): parser = argparse.ArgumentParser( description="runs a sampler that can be controlled with push 1.") parser.add_argument('--midi_in', default=0, type=int, help='MIDI IN port of push interface') parser.add_argument('--midi_out', default=2, type=int, help='MIDI OUT port of push interface') parser.add_argument('--list_devices', action='store_true') parser.add_argument('--audio_out_device', default=0, type=int, help='audio output device (start with option ' '--list_devices too see available devices)') args = parser.parse_args() if args.list_devices: pyo.pa_list_devices() pyo.pm_list_devices() sys.exit() server = pyo.Server() server.setOutputDevice(args.audio_out_device) server.setMidiInputDevice(args.midi_in) server.setMidiOutputDevice(args.midi_out) server.boot() server.start() push = PushInterface(server) ui = PushUI(server) ui.sampler.load_sample('samples/BD-short.wav', 0) ui.sampler.load_sample('samples/SD-short.wav', 1) ui.sampler.load_sample('samples/LT-short.wav', 2) ui.sampler.load_sample('samples/MT-short.wav', 3) ui.sampler.load_sample('samples/HT-short.wav', 4) ui.sampler.load_sample('samples/RS-short.wav', 5) ui.sampler.load_sample('samples/CH-short.wav', 6) ui.sampler.load_sample('samples/OH-short.wav', 7) ui.sampler.start() while 1: time.sleep(1)
def list_devices(): pyo.pa_list_devices()
import datetime import random from functools import partial from scipy.signal import argrelextrema if ENABLE_SONIFICATION: import pyo RATE = 48000 # audio sampling rate, should stay like this. # other rates might require new energy calibration # and will in any case require modification of analysis scripts FRAME_SIZE = 4096 # size of waveform frame size. could be modified, but not tested if ENABLE_SONIFICATION: s = pyo.Server(duplex=0).boot() s.deactivateMidi() s.setOutputDevice(1) pyo.pa_list_devices() s.start() tab_m = pyo.HarmTable([ 1, 0, 0, 0, 0, .3, 0, 0, 0, 0, 0, .2, 0, 0, 0, 0, 0, .1, 0, 0, 0, 0, .05 ]).normalize() tab_p = pyo.HarmTable([1, 0, .33, 0, .2, 0, .143, 0, .111]) class Ring: def __init__(self, fport=250, fmod=100, amp=.3): self.mod = pyo.Osc(tab_m, freq=fmod, mul=amp) self.port = pyo.Osc(tab_p, freq=fport, mul=self.mod) def out(self): self.port.out()
def print_infos(): print(pyo.pa_list_devices())