Closed rfpuyana closed 5 years ago
Hi @rfpuyana
I think the error might be because math isn't capitalized in your code. The name of the math object in javascript is capitalized: Math
. (Source: MDN web docs)
Try the following code:
osc(10,0.1)
.thresh(0.1).scale(()=>Math.sin(time))
.out()
Zach you are correct. My Bad. It's now working.
However, Hydra shouldn't freeze. An error message should notify about this particular case.
Maybe a solution is allowing sin
to be a globally accessible function to prevent calling Math
object directly.
Example (hydra-editor)
sin = (x) => Math.sin(x);
shape(3)
.scale(
()=>sin(time)
).out();
Ideally, it wouldn't require an anonymous function to pass the value but I am not sure how that could be accomplished. Maybe @ojack @rumblesan @echophon @brucelane have ideas on that? Example:
shape(3)
.scale(
sin(time)
).out();
so there's a couple of immediate solutions I guess.
Math
globally availablemath
variable that is just Math
so casing doesn't make any difference.
Both are fine, though the bigger issue really is that the undefined variable crashes everything. I think a better fix would be to catch the error and handle it gracefully with a warning so users can fix the casing.I've not had a look at the hydra code for a while now, but I've not got anything else happening with my Friday night so I'll start digging 😂
setting sin( )
matches how p5.js (source code, line 188) has approached this too
right, think I've figured out what's going on and opened that PR, but not had a chance to fully check. will get back to it a bit later when I have a moment
@rumblesan's commit fixed the function crashing issue, yay! And also fixes https://github.com/ojack/hydra/issues/35
As far as globally defining certain functions as @zachkrall mentions, that is part of a much larger conversation at https://github.com/ojack/hydra/issues/8 so let's continue it there.
Opened a new issue about providing user log info about what happens in hydra synth at: https://github.com/ojack/hydra/issues/53
hah, glad to be of use :D
There's something about this sine function freezing Hydra and not showing any error. Hydra web needs to be reloaded in the browser.
This chain works well
This one freezes Hydra. No error messages
OS:Mac OSX - High Sierra Browser: Chrome Version 75.0.3770.100 (Official Build) (64-bit) Hydra: Web