Re: [chuck-dev] chuck-dev Digest, Vol 65, Issue 2
![](https://secure.gravatar.com/avatar/7dd296e3cd781e5aed4b0d4e6a89bc12.jpg?s=120&d=mm&r=g)
Hi Spencer, thanks for this very useful piece of information ! Of course it would make sense to have functions like Michael showed included in Std or Math, but to be able to run your own .ck files automatically at startup is also a feature that is ridiculously useful, do you think it can also be included in the next version of mini-audicle ? Cheers, Casper On 3 jan. 2013, at 18:00, chuck-dev-request@lists.cs.princeton.edu wrote:
Send chuck-dev mailing list submissions to chuck-dev@lists.cs.princeton.edu
To subscribe or unsubscribe via the World Wide Web, visit https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev or, via email, send a message with subject or body 'help' to chuck-dev-request@lists.cs.princeton.edu
You can reach the person managing the list at chuck-dev-owner@lists.cs.princeton.edu
When replying, please edit your Subject line so it is more specific than "Re: Contents of chuck-dev digest..." Today's Topics:
1. Re: add methods to Std or Math (Spencer Salazar)
From: Spencer Salazar
Subject: Re: [chuck-dev] add methods to Std or Math Date: 3 januari 2013 01:33:47 CET To: ChucK Developer Mailing List Reply-To: ChucK Developer Mailing List Hey Michael,
Yeah, these are super useful functions. I have these and a few others defined in a public class called "Std2" whose source file is in my chugin directory. ChucK executes .ck files in the chugin directory at launch, so they are pretty much available for general usage on my system. I think in the future it would make sense/be easy to have these builtin to the language itself though.
spencer
On Mon, Dec 31, 2012 at 12:53 PM, Michael Heuer
wrote: Hello, I find myself using the following all the time and was wondering how difficult it would be to add them to Std or Math
fun static int constrain(int value, int min, int max) { if (value < min) { return min; } if (value > max) { return max; } return value; }
fun static float constrainf(float value, float min, float max) { if (value < min) { return min; } if (value > max) { return max; } return value; }
fun static float interp(float value, float sourceMin, float sourceMax, float targetMin, float targetMax) { return targetMin + (targetMax - targetMin) * ((value - sourceMin) / (sourceMax - sourceMin)); }
Thanks,
michael _______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
_______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
![](https://secure.gravatar.com/avatar/f0a72602304692921cf57db98342d186.jpg?s=120&d=mm&r=g)
Hey Casper,
Automatically executing .ck files at startup works in the current release
version of chuck. It was introduced as a way of allowing "chugins" that
were written purely in ChucK code.
spencer
On Fri, Jan 4, 2013 at 1:44 AM, Casper Schipper
Hi Spencer,
thanks for this very useful piece of information ! Of course it would make sense to have functions like Michael showed included in Std or Math, but to be able to run your own .ck files automatically at startup is also a feature that is* *ridiculously useful, do you think it can also be included in the next version of mini-audicle ?
Cheers, Casper
On 3 jan. 2013, at 18:00, chuck-dev-request@lists.cs.princeton.edu wrote:
Send chuck-dev mailing list submissions to chuck-dev@lists.cs.princeton.edu
To subscribe or unsubscribe via the World Wide Web, visit https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev or, via email, send a message with subject or body 'help' to chuck-dev-request@lists.cs.princeton.edu
You can reach the person managing the list at chuck-dev-owner@lists.cs.princeton.edu
When replying, please edit your Subject line so it is more specific than "Re: Contents of chuck-dev digest..." Today's Topics:
1. Re: add methods to Std or Math (Spencer Salazar)
*From: *Spencer Salazar
*Subject: **Re: [chuck-dev] add methods to Std or Math* *Date: *3 januari 2013 01:33:47 CET *To: *ChucK Developer Mailing List *Reply-To: *ChucK Developer Mailing List Hey Michael,
Yeah, these are super useful functions. I have these and a few others defined in a public class called "Std2" whose source file is in my chugin directory. ChucK executes .ck files in the chugin directory at launch, so they are pretty much available for general usage on my system. I think in the future it would make sense/be easy to have these builtin to the language itself though.
spencer
On Mon, Dec 31, 2012 at 12:53 PM, Michael Heuer
wrote: Hello,
I find myself using the following all the time and was wondering how difficult it would be to add them to Std or Math
fun static int constrain(int value, int min, int max) { if (value < min) { return min; } if (value > max) { return max; } return value; }
fun static float constrainf(float value, float min, float max) { if (value < min) { return min; } if (value > max) { return max; } return value; }
fun static float interp(float value, float sourceMin, float sourceMax, float targetMin, float targetMax) { return targetMin + (targetMax - targetMin) * ((value - sourceMin) / (sourceMax - sourceMin)); }
Thanks,
michael _______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
_______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
_______________________________________________ chuck-dev mailing list chuck-dev@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-dev
![](https://secure.gravatar.com/avatar/fa5a8de5c6e6c5838fc8106b390c7a6d.jpg?s=120&d=mm&r=g)
On Sat, Jan 05, 2013 at 03:16:56PM -0800, Spencer Salazar wrote:
Hey Casper, Automatically executing .ck files at startup works in the current release version of chuck. It was introduced as a way of allowing "chugins" that were written purely in ChucK code.* spencer
Just thinking out loud here, fire at will and shoot holes. Would it make sense to include a "~.chuckrc" in the list of such files (with a matching kind of thing for Windows)? I also imagine that such a file might use a Startup.foo() Type namespace, reserved for files run as the VM starts. Here "foo" would be things that would ordinarily be commandline flags like; Startup.inChannels() Startup.outChannels() Startup.bitRate() etc. This would remove the need for scripts to start the VM in different ways for different patches and .chuckrc would set defaults, for example to deal with the case where we would use multiple soundcards. The mini has such settings, ChucK doesn't, I imagine they'd share the same file. Note that caution-to-the-wind would require a y/[n] dialogue to prevent the theoretical risk of a ChucK virus flattening a Computer Music lab. I think this would probably be quite practical, but I also imagine it could have huge repercussions. I'm not proposing it so much as I'm inviting critique. Fire at will :-) Kas.
participants (3)
-
Casper Schipper
-
Kassen
-
Spencer Salazar