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

Fix UGen initialization: OscUGens #5787

Merged
merged 16 commits into from
Aug 14, 2022

Conversation

mtmccrea
Copy link
Member

@mtmccrea mtmccrea commented May 25, 2022

Purpose and Motivation

A majority of UGens do not initialize with a correct initialization sample, and subsequently output an incorrect first sample. A lack of clarity and consistency around how UGens are initialized has led to many UGens being improperly initialized. The affects include: UGen graphs aren't properly "primed" (users see unexpected results), samples are delayed, filters can pop from incorrect feedback coefficients, accessing unassigned memory, etc. Users regularly report Issues that can be traced back to UGen initialization problems.

This PR also serves as a concrete reference for discussion found in the RFC: Fix UGen Initializations, more details can be found there.

This PR is part of an ongoing effort to fix UGen initializations, the progress of which is tracked here.

(I will update this post with Issues this fixes.)

Types of changes

  • Documentation (FSinOsc, FoldIndex)
  • Bug fixes
  • Breaking changes

Changes in behavior of UGens would all technically be breaking. However, the changes are largely (entirely?) confined to the output of samples within the first block.

I chose to use OscUGens as the starting point because I expect these changes are minor (likely won't be heard), and are hopefully not overly controversial.

Changes to UGens which are more elaborate or might create more substantial change in behavior will be left out of these kind of "batch" fixes, and submitted as separate PRs (TWindex(#5815), Klang and Klank (#5817), in this case).

To-do list

  • Code is tested
  • All tests are passing
  • Updated documentation
  • This PR is ready for review

@mtmccrea
Copy link
Member Author

mtmccrea commented May 28, 2022

[EDIT: this issue is resolved, thanks @dyfer!]

I was getting failing MacOS tests based on RTAlloc, so reset my branch to before merging those additions (#5713), which were merged despite failing tests. Seems to have resolved that..

Now I'm seeing failing tests related to NodeProxy, which I also assume are unrelated to my changes. (And actually when I run the tests in TestNodeProxy_Server locally, a different test fails than the one failing on the Linux build).

Are there known issues with NodeProxy tests, or should I dig deeper into whether my changes could somehow be affecting them?

@dyfer
Copy link
Member

dyfer commented May 31, 2022

Now I'm seeing failing tests related to NodeProxy, which I also assume are unrelated to my changes. (And actually when I run the tests in TestNodeProxy_Server locally, a different test fails than the one failing on the Linux build).

Are there known issues with NodeProxy tests, or should I dig deeper into whether my changes could somehow be affecting them?

Yes, there are issues in these tests and thus they are disabled in the CI.

RTAlloc failures are tricky. I can't reproduce them locally and so couldn't @elgiano who submitted #5713... I think we might need to disable them for now in CI and dig deeper later...

@dyfer
Copy link
Member

dyfer commented Jun 1, 2022

@mtmccrea RTAlloc tests are now disabled in the CI and I made some changes to the testing script as well. Can you try rebasing this PR on the latest develop?

mtmccrea added 16 commits June 1, 2022 21:04
The UGen's calc rate erroneously checked against the bufnum slot instead of the input signal slot, so the calc func would never be DegreeToKey_next_a.
This also ensures in != unit->mPrevIn on first frame so that index is calculated.
Was outputting `y(-1)` for init sample and setting `y(-1)` to `y(0)` and `y(-2)` to `y(-1)`.
Don’t assume init sample to be 0, properly calculate previous sample by rolling back phase.
Calculate the initialization sample by the proper `next_` function, based on input rates, reset state for first sample.
Reset the initial phase after calculating the initialization sample.
Calculate the initialization sample by the proper `next_` function, based on input rates.
Reset the initial phase after calculating the initialization sample.
Calculate the initialization sample by the proper `next_` function, based on input rates.
Reset the initial phase after calculating the initialization sample.
Calculate the initialization sample by the proper `next_` function, based on input rates.
Reset the initial phase after calculating the initialization sample.
@mtmccrea mtmccrea force-pushed the topic/init-sample-oscugens branch from 566fd1c to 81d7a16 Compare June 1, 2022 18:05
@mtmccrea
Copy link
Member Author

mtmccrea commented Jun 1, 2022

Thanks @dyfer! After the rebase the tests are passing now. Thanks!!

Copy link
Member

@joshpar joshpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@dyfer dyfer merged commit 60a1721 into supercollider:develop Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants