Commit Graph

280 Commits

Author SHA1 Message Date
Max Kellermann e565dcf18c pcm/dsd2pcm: convert to C++ 2020-01-14 22:05:58 +01:00
Max Kellermann 5a87fc7c26 pcm/dsd2pcm: remove unused sources 2020-01-14 22:05:27 +01:00
Max Kellermann 44d7a1d8d2 pcm/Traits: drop "_type" from type names 2020-01-03 16:01:44 +01:00
Max Kellermann 683d5848f4 Merge tag 'v0.21.17'
release v0.21.17
2019-12-16 23:44:20 +01:00
Max Kellermann dc3c0c8866 pcm/Convert, ...: add missing include for std::runtime_error 2019-12-16 22:52:50 +01:00
Max Kellermann f357f743a3 pcm/Volume: use transform_n() 2019-08-10 12:05:37 +02:00
Max Kellermann 91e565d92e pcm/PcmFormat: use transform_n() 2019-08-10 12:05:35 +02:00
Max Kellermann af99f9fc90 pcm/Volume: convert S16 to S24 to preserve quality and reduce noise
Applying software volume to S16 samples means several bits of
precision are lost; at 25% volume, two bits are lost.  Additionally,
dithering adds some noise.

The problem gets worse when you apply the software volume code twice:
for the software mixer volume, and again for the replay gain.  This
loses some more precision and adds even more dithering noise, which
can become audible (see
https://github.com/MusicPlayerDaemon/MPD/issues/542).

By converting everything to 24 bit, we need to shift only two bits to
the right instead of ten, losing nearly no precision, and dithering is
not needed.  Even if the output device is unable to play S24 directly,
we can convert back to S16 with only one stage of dithering.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/542
2019-07-30 20:03:37 +02:00
Max Kellermann 326c6ae615 pcm/Volume: add variable "dest_size" 2019-07-05 21:01:09 +02:00
Max Kellermann 5fa7610264 pcm/Volume: Open() returns output sample format
Prepare for a new mode which may convert to a different sample format
when applying volume, to reduce dithering.
2019-07-05 19:03:00 +02:00
Max Kellermann 1c757f8c1c pcm/Volume: allow any exception 2019-07-05 19:01:46 +02:00
Max Kellermann 06fbbe2d7b pcm/Volume: calculate PCM_VOLUME_1 2019-07-05 18:26:26 +02:00
Max Kellermann 21d91cb1d1 pcm/Volume: fix API documentation 2019-07-05 18:26:14 +02:00
Max Kellermann d663f81420 include cleanups (powered by iwyu) 2019-07-05 09:59:58 +02:00
Max Kellermann beed004b10 pcm/Export: add GetSilence() 2019-06-26 16:04:46 +02:00
Max Kellermann 34c6337887 pcm/Export: add GetInputBlockSize(), GetOutputBlockSize() 2019-06-26 15:49:08 +02:00
Max Kellermann 2093e53641 pcm/Export: add GetInputFrameSize() 2019-06-26 15:48:18 +02:00
Max Kellermann 2f243f2295 pcm/Export: rename GetFrameSize() to GetOutputFrameSize() 2019-06-26 15:46:49 +02:00
Max Kellermann e69fd0300a pcm/Export: rename CalcSourceSize() to CalcInputSize() 2019-06-26 15:46:05 +02:00
Max Kellermann f43cafbf7d pcm/Export: eliminate the AudioFormat parameter from GetFrameSize() 2019-06-26 15:42:47 +02:00
Max Kellermann 53faf77d20 pcm/Export: use the "channels" attribute in GetFrameSize() 2019-06-26 15:41:07 +02:00
Max Kellermann bf574dcb0a pcm/RestBuffer: make internal methods private 2019-06-26 14:44:20 +02:00
Max Kellermann 72b8f33272 pcm/Export: split src_sample_format from alsa_channel_order
Combining these two in one single value saves some memory, but is
complicated and we may need the src_sample_format for new features
later.
2019-06-18 12:19:40 +02:00
Max Kellermann a17f420d6b pcm/Export: update API documentation 2019-06-18 12:19:40 +02:00
Max Kellermann bf26adf555 pcm/Dsd{16,32}: stash odd frames away for the next call
Similar to commit 32380d1db0, these are
the final parts for really fixing
https://github.com/MusicPlayerDaemon/MPD/issues/469
2019-06-18 11:19:27 +02:00
Max Kellermann 0cc94fe30c pcm/Dsd{16,32}: convert public function to stateful class 2019-06-18 10:58:55 +02:00
Max Kellermann d5d5705213 pcm/Export: update API documentation 2019-06-18 10:58:26 +02:00
Max Kellermann 96d74e77eb pcm/Dsd{16,32}: move the conversion loop to a separate function 2019-06-17 22:51:01 +02:00
Max Kellermann 28e07e900f pcm/Export: convert the DSD bools to an enum
These options are exclusive.
2019-06-17 22:35:00 +02:00
Max Kellermann 32380d1db0 pcm/Dop: stash odd frames away for the next call
First part of the "real" fix for
https://github.com/MusicPlayerDaemon/MPD/issues/469
2019-06-17 22:18:44 +02:00
Max Kellermann c9f1354e4d pcm/RestBuffer: new utility class 2019-06-17 22:18:41 +02:00
Max Kellermann e3f9e96eef pcm/Dop: convert public function to stateful class
Preparing to add more state.
2019-06-17 22:16:29 +02:00
Max Kellermann 8f9b3cbf0e pcm/Dop: add separate dsd_buffer for DSD_U16/32
The dop_buffer will be moved out soon.
2019-06-17 22:11:23 +02:00
Max Kellermann 458a1beed9 AudioFormat: move MAX_CHANNELS to pcm/ChannelDefs.hxx
Reduce header dependencies.
2019-06-17 22:11:08 +02:00
Max Kellermann 33f5e03e80 Merge branch 'v0.21.x' 2019-06-17 22:06:54 +02:00
Max Kellermann d478bdda8e pcm/Export: document that Export() may return an empty buffer 2019-06-17 21:07:29 +02:00
Max Kellermann e87f0ca771 pcm/Pcm*: drop more "Pcm" prefixes from source file names 2019-06-17 11:17:48 +02:00
Max Kellermann a139279575 Copyright year 2019 2019-06-17 11:17:30 +02:00
Max Kellermann 9fcd33cc8d pcm/Dop: move the conversion loop to separate function 2019-06-16 12:23:48 +02:00
Max Kellermann 96ff6b9b8b pcm/Dop: remove redundant inline keywords 2019-06-16 12:23:38 +02:00
Max Kellermann fd5e74dbd0 pcm/Pcm{Dop,Export}: drop "Pcm" prefix 2019-06-16 12:11:44 +02:00
Max Kellermann b64571f4a5 pcm/Export: update API documentation 2019-06-16 11:52:57 +02:00
Max Kellermann 6addc9d6e0 pcm/PcmConvert: remove unused attribute "dest_format" 2019-04-04 21:06:28 +02:00
Max Kellermann e78d825059 pcm/PcmConvert: eliminate Open() and Close()
Let the constructor and destructor do this.  This means that all users
have to be converted to allocate PcmConvert dynamically.
2019-04-04 21:01:08 +02:00
Max Kellermann f2cacaf6b6 AudioFormat, pcm/Dsd*: remove redundant inline keywords from constexpr functions 2019-03-08 10:29:03 +01:00
Max Kellermann c176d94598 system/ByteOrder: move to util/ 2019-03-08 10:21:10 +01:00
Max Kellermann ce49d99c2f check.h: remove obsolete header
Since we switched from autotools to Meson in commit
94592c1406, we don't need to include
`config.h` early to properly enable large file support.  Meson passes
the required macros on the compiler command line instead of defining
them in `config.h`.

This means we can include `config.h` at any time, whenever we want to
check its macros, and there are no ordering constraints.
2018-11-19 16:33:49 +01:00
Max Kellermann f5c9071494 *: copyright year 2018 2018-10-31 17:54:59 +01:00
Max Kellermann c97469283c pcm: build dsd2pcm only if -Dtest=true 2018-10-30 13:31:43 +01:00
Max Kellermann 804ccddf7e pcm/Clamp: convert to constexpr 2018-10-30 00:08:25 +01:00