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
Random operators (|
and ?
) always make the same choice in a cycle
#530
Comments
Hey! thanks for the investigation you're right, the randomness is currently a bit weird..
that's true, I rolled some of it back because it introduced non deterministic behavior, see #245 .
Interesting observation.. this produces the same value 3 cycles in a row:
I am not sure what to do here, as I haven't fully dived into the inner workings of the rng.. @yaxu any ideas? |
Thanks for the quick reply!
Ah, I noticed that Tracing backwards from For example, if I strudel/packages/core/signal.mjs Lines 17 to 20 in 952bd38
then I see:
so |
Upon further contemplation, the stuff with s("hh*2").gain(seq(sine, sine).log()) // always yield ~0.5 because the signal always starts from the beginning
s("hh*2").gain(sine.log()) // alternates between 0 and 1 because the signal is sampled at two points per cycle and indeed, Tidal behaves identically; So then why doesn't random choice behave like this in Tidal? It looks like it's because of this, which causes a new seed to be associated with each occurrence of Regarding the problem mentioned in #245 (comment), maybe the issue is that If so, probably the right thing to do is have some similar parser state in Strudel, so that each occurrence of |
rand
produces duplicate values when used repeatedly in seq()
|
and ?
) always make the same choice in a cycle
Yes that's a solid analysis! |
Hello! I've observed a funny interaction between
rand
andseq()
.I initially noticed that
s("[sd|cp] [sd|cp]")
will always select bothsd
s or bothcp
s in any given cycle; you never get the combinationssd cp
orcp sd
. This is surprising because it seems like the choices should be independent.I confirmed that this is different than Tidal's behavior: after evaluating
d1 $ s "bd [sd|cp] [sd|cp]"
, I observe all four combinations of [sd, cp] x [sd, cp].The
|
syntax is mini-notation forchooseCycles()
, which usesrand
; I can see thatrand
itself is producing duplicate values:generates console output like
However, this does not occur with
s("hh*2").gain(rand.log())
.(
s("hh").gain(rand.log()).pan(rand.log())
also produces duplicate values for gain and pan, but I get the impression that's expected behavior because the PRNG is a pure function of time, and the two uses ofrand
here are simultaneous for each hap.)In short, this seems like a regression from the behavior described here: #165 (comment).
That's as far as I've gotten for now; I plan to take a closer look at this soon and hopefully submit a fix.
The text was updated successfully, but these errors were encountered: