belangeo / pyo

Python DSP module

Home Page:http://ajaxsoundstudio.com/software/pyo/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to hide `wxPython` warnings ?

dschiller opened this issue · comments

When executing the following script I get warnings like:

WxPython is not found for the current python version.
Pyo will use a minimal GUI toolkit written with Tkinter (if available).
This toolkit has limited functionnalities and is no more
maintained or updated. If you want to use all of pyo's
GUI features, you should install WxPython, available here:
http://www.wxpython.org/


Neither WxPython nor Tkinter are found for the current python version.
Pyo's GUI features are disabled. For a complete GUI toolkit, you should
consider installing WxPython, available here: http://www.wxpython.org/
from signal import sigwait, SIGINT
from pyo import *
import os
import contextlib
import warnings

s = Server()
with open(os.devnull, "w") as f, contextlib.redirect_stdout(f):
    warnings.filterwarnings('ignore', category=PendingDeprecationWarning)
    s.boot()
s.start()

# Sets fundamental frequency.
freq = 187.5

# Roland JP-8000 Supersaw emulator.
lfo4 = Sine(0.1).range(0.1, 0.75)
osc4 = SuperSaw(freq=freq, detune=lfo4, mul=0.3).out()

# Interpolates between input objects to produce a single output
sigwait([SIGINT])
s.stop()
s.shutdown()

I don't want install wxPython but use pyo without those warnings. Is that possible to hide the warnings ?

commented

Set PYO_GUI_WX environment variable to be 0 will hide that warning.

export PYO_GUI_WX=0

Seems not to work:

from pyo import Server, Sine, SuperSaw, time
from PyQt5.QtWidgets import QApplication, QWidget
import threading
import sys
import os

os.environ['PYO_GUI_WX'] = '0'


class Sound:

    def __init__(self):
        self.server = Server()
        self.server.deactivateMidi()
        self.server.setBufferSize(512)

    def start(self):
        self.server.boot().start()

    def stop(self):
        self.server.stop()

    def _synth(self):
        # Sets fundamental frequency.
        freq = 187.5

        # Roland JP-8000 Supersaw emulator.
        lfo4 = Sine(0.1).range(0.1, 0.75)
        osc4 = SuperSaw(freq=freq, detune=lfo4, mul=0.3).out()

        while True:
            time.sleep(.0001)

    def synth(self):

        self.synth_thread = threading.Thread(target=self._synth, daemon=True)
        self.synth_thread.start()


class Window(QWidget):

    def __init__(self):
        super().__init__()
        self.show()

        self.sound = Sound()
        self.sound.start()
        self.sound.synth()

    def closeEvent(self, event):
        self.sound.stop()
        return super().closeEvent(event)


app = QApplication([])
window = Window()
sys.exit(app.exec_())
WxPython is not found for the current python version.
Pyo will use a minimal GUI toolkit written with Tkinter (if available).
This toolkit has limited functionnalities and is no more
maintained or updated. If you want to use all of pyo's
GUI features, you should install WxPython, available here:
http://www.wxpython.org/


Neither WxPython nor Tkinter are found for the current python version.
Pyo's GUI features are disabled. For a complete GUI toolkit, you should
consider installing WxPython, available here: http://www.wxpython.org/

Pyo warning: Portaudio input device `MacBook Pro Mikrofon` has fewer channels (1) than requested (2).

Makes sense. Thanks Oliver and Lex!

But still getting a bit of output regarding WxPython and Tkinter:

from PyQt5.QtWidgets import QApplication, QWidget
import threading
import sys
import os

os.environ['PYO_GUI_WX'] = '0'

from pyo import Server, Sine, SuperSaw, time  # noqa


class Sound:

    def __init__(self):
        self.server = Server()
        self.server.deactivateMidi()
        self.server.setBufferSize(512)

    def start(self):
        self.server.boot().start()

    def stop(self):
        self.server.stop()

    def _synth(self):
        # Sets fundamental frequency.
        freq = 187.5

        # Roland JP-8000 Supersaw emulator.
        lfo4 = Sine(0.1).range(0.1, 0.75)
        osc4 = SuperSaw(freq=freq, detune=lfo4, mul=0.3).out()

        while True:
            time.sleep(.0001)

    def synth(self):
        self.synth_thread = threading.Thread(target=self._synth, daemon=True)
        self.synth_thread.start()


class Window(QWidget):

    def __init__(self):
        super().__init__()
        self.show()
        self.sound = Sound()
        self.sound.start()
        self.sound.synth()

    def closeEvent(self, event):
        self.sound.stop()
        return super().closeEvent(event)


app = QApplication([])
window = Window()
sys.exit(app.exec_())
Neither WxPython nor Tkinter are found for the current python version.
Pyo's GUI features are disabled. For a complete GUI toolkit, you should
consider installing WxPython, available here: http://www.wxpython.org/

Pyo warning: Portaudio input device `MacBook Pro Mikrofon` has fewer channels (1) than requested (2).

Can this be fixed?