[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change mixer values after initialisation #238

Open
luisarandas opened this issue May 27, 2022 · 1 comment
Open

Can't change mixer values after initialisation #238

luisarandas opened this issue May 27, 2022 · 1 comment

Comments

@luisarandas
Copy link
luisarandas commented May 27, 2022

Hello all.

I am trying to control mixer volumes through custom callbacks but that doesn't seem to work. I think the only thing that works is when I setup the server (which is Flask) and declare the values, when I try to change an amp value with a socket after the server starts, it takes no effect. I have a setup similar to #182, like this:

audio_server = pyo.Server(sr=44100, nchnls=2, buffersize=512)
audio_server.boot()
audio_server.start()
background_audio_table = pyo.SndTable("background.wav")
background_freq = background_audio_table.getRate()
background_sound = pyo.Osc(table=background_audio_table, freq=background_freq, mul=1)
audio_mixer = pyo.Mixer(outs=2, chnls=2) # this is the end of the chain
audio_mixer.addInput(0, background_sound)
# i will then add 0->n based on the nr of sounds I'll add and set the amp nr respectively
audio_mixer.setAmp(0,0,1)
audio_mixer.setAmp(0,1,1)
audio_mixer.out()

I then have some callbacks on the keyboard that will call functions in the server file, with methods like:

@socketio.on('loremipsum')
def _loremipsum(data):
    audio_mixer.setAmp(0, 0, 0)
    audio_mixer.setAmp(0, 1, 0)

This should put the volume of the background track to 0 right? Anyhow the audio doesn't stop, and to be honest doesn't seem to change at all (qualitative opinion). Any idea how to solve this?

Thanks

@belangeo
Copy link
Owner
belangeo commented Nov 4, 2022

The function "_loremipsum" is declared in your server file, but are you sure that the call doesn't actually occurs in another thread?

When used locally, it works as expected:

import pyo

audio_server = pyo.Server(sr=44100, nchnls=2, buffersize=512)
audio_server.boot()
audio_server.start()
background_audio_table = pyo.SndTable(pyo.SNDS_PATH+"/transparent.aif")
background_freq = background_audio_table.getRate()
background_sound = pyo.Osc(table=background_audio_table, freq=background_freq, mul=1)
audio_mixer = pyo.Mixer(outs=2, chnls=2) # this is the end of the chain
audio_mixer.addInput(0, background_sound)
# i will then add 0->n based on the nr of sounds I'll add and set the amp nr respectively
audio_mixer.setAmp(0,0,1)
audio_mixer.setAmp(0,1,1)
audio_mixer.out()

def _loremipsum(data):
    audio_mixer.setAmp(0, 0, 0)
    audio_mixer.setAmp(0, 1, 0)

audio_server.gui(locals())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants