bad values from xwax timecoder

Bug #788630 reported by Owen Williams
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Low
Owen Williams

Bug Description

What I thought would be a simple one-liner is causing problems. In xwax's timecoder.c, I want to normalize the timecode to represent milliseconds instead of "timecoder steps." Technically we lose precision with vinyl like traktor (since it's supposedly accurate to 1/2 millisecond) but it's much cleaner to problem for.

So I wrote this line (at the end of the file):

if (r >= 0) {
//normalize position to milliseconds, not timecode steps -- Owen
r = r * 1000 / (tc->def->resolution * tc->speed);
...

However I seem to suck at math, because every so often this will spit out a gigantic value -- originally because I did the math before I tested for r>=0, which (maybe?) caused unsigned integer math barf. But it's still capable of spitting out gigantic values, so there's still something wrong.

What's the right way to write this line so all the numbers behave? I'm thinking:

r = (float)r * (1000.0 / (tc->def->resolution * tc->speed));

(r is a signed int, resolution is an int, and speed is a double)

Tags: vinylcontrol
Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

When the value goes gigantic -- what are the values of all the other variables? Can you log it or something?

tags: added: vinylcontrol
Revision history for this message
Owen Williams (ywwg) wrote :

I did my fix as indicated, and this hasn't been a problem in a while. closing.

Changed in mixxx:
status: New → Fix Committed
assignee: nobody → Owen Williams (ywwg)
jus (jus)
Changed in mixxx:
milestone: none → 1.11.0
importance: Undecided → Low
RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/5908

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.