belangeo / pyo

Python DSP module
GNU Lesser General Public License v3.0
1.32k stars 132 forks source link

How to hide `wxPython` warnings ? #259

Closed dschiller closed 1 year ago

dschiller commented 1 year ago

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 ?

lextoumbourou commented 1 year ago

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

export PYO_GUI_WX=0
dschiller commented 1 year ago

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).
belangeo commented 1 year ago

You need to do it before importing pyo!

Olivier

Le mar. 21 févr. 2023 à 12:30, Dirk Schiller @.***> a écrit :

Seems not to work:

from pyo import Server, Sine, SuperSaw, timefrom PyQt5.QtWidgets import QApplication, QWidgetimport threadingimport sysimport os os.environ['PYO_GUI_WX'] = '1'

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'sGUI 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).

— Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/259#issuecomment-1438853684, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXKJTALWLZG4VPVMPUBPY3WYT3TNANCNFSM6AAAAAAU6PUHBE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dschiller commented 1 year ago

Makes sense. Thanks Oliver and Lex!

dschiller commented 1 year ago

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).
belangeo commented 1 year ago

Yes, it's true... There's nothing to prevent this message from being printed right now...

Olivier

On Tue, Feb 21, 2023 at 12:34 PM Dirk Schiller @.***> wrote:

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

from PyQt5.QtWidgets import QApplication, QWidgetimport threadingimport sysimport 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 shouldconsider installing WxPython, available here: http://www.wxpython.org/Pyo warning: Portaudio input device MacBook Pro Mikrofon has fewer channels (1) than requested (2).

— Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/259#issuecomment-1438859350, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXKJTFUNJRJC672CWRKBNDWYT4EHANCNFSM6AAAAAAU6PUHBE . You are receiving this because you commented.Message ID: @.***>

jacksongoode commented 8 months ago

Can this be fixed?