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

Read Cues from Serato MP3 Tags #2526

Merged
merged 21 commits into from
Apr 22, 2020

Conversation

Holzhaus
Copy link
Member

This is based on PRs #2499 and #2523.

@Holzhaus Holzhaus force-pushed the serato-markers-integration-cues branch 2 times, most recently from 7ed1cb3 to 6287684 Compare March 5, 2020 12:40
src/track/serato/tags.cpp Outdated Show resolved Hide resolved
switch (timingShiftCase) {
#if defined(__MAD__)
case EXIT_CODE_CASE_D:
timingOffset = -16;
Copy link
Member Author

Choose a reason for hiding this comment

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

@ywwg Here's an example how to set timing offsets btw.

src/track/track.cpp Outdated Show resolved Hide resolved
@uklotzde
Copy link
Contributor

Unrelated warning:

In file included from /tmp/mixxx/src/track/serato/markers.cpp:1:
/tmp/mixxx/src/track/serato/markers.h:94:10: warning: private field 'm_isSet' is not used [-Wunused-private-field]
    bool m_isSet;
         ^
1 warning generated.

@uklotzde
Copy link
Contributor

I have some ideas how to explicitly handle the discrepancy between file tags and stream properties of track objects. Stay tuned.

@Be-ing
Copy link
Contributor

Be-ing commented Mar 23, 2020

Has anyone looked into the cue offset issues with this? @ehendrikd maybe you could help? If you don't want to directly work on this, maybe sending @Holzhaus the audio files you tested with Rekordbox and Mixxx would be helpful.

@ehendrikd
Copy link
Contributor

ehendrikd commented Mar 23, 2020

Here is a selection of known MP3 offset issue tracks, categorized in to cases A, B, C and D:

https://github.com/pestrela/music/tree/master/traktor/26ms_offsets/examples_tagged

As per ABCD cases defined here:

digital-dj-tools/dj-data-converter#3

And this was the final algorithm I settled on:

#2119 (comment)

// The following code accounts for timing offsets required to

@uklotzde
Copy link
Contributor

Sorry, but the Xenial issues are blocking me. I will not introduce more workarounds and make unnecessary compromises.

@Be-ing Be-ing added this to the 2.3.0 milestone Mar 24, 2020
@ywwg ywwg added the blocker label Mar 24, 2020
@daschuer
Copy link
Member

Why is a commented feature a beta blocker?
While the feature is nice, we can introduce it at any time later.

@Holzhaus
Copy link
Member Author

Here is a selection of known MP3 offset issue tracks, categorized in to cases A, B, C and D:

https://github.com/pestrela/music/tree/master/traktor/26ms_offsets/examples_tagged

I checked and the offset seems to be -18 ms in all cases for the MAD decoder on linux.

Can someone check the other offsets? I don't have a mac and my windows VM is too slow for audio playback on Serato for some reason.

If you want to test, you need to apply this patch first:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 912c3d2a6f..d99fd3741e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -730,6 +730,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
 set_target_properties(mixxx-lib PROPERTIES AUTOMOC ON AUTOUIC ON)
 target_include_directories(mixxx-lib PUBLIC src "${CMAKE_CURRENT_BINARY_DIR}/src")
 target_compile_definitions(mixxx-lib PRIVATE SETTINGS_FILE="mixxx.cfg")
+target_compile_definitions(mixxx-lib PUBLIC __EXTRA_METADATA__)
 if(UNIX AND NOT APPLE)
   target_compile_definitions(mixxx-lib PRIVATE SETTINGS_PATH=".mixxx/")
 endif()

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

@JosepMaJAZ maybe you could test on Windows? @ferranpujolcamins could you test on macOS? Serato DJ Lite does not cost any money and doesn't require any Serato specific hardware.

Can we clarify how exactly to test? Load each file from https://github.com/pestrela/music/tree/master/traktor/26ms_offsets/examples_tagged into Serato, set a cue point on each, then use this branch to import into Mixxx? How are you determining the timing offsets? The deck display in Mixxx is only precise to 10 ms.

@Swiftb0y
Copy link
Member

And maybe also test it with ffmpeg for mp3 and aac?

@Holzhaus
Copy link
Member Author

I set cue points in serato and checked visually if they are at the correct position in Mixxx. I wasn't aware that the waveform display is not accurate. Is there a better way do this?

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

I was referring to the time display in the decks:
image
It only goes to 0.00 seconds or 10 ms precision.

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

How did you compare to determine 18 ms is the offset? Did you write code to guess and check until the waveforms looked exactly the same?

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

@Holzhaus you can test for the FFMPEG decoder on Linux by editing SoundSourceProviderFFmpeg::getPriorityHint in src/soundsources/soundsourceffmpeg.cpp.

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

We use libmad (SoundSourceMp3) for both Linux and Windows, right? So I don't anticipate any difference between Linux and Windows. On macOS we use SoundSourceCoreAudio for MP3 so we do need someone with a Mac to test that. Judging from the offsets for Rekordbox, it is likely CoreAudio will not be the same as libmad.

@ywwg
Copy link
Member

ywwg commented Mar 25, 2020

Why is a commented feature a beta blocker?

it looked like it was designated such from the project page. @Holzhaus would it be ok to take this off the beta-blocking list?

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

My understanding is that there is only a little bit left to do here to correct the cue offsets (correct me if I am wrong). The hard work of reverse engineering the file tags is already merged. I think it would be a shame to release this feature in a half-baked state with the Serato library support for playlists without being able to read Serato cues. Releasing it in that state would raise the hopes of lots of people who would quickly be disappointed because it isn't practically all that beneficial. It would also be a shame to disable the Serato library feature to avoid disappointing those users. So I think we should push to finish this last part for the 2.3 beta release.

@Holzhaus
Copy link
Member Author

Holzhaus commented Mar 25, 2020

How did you compare to determine 18 ms is the offset? Did you write code to guess and check until the waveforms looked exactly the same?

  1. I set serato to -50% bpm (so that the waveform is zoomed to maximum), then I set hotcues at positions were the waveform suddenly changes (e. g. when the beat starts or something like that). Then I eject the track from the deck to trigger a Metadata write.
  2. I open the file in Mixxx, zoom in the waveform and check if the hotcue position is ahead or behind, then guesstimate an offset and put it in the code, recompile and restart mixxx and reimport Metadata. Repeat until it visually looks the same.

@Be-ing
Copy link
Contributor

Be-ing commented Mar 25, 2020

Shouldn't we get rid of the __EXTRA_METADATA__ guards in this PR now?

@Be-ing
Copy link
Contributor

Be-ing commented Apr 17, 2020

Your documentation says AIFF uses the same ID3 tags as MP3. Does this PR also work for AIFF files?

@Holzhaus
Copy link
Member Author

I have no idea, I converted the a file into all supported formats, loaded them in Serato and had a quick glance at the tags written. I didn't really try to reverse them.

@uklotzde
Copy link
Contributor

Your documentation says AIFF uses the same ID3 tags as MP3. Does this PR also work for AIFF files?

AIFF files could have ID3v2 tags or RIFF tags. For ID3v2 tags it works, for RIFF tags no. I could check if Serato is writing its markers into RIFF INFO tags.

@Holzhaus
Copy link
Member Author

I guess the lack of Windows/OSX testers is probably due to the buggy waveforms. Until that is fixed, can at least someone check the offsets on Linux? Or shall we postpone this to 2.4? I feel like we're not making progress here.

@Be-ing
Copy link
Contributor

Be-ing commented Apr 20, 2020

@bengl3rt will you have time to find the offsets for macOS soon?

@ehendrikd
Copy link
Contributor

ehendrikd commented Apr 20, 2020

I’m also now having a look into this on macOS, think a separate CoreAudio section for each MP3 case as suggested by @Be-ing will be needed. Would it be best to create a PR to @Holzhaus branch once I have completed this with the new CoreAudio offsets?

@Be-ing
Copy link
Contributor

Be-ing commented Apr 20, 2020

Great, thanks for taking this up @ehendrikd. Yes, make a PR for @Holzhaus's fork. Please leave a comment here with a link to your PR so all Mixxx contributors can find it.

@ehendrikd
Copy link
Contributor

Think I have the offsets set for CoreAudio. Holzhaus#4

…coreaudio

CoreAudio MP3 offsets for Serato cues
@Be-ing
Copy link
Contributor

Be-ing commented Apr 21, 2020

Ready for merge?

@Holzhaus
Copy link
Member Author

Holzhaus commented Apr 21, 2020

No windows offsets yet. Also, I'd really like someone to verify my Linux findings. It's strange that all values are the same...

@Be-ing
Copy link
Contributor

Be-ing commented Apr 21, 2020

Mixxx uses libmad (SoundSourceMP3) on both Windows and Linux, so the offsets should be the same on both. Can you confirm that is correct, @uklotzde?

@Be-ing
Copy link
Contributor

Be-ing commented Apr 22, 2020

It's possible that Serato also uses libmad which is why there are no offsets to correct for on Linux and Windows.

From the MAD homepage:

MAD is available under the terms of the GNU General Public License, Version 2, for either permanent use or for evaluation prior to obtaining a commercial license. Please note that under the GPL, there is absolutely no warranty of any kind.
Commercial, non-GPL licensing is also available. Please contact us to discuss possible license terms.

@Be-ing
Copy link
Contributor

Be-ing commented Apr 22, 2020

@Holzhaus maybe you could do a little digging to search for libmad symbols in the Serato binary?

@Be-ing
Copy link
Contributor

Be-ing commented Apr 22, 2020

Ha! What an interesting find. In the "Applications Using MAD" section on the libMAD homepage, it lists Stanton Final Scratch Live, one of the first DVS programs first released in 2004. Serato Scratch Live was also first released in 2004, so it wouldn't surprise me if they also bought a proprietary license for libMAD around the same time.

@uklotzde
Copy link
Contributor

Mixxx uses libmad (SoundSourceMP3) on both Windows and Linux, so the offsets should be the same on both. Can you confirm that is correct, @uklotzde?

That's correct.

@Holzhaus Holzhaus marked this pull request as ready for review April 22, 2020 06:48
@Holzhaus
Copy link
Member Author

Ok, then lets merge and I'll rebase #2673 on master for the loop import.

@Be-ing Be-ing marked this pull request as ready for review April 22, 2020 07:08
@Be-ing Be-ing merged commit 22900e5 into mixxxdj:master Apr 22, 2020
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.

10 participants