Hi Claudio,


Since you mentioned the command line I suppose you want to pass arguments to a program (it is also possible to pass it to a shred, but not sure that is what you meant).

If that's the case well then yes, programs can receive floats arguments from command line.

Here's an example:


// loop through all the arguments
// those which are not 'floats' will be printed as 0
if(me.args())
{
    for(0 => int c; c < me.args(); c++)
    {
    	chout <= Std.atof(me.arg(c)) <= " ";
    }
    chout <= IO.nl();
}
Std.atof(me.arg(0)) => float myArg;
chout <= "1st argument: " <= myArg <= IO.nl();


You can launch this program and pass one or more args the following way (assuming you saved it as myScript.ck):


    
chuck myScript:1.23:5555:thridArg


where you have 3 args: 1.23, 5555, thirdArg

The colon character ":" is used to separate the various arguments, with no space between them.

me.arg() returns all the arguments as strings, regardless of their type (numbers, literals), so you need to convert them (when possible).

Std.atof() and Std.atoi() (ASCII to Float and ASCII to Int - more info here) will do the job, but keep in mind that when the argument passed is a 'string' that can't be properly converted into a number (ie "thirdArg"), they'll return 0.


Now this is just the way you can pass arguments to a program, then you'll have to implement a way to make it fade out.

The only thing that is not clear to me yet, is how you want to use this to actually fade out and terminate a program, considering the arguments are passed when the program is launched.

But anyway, let me know if you have any questions, and/or if I can be of any help.



Cheers,

Mario





On 01/06/2020 18:36, Claudio Donaggio wrote:
Hi Mario and thanks for your response!
Is it possible for a shred to receive an float argument, from Command Line, that is the Gain of the shred and so gradually and manually faing  the shred?
Thanks for answering my surely stupid question!

Claudio

Il lun 1 giu 2020, 18:00 <chuck-users-request@lists.cs.princeton.edu> ha scritto:
Send chuck-users mailing list submissions to
        chuck-users@lists.cs.princeton.edu

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
or, via email, send a message with subject or body 'help' to
        chuck-users-request@lists.cs.princeton.edu

You can reach the person managing the list at
        chuck-users-owner@lists.cs.princeton.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of chuck-users digest..."
Today's Topics:

   1. Re: Shreds fade out (mario buoninfante)



---------- Forwarded message ----------
From: mario buoninfante <mario.buoninfante@gmail.com>
To: chuck-users@lists.cs.princeton.edu
Cc: 
Bcc: 
Date: Sun, 31 May 2020 19:31:28 +0100
Subject: Re: [chuck-users] Shreds fade out

Hi Claudio,

I suspect ChucK just 'kills' the programs when you run

> chuck - 1

from terminal. What it does it's just sending the 'remove' command to the Virtual Machine, so the program itself is not really aware of what's going on.

If you want to fade the program out (or do any other operation) before removing it, you must find a way to let it know first, if that makes sense.

One solution could be to kill (and maybe launch as well) your program from a different ChucK script (see Machine section here: https://en.flossmanuals.net/chuck/_full/#standard-libraries), at this point you could put the 2 in communication and have the parent program sending an Event to the child before killing it, so that the latter has the time to fade out and then 'remove' itself (ie me.exit()).

One other way could be to have all your programs able to receive msg via OSC.

Then you have a dedicate program that deals with removing them, sending messages via OSC.

For example you can have a cleanup.ck program that simply takes one argument (provided via terminal) that is the ID of the program to remove.

For example:

> cleanup.ck:12

to remove the program with the ID 12.

When this is launched it fires an OSC message that looks like this:

"remove x"

where 'x' is the ID of the program to remove.

Now all the other "active" programs receive this message, but only the one with the right ID will respond to it and maybe run your cleanupAndLeave() function, that fades out and exits (me.exit()).

This of course means that all your other programs need to have a simple parser that deals with the incoming OSC msg.


Of course I don't know anything about the context here, so these solutions could be not suitable for you.

Maybe if you share a bit more about how and why you're trying to achieve this, we'd be able to provide a bit more support.


Hope this helps, anyway.


Cheers,

Mario




On 30/05/2020 23:33, Claudio Donaggio wrote:


Hi all!
I was wondering if there is a way to smoothly fade out a shred. Example: from command line you add a shred with chuck + shred.ck and remove it with chuck - 1. But when you remove the shred or replace it gets cut off instantly. I am sure there is a way to dinamically scale the gain from 1 to 0 smoothly before remove the shred, but I do not have a clue on how to go about it...
Thanks!
Claudio

Inviato dal mio dispositivo mobile Huawei


_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users