Problems with TimeNow and ADSRs

Hi,

1.) I’ve got problems using the TimeNow() function. Print(TimeNow()) works as expected, but as soon as I declare an integer variable and try to assign TimeNow(), I get an “Unexpected error” in the log window. When I run it on OSX, GP even crashed at the second time I compiled the script.

2.) I try to implement an automatic filter sweep using an ADSR.

var Env : ADSR [...] Env.EnableLFO(true)

I get an “Semantic error: Line 15, Col 5: Types are not compatible”.

Did I do something wrong?

Thanks!
Lukas

I’ll check the timenownproblem quickly but I don’t know what line is line 15 and what was just before it

Please post entire script

Ok, no need to post the script, I know what’s wrong.

THere is actually an underlying type called a generator and LFO, ADSR and other periodic functions. I used to call the underlying type an LFO until I implemented ADSR and realized that LFO was a bad base type.

This will be fixed for next version. Again, thanks for reporting this.

Could you reproduce the TimeNow problem? Is there any workaround for the current version to get the timestamp? What I want to do is to define a timeout so that if no notes will be played for >= 10 seconds the widget values will be reset to standard values. That makes it possible to have a new filter sweep for every phrase without having to reset the filter cutoff/envelope manually. Very cool thing.

While not being able to use the ADSR at the moment I helped myself by manipulating the cutoff with every note-on event. Not as smooth as a real envelope but it does its job :slight_smile:

BTW - for the future: Is it better to open separate threads for different issues than posting them into one thread?

I didn’t need to reproduce the TimeNow problem. As soon as I looked at the source code for it, I saw what was wrong - it is declared as returning an integer but in fact I was returning a double! Unfortunately no workaround that I can think of because the stack gets corrupted because of this (GP Script is actually a compiler so getting types wrong can really blow things up).

TimeNow is fixed as well and will be in the next update.

It is probably better to post these issues as separate threads though. But these were easy.

OK. Thanks for fixing!