Skip to content
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

Classlib: Patterns: Pn should set flag at onset #2833

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

jamshark70
Copy link
Contributor

From the discussion of Pn/Pgate on sc-users, I found a little bug.

Pn's help implies that it sets the flag every time the subpattern starts. But it doesn't do this for the first repeat. Pn's logic "cheats" and sets after the pattern, not at the beginning. This has an unintended consequence: an immediately following Pn does not trigger a new value in Pgate.

(
p = Pbind(
	\degree, Pseq([
		Pn(Pseries(0, 1, { rrand(2, 5) }), 3, \nextDur),
		Pn(Pseries(0, 1, 10), 1, \nextDur)
	], 1),
	\dur, Pgate(Pexprand(0.1, 0.25, inf), inf, \nextDur)
).trace.play;
)

( 'degree': 0, 'dur': 0.10465929123453 )
( 'degree': 1, 'dur': 0.10465929123453 )
( 'degree': 2, 'dur': 0.10465929123453 )
( 'degree': 3, 'dur': 0.10465929123453 )
( 'nextDur': true, 'degree': 0, 'dur': 0.14876536558564 )
( 'degree': 1, 'dur': 0.14876536558564 )
( 'degree': 2, 'dur': 0.14876536558564 )
( 'degree': 3, 'dur': 0.14876536558564 )
( 'degree': 4, 'dur': 0.14876536558564 )
( 'nextDur': true, 'degree': 0, 'dur': 0.14595617545395 )
( 'degree': 1, 'dur': 0.14595617545395 )
( 'degree': 2, 'dur': 0.14595617545395 )
( 'degree': 3, 'dur': 0.14595617545395 )
( 'degree': 4, 'dur': 0.14595617545395 )
( 'nextDur': false, 'degree': 0, 'dur': 0.14595617545395 )  <-- 'nextDur': false ???????
( 'degree': 1, 'dur': 0.14595617545395 )
( 'degree': 2, 'dur': 0.14595617545395 )
( 'degree': 3, 'dur': 0.14595617545395 )
( 'degree': 4, 'dur': 0.14595617545395 )
( 'degree': 5, 'dur': 0.14595617545395 )
( 'degree': 6, 'dur': 0.14595617545395 )
( 'degree': 7, 'dur': 0.14595617545395 )
( 'degree': 8, 'dur': 0.14595617545395 )
( 'degree': 9, 'dur': 0.14595617545395 )

After this change, the second Pn does trigger a new duration value.

( 'nextDur': true, 'degree': 0, 'dur': 0.1291245383907 )
( 'degree': 1, 'dur': 0.1291245383907 )
( 'nextDur': true, 'degree': 0, 'dur': 0.18075621535085 )
( 'degree': 1, 'dur': 0.18075621535085 )
( 'degree': 2, 'dur': 0.18075621535085 )
( 'degree': 3, 'dur': 0.18075621535085 )
( 'nextDur': true, 'degree': 0, 'dur': 0.11987889871256 )
( 'degree': 1, 'dur': 0.11987889871256 )
( 'nextDur': true, 'degree': 0, 'dur': 0.13784356186022 )  <-- here, yes!
( 'degree': 1, 'dur': 0.13784356186022 )
( 'degree': 2, 'dur': 0.13784356186022 )
( 'degree': 3, 'dur': 0.13784356186022 )
( 'degree': 4, 'dur': 0.13784356186022 )
( 'degree': 5, 'dur': 0.13784356186022 )
( 'degree': 6, 'dur': 0.13784356186022 )
( 'degree': 7, 'dur': 0.13784356186022 )
( 'degree': 8, 'dur': 0.13784356186022 )
( 'degree': 9, 'dur': 0.13784356186022 )

@jamshark70 jamshark70 added bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: class library SC class library labels Apr 10, 2017
@jamshark70
Copy link
Contributor Author

Hm, I see I can do it a little more cleanly. Later today...

@jamshark70 jamshark70 force-pushed the topic/FixMultiplePnPgate branch from bdb3f73 to 8ebd346 Compare April 10, 2017 02:35
@jamshark70 jamshark70 force-pushed the topic/FixMultiplePnPgate branch from 8ebd346 to 112bf4c Compare April 10, 2017 02:37
@jamshark70
Copy link
Contributor Author

jamshark70 commented Apr 10, 2017

OK, done (force push, for cleaner history after merging).

I'm not sure if Pn really needs the line event[key] = false; before exiting. I chose not to delete it, in case some user code might be checking for it -- I think it's unlikely, but why take the risk?

The updated version also fixes a mistake in Pgate's per-repeat initialization (my mistake, in the initial PR).

@jamshark70
Copy link
Contributor Author

Bump. C'mon, this is really obviously a bug.

@telephon telephon merged commit 9acbb66 into supercollider:master Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: class library SC class library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants