Accessing arguments of a SinOsc

Hello!

New to the forums and SC in particular. :woozy_face::sparkles:

I would like to know how to access or ‘get’ the arguments of a given SinOsc. Is there something similar to:

mySinOsc = { SinOsc.ar(SinOsc.ar(1, 0, 250, 1000), 0, 0.3)  }
mySinOsc.getPhase;
mySinOsc.getMul;

etc…

Thank you for your help!

1 Like

Welcome HuevoMilenio!

First, I want to point out that in the first line – mySinOsc = { SinOsc.ar(SinOsc.ar(1, 0, 250, 1000), 0, 0.3) } – the variable mySinOsc actually holds a Function, not a SinOsc. You could use this Function to create a SynthDef, which gets you closer to making sound from it. You may also know you can call play on a Function to make sound.

Second, I would strongly recommend reading https://doc.sccode.org/Guides/ClientVsServer.html and https://doc.sccode.org/Reference/Server-Architecture.html to better understand the distinction between the language and server in SuperCollider.

I would be happy to answer your original question, but it depends on whether you want to access the value you’ve used to create a SinOsc without actually running your SynthDef on the server, or access the value as the SinOsc is running on the server and generating sound. My hunch is that you’re asking about the latter, but I want to make sure first.

Thank you for your reply @VIRTUALDOG. I’m not familiar with SynthDef-s yet, but I do now I could play that function to make sound. (Will read your suggested documentation).

In this case I just wanted to access the value used when creating the SinOsc without actually running the function on the server. I wanted to create a variable out of it as I was trying to figure out how they work in SC.

There’s not really a good way to do that.

A UGen such as SinOsc must be created within the function being played.

// OK
a = { SinOsc.ar * 0.1 }.play;

// not OK
o = SinOsc.ar;
a = { o * 0.1 }.play;

Because it must be created within the function, it literally doesn’t exist without running the function.

If the input value is a simple constant, then you could postln it – but if it’s a simple constant, you can read it in the code, so there’s no need to post it.

If the input is another UGen, then the concrete value will be calculated in the server – so there is no value to post without playing it in the server.

You could run it on the server and poll it.

a = {
    var trig = Impulse.ar(0);
    var modulator = SinOsc.ar(1, 0, 250, 1000);
    modulator.poll(trig);
    SinOsc.ar(modulator, 0, 0.3)
}.play;

hjh

1 Like