belangeo / pyo

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

Panning ignored by Mixer? #182

Closed jelling closed 3 years ago

jelling commented 4 years ago

I can pan audio fine when not using the mixer but when I add the panned audio into the Mixer the panning is lost. Is this supposed to work or do I misunderstand when/how to use the mixer?

from pyo import *

s = Server().boot()
s.start()

# Setup Mixer
mm = Mixer(outs=2, chnls=1)

# Load Files
path = "/Users/jelling/dev/performa/server/audio" 

# Play files - works
# speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2).out(0)
# band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2).out(1)

# Play files and pan without mixer - works
# speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)
# band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

# speechPanned = Pan(speech,2,.5).out() # pan to center
# bandPanned = Pan(band,2,0,.5).out(1) # pan to center

# Play via mixer - works
# speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)
# band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

# mm.addInput(0, speech.out())
# mm.addInput(1, band.out(1))

# Play panned files via mixer - panning to center has no effect
speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)
band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

# Center pan does not take effect
speechPanned = Pan(speech, 1, 0.5)
bandPanned = Pan(band, 1, 0.5)

# Exposed pan controls in gui - moving controls still has no effect
speechPanned.ctrl()
bandPanned.ctrl()

mm.addInput(1, speechPanned.out(0))
mm.addInput(0, bandPanned.out(1))

s.gui(locals())
stripwax commented 4 years ago

Does it work if you initialise the mixer with channels=2 instead of channels=1 ?

On Mon, 18 May 2020, 19:31 Jon Elling, notifications@github.com wrote:

I can pan audio fine when not using the mixer but when I add the panned audio into the Mixer the panning is lost. Is this supposed to work or do I misunderstand when/how to use the mixer?

from pyo import *

s = Server().boot() s.start()

Setup Mixer

mm = Mixer(outs=2, chnls=1)

Load Files

path = "/Users/jelling/dev/performa/server/audio"

Play files - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2).out(0)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2).out(1)

Play files and pan without mixer - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

speechPanned = Pan(speech,2,.5).out() # pan to center

bandPanned = Pan(band,2,0,.5).out(1) # pan to center

Play via mixer - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

mm.addInput(0, speech.out())

mm.addInput(1, band.out(1))

Play panned files via mixer - panning to center has no effect

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2) band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

Center pan does not take effect

speechPanned = Pan(speech, 1, 0.5) bandPanned = Pan(band, 1, 0.5)

Exposed pan controls in gui - moving controls still has no effect

speechPanned.ctrl() bandPanned.ctrl()

mm.addInput(1, speechPanned.out(0)) mm.addInput(0, bandPanned.out(1))

s.gui(locals())

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/182, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF47HFMZQAYED72CLL275DRSF5IFANCNFSM4NEKGTZQ .

jelling commented 4 years ago

No it does not

belangeo commented 4 years ago

Hi,

On Mon, May 18, 2020 at 2:31 PM Jon Elling notifications@github.com wrote:

I can pan audio fine when not using the mixer but when I add the panned audio into the Mixer the panning is lost. Is this supposed to work or do I misunderstand when/how to use the mixer?

from pyo import *

s = Server().boot() s.start()

Setup Mixer

mm = Mixer(outs=2, chnls=1)

Load Files

path = "/Users/jelling/dev/performa/server/audio"

Play files - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2).out(0)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2).out(1)

Play files and pan without mixer - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

speechPanned = Pan(speech,2,.5).out() # pan to center

bandPanned = Pan(band,2,0,.5).out(1) # pan to center

This is not panned to center, it's full left (Pan(band, outs=2, pan=0, spread=0.5) # spread does nothing in stereo.

Play via mixer - works

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2)

band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

mm.addInput(0, speech.out())

mm.addInput(1, band.out(1))

You don't play via Mixer, you send the signals to the audio outputs with .out() and .out(1). The signals are added to the Mixer but the Mixer's outputs are not used.

Play panned files via mixer - panning to center has no effect

speech = SfPlayer(path + "/gettysburg10.wav", loop=True, mul=.2) band = SfPlayer(path + "/CantinaBand60.wav", loop=True, mul=.2)

Center pan does not take effect

speechPanned = Pan(speech, 1, 0.5) bandPanned = Pan(band, 1, 0.5)

This is not center pan either... With outs=1, it's a simple thru (only one signal stream).

Exposed pan controls in gui - moving controls still has no effect

speechPanned.ctrl() bandPanned.ctrl()

For the very same reason!

mm.addInput(1, speechPanned.out(0)) mm.addInput(0, bandPanned.out(1))

Same as before, Mixer's outputs are not used, signals are sent the the soundcard with the calls .out() and .out(1).

Olivier

s.gui(locals())

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/182, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXKJTHBQYGYQEPZ244TR6TRSF5IHANCNFSM4NEKGTZQ .

jelling commented 4 years ago

@belangeo thank you for the detailed response. Two remaining questions:

# Play panned files via mixer

# Center both - works
# speechPanned = Pan(speech, 2,pan=0.5)
# bandPanned = Pan(band, 2, pan=0.5)

# tighter panning - works
# speechPanned = Pan(speech, 2,pan=0.2)
# bandPanned = Pan(band, 2, pan=0.8)

# hard panned -  only speech is heard
speechPanned = Pan(speech, 2,pan=0)
bandPanned = Pan(band, 2, pan=1)

mm.addInput(0, speechPanned)
mm.addInput(1, bandPanned)

# Had to set volume for each channel for each input
# is there a one-line way of doing this? not a big deal if not
mm.setAmp(0,0,3)
mm.setAmp(0,1,3)

mm.setAmp(1,0,3)
mm.setAmp(1,1,3)

mm.out() 
jelling commented 4 years ago

On further examination, the panning above may not be working for 0.2 or 0.5. I suspect the .setAmp command is overwriting the effect of the panning. Is that true? If so, could I trouble you for a simple example of how to properly pan with the mixer? I don't hear anything unless I use setAmp to set volume.

belangeo commented 4 years ago

Have you set the Mixer's number of channels per output to 2 (chnls argument) ? This is working as expected:

mm = Mixer(outs=2, chnls=2)

speech = Sine(2000, mul=Sine(4).range(0, 0.3))
band = Sine(1000, mul=Sine(8).range(0, 0.3))

# hard panned -  only speech is heard
speechPanned = Pan(speech, 2,pan=0)
bandPanned = Pan(band, 2, pan=1)

mm.addInput(0, speechPanned)
mm.addInput(1, bandPanned)

# Had to set volume for each channel for each input
# is there a one-line way of doing this? not a big deal if not
mm.setAmp(0,0,3)
mm.setAmp(0,1,3)

mm.setAmp(1,0,3)
mm.setAmp(1,1,3)

mm.out() 
belangeo commented 3 years ago

Closing as i don't think there is anything to fix here.