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

Enhance precision of track duration #970

Merged
merged 10 commits into from Jun 25, 2016
Merged

Enhance precision of track duration #970

merged 10 commits into from Jun 25, 2016

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented Jun 25, 2016

Launchpad
https://bugs.launchpad.net/mixxx/+bug/1497183

Track Property
Changed the data type of this property. In JavaScript it's a number and and control objects are always double.

DB Column
Since the existing DB column 'duration' cannot be deleted a new column 'duration_real' that gets it's default value from 'duration' is added. Both columns are written, but only the new column is read.

Util Classes
I've moved the formatting of duration values into util/duration.h. The header util/time.h caused naming conflicts with system headers when included in track/track.h. I don't wanted to fix this now. We should think about enclosing more classes in namespace 'mixxx'. I've used 'Mixxx' in the past, but lower case names are more common for C++. The namespace fixes will be part of a following PR

m_nextTransitionTime = math_min(m_iTransitionTime,
fromTrackDuration / 2);
m_nextTransitionTime = math_min(m_transitionTime,
fromTrackDuration / 2.0);
Copy link
Member

Choose a reason for hiding this comment

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

A Pentium is able to divide a float by an integer. No need for .0 here.

pTrackMetadata->setBitrate(audioProperties.bitrate());
#if TAGLIB_HAS_LENGTH_IN_MILLISECONDS
double duration = audioProperties.lengthInMilliseconds() / 1000.0;
Copy link
Member

Choose a reason for hiding this comment

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

ähh * 1000.0?

Copy link
Member

Choose a reason for hiding this comment

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

ups :-*

@daschuer
Copy link
Member

Thank you for adopting this.

Even though a sqlite column is marked at int, you are able to store a real value.
See http://sqlite.org/datatype3.html#section_3
The important idea here is that the type is recommended, not required. Any column can still store any type of data.

I have just checked. You are able to store 90.5 in the old duration column. It is read as 91 in current Mixxx. If you store 90.49 it is read as 90.

The question is, can't we just ignore the "interger recommendation" and continue the original duration column?
Of cause this is less clean because we do not follow the legacy type recommendation, but it avoids to carry a useless column around which may have a performance or size impact.
Unfortunately sqlite does not allow to remove the recommendation.

What do you think?

@rryan
Copy link
Member

rryan commented Jun 25, 2016

I think it's safe to ignore the integer recommendation -- SQLite wouldn't be able to change that without breaking backwards compatibility so we don't have to worry that they will in the future I think. It would be nice to not have the deprecated column.

For newly created DB files use the correct type for the schema.
Existing DB files are backwards compatible according to the
documentation:

https://www.sqlite.org/datatype3.html
"Any column in an SQLite version 3 database, except an INTEGER PRIMARY KEY
column, may be used to store a value of any storage class."
@uklotzde
Copy link
Contributor Author

Thanks for the hint, Daniel! Let's reuse the existing column, it's even
officially documented:

https://www.sqlite.org/datatype3.html
"Any column in an SQLite version 3 database, except an INTEGER PRIMARY KEY
column, may be used to store a value of any storage class."

On 25.06.2016 19:33, Daniel Schürmann wrote:

Thank you for adopting this.

Even though a sqlite column is marked at int, you are able to store a real
value.
See http://sqlite.org/datatype3.html#section_3
|The important idea here is that the type is recommended, not required.
Any column can still store any type of data.|

I have just checked. You are able to store 90.5 in the old duration
column. It is read as 91 in current Mixxx. If you store 90.49 it is read
as 90.

The question is, can't we just ignore the "interger recommendation" and
continue the original duration column?
Of cause this is less clean because we do not follow the legacy type
recommendation, but it avoids to carry a useless column around which may
have a performance or size impact.
Unfortunately sqlite does not allow to remove the recommendation.

What do you think?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#970 (comment), or
mute the thread
https://github.com/notifications/unsubscribe/ABZ-at2A0Kt23vWF0_-D6-iA980kXi-4ks5qPWaGgaJpZM4I-TBY.

@@ -1279,7 +1279,7 @@ TrackPointer TrackDAO::getTrackFromDB(TrackId trackId) const {
{ "rating", setTrackRating },
{ "comment", setTrackComment },
{ "url", setTrackUrl },
{ "duration", setTrackDuration },
{ "duration_real", setTrackDuration },
Copy link
Member

Choose a reason for hiding this comment

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

leftover

@daschuer
Copy link
Member

That was fast :-) Thank you very much! LGTM

@daschuer daschuer merged commit 89612ff into mixxxdj:master Jun 25, 2016
@uklotzde uklotzde deleted the duration_real branch June 26, 2016 06:20
radusuciu added a commit to radusuciu/mixxx that referenced this pull request Feb 14, 2017
I believe this work-around is no longer necessary after this bug was
fixed: https://bugs.launchpad.net/mixxx/+bug/1497183 in
mixxxdj#970
radusuciu added a commit to radusuciu/mixxx that referenced this pull request Feb 15, 2017
I believe this work-around is no longer necessary after this bug was
fixed: https://bugs.launchpad.net/mixxx/+bug/1497183 in
mixxxdj#970
radusuciu added a commit to radusuciu/mixxx that referenced this pull request Feb 16, 2017
I believe this work-around is no longer necessary after this bug was
fixed: https://bugs.launchpad.net/mixxx/+bug/1497183 in
mixxxdj#970
@ninomp ninomp mentioned this pull request Nov 5, 2017
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.

None yet

3 participants