Clarification on fm.carrier

28 views
Skip to first unread message

Gabriele Battaglia

unread,
Dec 26, 2023, 4:53:02 PM12/26/23
to pyo-d...@googlegroups.com

Hi.

I'm trying this simple example:


from pyo import *
s=Server().boot()
s.start()
s.amp=.5
print("Example from Python Audio Cookbook.")
adsr = Adsr(attack=.05,decay=.2,sustain=.6,release=.1,dur=2)
fm = FM(carrier=200, ratio=.248, index=adsr*8,mul=adsr*0.3).mix(2).out()
adsr.play()
while True:
    f1=input("q to quit> ")
    if f1=="q": break
    fm.carrier=float(f1)
    adsr.play()
To hear and test different values of carrier. But it doesn't takes the new values and it remains fixed on 200, the starting point.
Why?
Thanks.

Sean Wayland

unread,
Dec 26, 2023, 6:45:25 PM12/26/23
to pyo-d...@googlegroups.com
I would just edit the variable in the file or move the "input" part out of a loop ( above it ) that was being used to play a pyo object. 
alternatively you could parse an argument with sys arg or argparse and pass the value in when executing the file 
there are  examples in the pyo examples of sliders used to change synth settings 
you could hack into this file for example and create a slider and use it in your script 



--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/222a07a6-ecb7-4abb-9351-2fa61e8ea6eb%40libero.it.


--


http://seanwayland.com

https://github.com/seanwayland



Sean Wayland           

US cell phone: +1 (347)5231455


Alexandros Drymonitis

unread,
Dec 27, 2023, 4:23:02 AM12/27/23
to pyo-d...@googlegroups.com

The fm object is internally turned to an object of the Mix() class, because you call its mix() method in the initialization line. The Mix() class has no carrier member, and Python silently ignores the `fm.carrier=float(f1)` line.

To remedy this, don't call the mix() method and don't send it to your speakers, but pass fm to a Sig() object for which you will call mix() and send that to the output. Then you can pass the values you want.

This is explained thoroughly throughout the 3rd chapter.

Gabriele Battaglia

unread,
Dec 27, 2023, 5:02:45 AM12/27/23
to pyo-d...@googlegroups.com
Ciao Alexandros!

Ofcourse with your help, it works perfectly. Now the concept is more
clear to me.


Just to fix...


If I create an object like a Sine which I call a, then I pass it into
another object like a Sig and I call this last one a1 and I send a1 to out.

Then a still exist and I cuold operate on it and at the same time, even
a1 is alife and I can operate on it without need to send it to out at
every modifications I do.

Is this right?

And what's happens if I delete a. A1 still exist using an a's copy or
does it stop from being alive?


Many many thanks for your time.


Gabe.

Alexandros Drymonitis

unread,
Dec 27, 2023, 5:20:13 AM12/27/23
to pyo-d...@googlegroups.com

On 12/27/23 12:02, Gabriele Battaglia wrote:
> Ciao Alexandros!
>
> Ofcourse with your help, it works perfectly. Now the concept is more
> clear to me.
>
>
> Just to fix...
>
>
> If I create an object like a Sine which I call a, then I pass it into
> another object like a Sig and I call this last one a1 and I send a1 to
> out.
>
> Then a still exist and I cuold operate on it and at the same time,
> even a1 is alife and I can operate on it without need to send it to
> out at every modifications I do.
>
> Is this right?
That is correct, but if "a1" is sent to the speakers, and its value is
"a", then, whatever modification you do to "a" will be immediately audible.
>
> And what's happens if I delete a. A1 still exist using an a's copy or
> does it stop from being alive?
"a1" will still exist, but there will not be much you can do to is,
other than it's mul and add attributes, since "a" will not exist any
more. But you can create another object of whatever class you want, and
change the value of "a1", and this will work fine.

Gabriele Battaglia

unread,
Dec 27, 2023, 5:35:35 AM12/27/23
to pyo-d...@googlegroups.com
Thank you.

Olivier Bélanger

unread,
Dec 27, 2023, 8:43:25 AM12/27/23
to pyo-d...@googlegroups.com
Hello,

You can even  do it without a Sig object, all you need is to split the line:

fm = FM(carrier=200, ratio=.248, index=adsr*8, mul=adsr*0.3)
out = fm.mix(2).out()

You still have access to the FM object ("fm"), and "out" is a Mix object, created internally by FM, whose signals are sent to the speakers.

Olivier



On Wed, Dec 27, 2023 at 5:35 AM Gabriele Battaglia <gabriele....@gmail.com> wrote:
Thank you.


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.

Alexandros Drymonitis

unread,
Dec 27, 2023, 4:12:53 PM12/27/23
to pyo-d...@googlegroups.com

Aaaah, I should have known this before I wrote my book... well, for the second edition :)

Reply all
Reply to author
Forward
0 new messages