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

Brake: fix infinite run out #4705

Closed
wants to merge 3 commits into from
Closed

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Mar 26, 2022

Multiple times I experienced that engine.brake() would slow down the deck until the waveforms halted but play was never disabled.
I suspected a broken controller button (faulty debounce filter) to initiate brake again, but I could also reproduce it with a MIDI Through script a few times.

There is at least one possibility that the rampTo rate was crossed but scratchProcess didn't stop, thus slowing down to zero and accelerating again very, very slowly:

debug [Controller]    old 0
debug [Controller]    new 1.69772e-311
debug [Controller]    fabs 0.01
debug [Controller] .
debug [Controller] .
debug [Controller]    old 1.69772e-311
debug [Controller]    new 5.08986e-311
debug [Controller]    fabs 0.01
debug [Controller] .
debug [Controller] .
debug [Controller]    old 5.08986e-311
debug [Controller]    new 1.01731e-310
debug [Controller]    fabs 0.01
...
debug [Controller]    old 1.85776e-307
debug [Controller]    new 1.88052e-307
debug [Controller]    fabs 0.01
debug [Controller] .
debug [Controller] .
debug [Controller]    old 1.88052e-307
debug [Controller]    new 1.90341e-307
debug [Controller]    fabs 0.01
debug [Controller] .
debug [Controller] .
debug [Controller]    old 1.90341e-307
debug [Controller]    new 1.92641e-307
debug [Controller]    fabs 0.01

I fixed that

That and some more simplification and I couldn't reproduce the bug anymore 🤷‍♂️

@ronso0
Copy link
Member Author

ronso0 commented Mar 26, 2022

Draft until I can confirm it's fixed with some 'real life' tests with my controller.

@ronso0 ronso0 force-pushed the brake-fix-run-out branch from c920555 to 0932604 Compare March 27, 2022 00:32
@@ -16,6 +16,8 @@ constexpr int kDecks = 16;
// timer.
constexpr int kScratchTimerMs = 1;
const double kAlphaBetaDt = kScratchTimerMs / 1000.0;
// stop ramping at a rate which doesn't produce any audible output anymore
const double kBrakeRampToRate = 0.01;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const double kBrakeRampToRate = 0.01;
constexpr double kBrakeRampToRate = 0.01;

@daschuer
Copy link
Member

Thank you for investigating.
If you like, you may split out the useful refactoring. I think that can be merged immediately since it does not change the behavior.

@ronso0
Copy link
Member Author

ronso0 commented Mar 27, 2022

I don't mind if the refactring has to wait.
I have to start over anyway because I didn't consider that brake() can also be a spinback :|

Also, the code hasn't changed since 2.3 AFAICT so I'll rebase this onto 2.3

@ronso0
Copy link
Member Author

ronso0 commented Mar 28, 2022

Uff, we didn't test spinback after my most recent brake fixes #1085
It's broken 😬

  • spinback accelerates infinitely
  • this prevents spinback from starting when the deck is stopped
  • this makes it runs way to long because brake rampTo is positive while spinback is running with negative rate
  • spinback while softStart'ing accelerates the track to warp 10 until it hits the end

I'll prepare a fix for both issues.

@ronso0
Copy link
Member Author

ronso0 commented Mar 29, 2022

Superseded by #4708 (2.3)

@ronso0 ronso0 closed this Mar 29, 2022
@ronso0 ronso0 mentioned this pull request Mar 29, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants