-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASL dyn to allow calculations outside of a to() #433
Comments
What is the expected behavior of
|
I realize the naming didn't make sense because loop{ to(5,dyn{t=5}) -- ramp to 5v over dyn.t seconds
, to(0,dyn{t=5}) -- move to 0v over dyn.t seconds
, dyn{t=5}:mul(0.9) -- dyn.t *= 0.9
} The effect is that of a triangle lfo which increases in speed by 10% every cycle of the whole loop. This example is not a great example of why you would need the dyn to stand on it's own. It only becomes useful when you are trying to build custom oscillators with state built in. There's some examples in this gist where state changes are inside an |
Personally I think allowing bare |
@HelveticaScenario Do you have thoughts on how we could alter the syntax so that it is possible to make the more complex ASLs of the above gist in a way that doesn't use 'dummy' |
@trentgill I have a couple ideas yeah Basically, we separate the method calls from the The 2 ways I can see this happening is as follows -- Option 1: `dyn` tables
t = dyn(5)
output[1].action = loop{ to(5, t)
, to(0, t)
, change(t, mul(0.9))
}
-- Because the name of a `dyn` is now just the variable its assigned to we cant
-- have the `output[1].dyn.t` pattern anymore, but because we now have a `dyn`
-- table to play with we can do this
dyn.value = 3 -- `dyn.volts` is another option
-- Option 2: `dyn` strings
output[1].action = loop({t = 5},
{ to(5, 't')
, to(0, 't')
, change('t', mul(0.9))
})
-- `dyn` are still named so we retain the current `dyn` value assignment syntax
output[1].dyn.t = 3 Personally I think option 1 is more interesting and more in line with how I expect programs to work in general, where you explicitly create and use values. It also solves a potential issue that arises when you separate As for separating mutation into its own separate verb, we make asl driven mutation explicit, which I personally feel is clearer because it separates assignment from accessing, which is how programs usually work. It is, however, more verbose as it requires an explicit step to do a mutation, but I personally don't feel like it's so verbose as to be a detriment. One thing to note: |
If I understand whats going on in that gist, using option 1, you should be able to do it like this function steps(f1, f2)
local ff = dyn(f1)
local lev = dyn(5)
local count = dyn(-30)
return loop{ asl._if( count,
, { change(lev, mul(lev), mul(lev), mul(lev), wrap(-5,5)) }),
, change(count, step(1), wrap(-3000,1.1)),
, to( lev, 0.5/ff)
, to(-lev, 0.5/ff)
}
end One thing that we would need to decide is if you have a variadic |
@trentgill any thoughts on this? |
I certainly thought about it a lot, but I'm not sure I'm anywhere near a definitive position. There are arguments in many directions, and I worry we are too focused on one particular aspect. Regarding your proposal it might be helpful to read through the source, at least May be of interest: I have a little trouble with the necessity of an explicit 'verb' function (eg. As a historical reference, originally all the operations used standard math operators, and any object called // I can see your arguments for the syntax you propose, but equally I see problems both in terms of implementation and structure. Your proposed changes would be breaking to existing scripts, and while this isn't a dealbreaker, it requires there to be a strong benefit to the new option which I don't clearly see. So perhaps I can ask a slightly different question: What is your motivation related to this problem? It seems you have real enthusiasm for it (great!), but I'm a little vague whether you're interested in the problem of "ASL dyn calculations outside of a to" or something closer to an alternate syntax for |
To answer your last question first, I’m still figuring it out. When I think about crow there are some things that I wish were there, but I’m conflicted because (a) I am very new to it and I don't feel like I’ve explored it enough to justify to myself that these things that I’d like need to be added or if they can be achieved in existing ways that work well enough, and (b) at the end of the day it isn’t my project, it’s yours and tehn’s. I don’t meant that in a negative way, and you have been nothing but courteous, but I can tell that y’all have a vision for it and I’m not sure if what I’d like to use crow for is really what y’all made crow for. Be that as it may, I think its an amazing product and I’m inspired to help. As for your first point regarding the need for a |
At present, in order to change a variable without it taking effect, you have to do some acrobatics.
In order to allow (conditionally) updating a variable without applying the value in a
to
call, i propose allowing rawdyn
operations in an ASL table:some other ASL helpers:
Ability to share a single named
dyn
variable, without having to re-init it with a default value every time (see above example). logically it should only be 'initialized' in one place, and the others could just refer to it by name.nested loop{loop{}} seems to break (or at least with loop{times{
something breaks when you assign dyn to a local variable in an ASL-constructor and pass in the name of the variable, rather than copying the table into each location.
all to() calls take twice as long as they should
asl._if is weird & unclear what values it matches on (>=1?)
The text was updated successfully, but these errors were encountered: