Re: [chuck-users] cast dur to time?
Mike wrote:
Still, this would be sugar.
I really like the argument that if (time / duration = float) is legal, then (time / float = duration) should also be legal, however, it also follows that (time = duration * float), which I don't like. (2::second * 4) ought to return 8::second. So, I think that we're dealing with concepts here that don't fit squarely into the model of mathematics. After all, we don't multiply strings and floats, do we?
I'm all for a more rigorous understanding of these types, though. This is all very confusing.
-Mike
What I think we're dealing with here mathematically is affine spaces. In an affine space you have points and vectors that connect them. The difference between a regular vector space is that there is no "true" origo but everything is relative. Also the operations on points differ from operations with vectors. Here the big letters denote points in an affine space and small letters denote vectors: -For each two points A and B we have an unambigious vector ab that connects them. -For each three points A, B and C: ac = ab + bc Operations: A - B = x A + x = B But: A + B = (undefined), (How do you add points together? Makes no sense) And thus A*(scalar) = (undefined), (In a vector space all this would be legal) Compare to time: time - time = dur; time + dur = time; time + time = (undefined) time*float = (undefined) The point (no pun intended) with affine spaces is that you can only make new points if you already have at least one to begin with. You can't just throw in a point if you don't define how it relates to the points already present. For the syntax issues I see no harm in adding me.bith = the time since the VM's start that the shred was sporked. To me it's just not a big deal to type: now => time birth; At the beginning of a sporkable funtion. But hey. We all find different things intuitive or counter-intuitive. Cheers -Pyry
Okay... affine spaces. I'm going to have to wikipedia that one, i'm
afraid (high school math ain't doin' it for me here ;-) I understand
the analogy of vectors and point, though--I think that lends some
credence to the idea that Chuck is already on the right path as far
how the dur and time types work.
I still have a few questions. The first is for Kassen: Why do you
want to know the VM start time? (Just curious) Although, I don't
like the idea of dur -> time casting, I don't see why the following
isn't legal:
0.0 $ time => time zero;
Also, if we have a special keyword for the birth of the VM, on the
precedent of how "now" currently works, does that mean that
subtracting duration from "birth" would be equivalent to adding
duration to "now?" Does that add anything, or just confuse things
further?
1::second => now; // equivalent to 1::second +=> now; as Kassen reminded us
thus:
1::second -=> birth; // same thing, effectively???
I'm just thinking out loud...
-Mike
On Jan 8, 2008 10:35 AM, pibsid@suomi24.fi
Mike wrote:
Still, this would be sugar.
I really like the argument that if (time / duration = float) is legal, then (time / float = duration) should also be legal, however, it also follows that (time = duration * float), which I don't like. (2::second * 4) ought to return 8::second. So, I think that we're dealing with concepts here that don't fit squarely into the model of mathematics. After all, we don't multiply strings and floats, do we?
I'm all for a more rigorous understanding of these types, though. This is all very confusing.
-Mike
What I think we're dealing with here mathematically is affine spaces. In an affine space you have points and vectors that connect them. The difference between a regular vector space is that there is no "true" origo but everything is relative. Also the operations on points differ from operations with vectors.
Here the big letters denote points in an affine space and small letters denote vectors: -For each two points A and B we have an unambigious vector ab that connects them. -For each three points A, B and C: ac = ab + bc
Operations: A - B = x A + x = B But: A + B = (undefined), (How do you add points together? Makes no sense) And thus A*(scalar) = (undefined), (In a vector space all this would be legal)
Compare to time: time - time = dur; time + dur = time; time + time = (undefined) time*float = (undefined)
The point (no pun intended) with affine spaces is that you can only make new points if you already have at least one to begin with. You can't just throw in a point if you don't define how it relates to the points already present.
For the syntax issues I see no harm in adding me.bith = the time since the VM's start that the shred was sporked.
To me it's just not a big deal to type: now => time birth; At the beginning of a sporkable funtion. But hey. We all find different things intuitive or counter-intuitive.
Cheers -Pyry _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://semiotech.org http://blog.deadlylittlepills.com http://www.murderkills.com http://shadowofaculture.blogspot.com
On 08/01/2008, mike clemow
Okay... affine spaces. I'm going to have to wikipedia that one, i'm afraid (high school math ain't doin' it for me here ;-) I understand the analogy of vectors and point, though--I think that lends some credence to the idea that Chuck is already on the right path as far how the dur and time types work.
I see the analogy and I think it has a lot of merit. I'm also, at the same time, sticking to my older point that ChucK is already muddying the waters and is in fact getting quite a bit of use from that, for example "now - (now % T) => now;", I find that line very beautiful, extremely useful and in direct opposition to looking at time objects are pure references to instances. I still have a few questions. The first is for Kassen: Why do you
want to know the VM start time?
To quote Nick Cave; "I can't see for the smoke so I poke around, I poke around"(etc) At some moment I just tried it as the units are the same, it didn't work so I tried some more related stuff. I want to learn so I'm asking questions. ChucK is a great tool to put some bangin' beats on the proverbial floor and it's a nice experiment in syntax. I like both aspects a lot. At the core of ChucK's syntax is time and timing so any questions and -possible- incoherency's in working with those are quite interesting. I can find the birth of the VM and half a minuted after I found out how to I shared this with the list so now we all can, but I think some questions remain. I don't know about you but so far I have used "time" as a data type only rarely and I didn't know that much about it, I think we all know a bit more now. In a way there is a certain philosophical beauty to only being able to define time in relation to the "now" but as this can lead to some decidedly odd expressions I wonder if that's intentional and proper. As for actual use, I could imagine that referring to absolute moments in time could become useful when writing a score, especially with some sort of sorting, Csound style. Maybe there are other better uses, maybe it's all quite academic? I'm already enthusiastic there are people that have a position on this too.
I'm just thinking out loud...
So was and am I. It's the ultimate in open-source! "thinking out loud" strikes me as a excelent slogan for a musical programing language. Yours, Kas.
OK, I'm not a math wiz or even a audio/dsp wiz, and certainly not a ChucK wiz. What exactly does this mean:
now - (now % T) => now;
I've seen it before and am guessing it has something to do with periodicity, but not really sure how this statement works.
-- Rich
----- Original Message -----
From: Kassen
To: ChucK Users Mailing List
Sent: Tuesday, January 08, 2008 7:34 PM
Subject: Re: [chuck-users] cast dur to time?
On 08/01/2008, mike clemow
OK, I'm not a math wiz or even a audio/dsp wiz, and certainly not a ChucK wiz. What exactly does this mean: now - (now % T) => now;
In this context, T is a duration to which to synchronize, like a beat. minute/140 => dur beat; the expression (now % beat) is the remainder after dividing the current time into uniform beats, the amount of time that hangs over the last beat. Usually, the next step for me is: beat - (now % beat) which indicates the time left until the next beat. Chucking it to now wakes up the current shred exactly on the next beat / period. beat - (now % beat) => now; But as far as your expression now - (now % T) => now; if T is a duration, then the right hand expression would be the current shred time (a time) minus that that hangs over the duration (a duration), which would be a time in the past, which seems to throw a NegativeTimeException in the VM. Graham
Thanx Graham; this makes sense, and is chuckin cool! Gees, even I can
understand it! Woohoo!
-- Rich
----- Original Message -----
From: "Graham Coleman"
OK, I'm not a math wiz or even a audio/dsp wiz, and certainly not a ChucK wiz. What exactly does this mean: now - (now % T) => now;
In this context, T is a duration to which to synchronize, like a beat. minute/140 => dur beat; the expression (now % beat) is the remainder after dividing the current time into uniform beats, the amount of time that hangs over the last beat. Usually, the next step for me is: beat - (now % beat) which indicates the time left until the next beat. Chucking it to now wakes up the current shred exactly on the next beat / period. beat - (now % beat) => now; But as far as your expression now - (now % T) => now; if T is a duration, then the right hand expression would be the current shred time (a time) minus that that hangs over the duration (a duration), which would be a time in the past, which seems to throw a NegativeTimeException in the VM. Graham _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 10/01/2008, Rich Caloggero
Thanx Graham; this makes sense, and is chuckin cool! Gees, even I can understand it! Woohoo!
Rich, I'm really sorry about making that typo and throwing you off. The plan was to have *more* clarity, not to send people off into a maze of error messages. Enthousiasm and dyslexia don't always mix well. Yours, Kas.
Glad to help, Rich.
Indeed, the _p - (now % p)_ pattern comes up so much, it could even
have its own operator...
now %- dur => now; //sync to period
and for ints:
beatnum %- 4 => int notesel; //reverse sawtooth pattern, 4, 3, 2, 1, 4, 3, 2, 1
thought it might be nice if it subtracted from the highest value, ie:
3 - (beatnum % 4) => now; //zero-based reverse sawtooth, 3, 2, 1, 0, 3, 2, 1, 0
Graham
On Jan 10, 2008 6:16 PM, Rich Caloggero
Thanx Graham; this makes sense, and is chuckin cool! Gees, even I can understand it! Woohoo! -- Rich
tis 2008-01-08 klockan 21:50 -0500 skrev Rich Caloggero:
OK, I'm not a math wiz or even a audio/dsp wiz, and certainly not a ChucK wiz. What exactly does this mean: now - (now % T) => now;
I've seen it before and am guessing it has something to do with periodicity, but not really sure how this statement works.
It's used to keep a bunch of shreds operating in sync so you can throw
new ones in, and remove old ones. like the otf_*.ck-files in the example
directory.
% means modulo, which means that chuck will compute the remainder of a
division.
7/3 = 2,333333333
or this:
7/3 = 6, r = 1.
It's like the division you (at least I did) learnt when you were a very
little kid and wasn't supposed to know about floats.
So, in our case:
now % beat => dur samples_from_last_beats
now - samples_from_last_beats => now; <--- go to next beat
Hope that helps,
Gasten
Ps. modulo can be used in many clever ways. for example, if you want to
count from 0 to 9 and imedietly start with 0 again, you could do
something like this (I'm not sure this is right - i'm not so good with
head-calculation, but you get the point):
0 => int x;
while (true) {
<<
ons 2008-01-09 klockan 01:34 +0100 skrev Kassen:
On 08/01/2008, mike clemow
wrote: [snip] I still have a few questions. The first is for Kassen: Why do you want to know the VM start time?
To quote Nick Cave; "I can't see for the smoke so I poke around, I poke around"(etc)
Agreed. [snip]
I'm just thinking out loud...
So was and am I. It's the ultimate in open-source! "thinking out loud" strikes me as a excelent slogan for a musical programing language.
Very nice! Like it a lot! You should put it on the Toplap slogan page =) Gasten
participants (6)
-
Graham Coleman
-
Kassen
-
Martin Ahnelöv
-
mike clemow
-
pibsid@suomi24.fi
-
Rich Caloggero