Search code examples
pythonaudiopyo

Play 2+ sine waves together in python with pyo


I would like to play 2, 3 or more sine waves in python for 5 seconds. I know how to write a .au or .wav file that could do this, but now I would like to play directly to the sound card. I know how to do this with 1 sine wave using pyo, but now I would like to do this with 2 or more and I'm stuck. Could you show me the way?

Thanks!


Solution

  • The oscillators in pyo are individual entities, so we can create multiple instances which work simultaneously.

    from pyo import *
    s = Server().boot()
    osc1 = Sine(freq=440).out()
    osc2 = Sine(freq=810).out()
    s.start()
    s.gui(locals())
    

    The harmonics are quite painful, but should quite clearly show that you have two oscillators being summed.