Floating point WAV/AIFF recording

Bug #1415720 reported by Decklin Foster
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Wishlist
JosepMa

Bug Description

Recording to WAV/AIFF currently uses 16-bit PCM: https://github.com/mixxxdj/mixxx/blob/master/src/engine/sidechain/enginerecord.cpp#L283

As I understand it, Mixxx uses floating point internally, and so when it writes samples later on in that code, they are converted to 16-bit integers by libsndfile. The normalization mode is set here: https://github.com/mixxxdj/mixxx/blob/master/src/engine/sidechain/enginerecord.cpp#L298 (see http://www.mega-nerd.com/libsndfile/command.html#SFC_SET_NORM_FLOAT).

I would like to record WAV/AIFF in floating point directly, instead. I'm doing this to eventually produce a FLAC file, and I'd like to, in "post-production", do volume normalization on the raw floating point data and then dither to 16-bit with other, higher-quality-than-libsndfile software.

The particular irritation I have with libsndfile's conversion to 16-bit (aside from the knawing sense that some in-between levels produced by EQ/filters are being tossed out) is that if I *ever* clip, there's a very noticeable pop when the sample "wraps around" as if there was a simple integer overflow in that code. I would prefer to treat that with a limiter in post. With MP3/Ogg recording (I only tried MP3), the samples above 0dB are clamped, which distorts the audio, but doesn't produce the "pop" (which I assume is why most people haven't noticed/don't care about it, loud distortion sounds normal these days :-))

I think it is better to simply change Mixxx's WAV/AIFF recording to floating point rather than adding an option. MP3/Ogg will still convert to 16-bit PCM and that's what most people will need/default to. If they're looking for WAV/AIFF output, they presumably want the highest quality possible (if they just want to run their own fancy MP3 encoder on it, it should also be able to handle limiting and dithering). I think this should just be a matter of changing the flags used to open the file (lines 284/286) and removing the sf_command call (line 298). If I had a build environment set up, I'd try it... I can send a pull request anyway if you want.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

+1 for removing the libsndfile normalization
+1 for adding an option for floating point output
-1 for making floating point wav output default (since this not the most common format)

Thank you for reporting the bug and offering your help.

What about adding a preference option for the wave sample format.
Portaudio offers function for float to S16 conversion including dithering. We should use this: http://portaudio.com/docs/v19-doxydocs-dev/pa__converters_8c.html instead of the libsndfile version.
In case of clipping, clamping is the best solution. We do it elsewhere in Mixxx and it is in charge of the user to avoid it.
Once it is available, the user can add a compressor effect to the master channel to address the issue explicit.

Do you need help with the first steps?
This might be helpful as well: http://www.mixxx.org/wiki/doku.php/bugfix_workflow

Changed in mixxx:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Daniel Schürmann (daschuer) wrote :

Just filed a separate Bug about the original click issue Bug #1415758

Revision history for this message
Decklin Foster (decklin) wrote :

OK, I will look at adding UI for selecting floating-point or not (it may take me a bit to get around to setting up a build env). How about re-using the slider that selects quality (bitrate) for MP3/Ogg? It could just have 16-bit PCM on the left and 32-bit floating point on the right.

Thanks for opening the other bug, it would be good to have that fixed for 16-bit PCM regardless (one scenario I didn't think of is people who want to burn an audio CD and just know they need WAV for that).

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Reusing the slider is a good first version.

On the long run, I would prefer to rework the preference pane and introduce combo boxes like on the interface pane.
Individual hidden control groups for each codec would be the best, but that is a different issue.

Revision history for this message
Thorsten Munsch (thorsten-munsch) wrote :

Is there any progress on this one?

The clipping bug has to be solved before the 1.12 release.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

This bug is still unassigned, so we can assume no progress.

Revision history for this message
Thorsten Munsch (thorsten-munsch) wrote :

Works.

Changed sound format from SF_FORMAT_PCM_16 to SF_FORMAT_DOUBLE and commented out the sf_command() call.

Run a build, started recording into wave format and a really ugly mix, full in the red, and neither in the speakers or in the recorded 64bit float wave (played afterwards via audacious) the clicks/pops are noticable.

:)

JosepMa (josepma)
Changed in mixxx:
assignee: nobody → JosepMa (josepma)
JosepMa (josepma)
Changed in mixxx:
status: Confirmed → In Progress
Revision history for this message
JosepMa (josepma) wrote :
JosepMa (josepma)
Changed in mixxx:
status: In Progress → Fix Committed
Changed in mixxx:
milestone: none → 2.1.0
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/7837

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.