Commit graph

1328 commits

Author SHA1 Message Date
Sasha Hilton
8fe2e01166
Merge pull request #660 from roderickvd/hi-res-volume-control
High-resolution volume control and normalisation
2021-04-10 01:26:20 +01:00
johannesd3
9378ae5b6f Bump num-bigint dependency 2021-04-09 22:39:51 +02:00
johannesd3
7ddb1a20bb Reuse librespot-core's Diffie Hellman in discovery 2021-04-09 22:39:47 +02:00
Roderick van Domburg
e20b96c598 Merge remote-tracking branch 'upstream/dev' into hi-res-volume-control 2021-04-09 20:06:20 +02:00
Roderick van Domburg
222f9bbd01 Bump playback crates to the latest supporting Rust 1.41.1
For Rodio, this fixes garbled sound on some but not all Alsa hosts.
2021-04-09 20:01:21 +02:00
Roderick van Domburg
d0ea9631d2 Optimize requantizer to work in f32, then round 2021-04-09 19:33:28 +02:00
johannesd3
11ce29077e Fix formatting 2021-04-09 10:45:48 +02:00
johannesd3
7c3d89112d Fix clippy warnings 2021-04-09 10:45:43 +02:00
johannesd3
f5274f5ada Merge branch 'dev' into tokio_migration 2021-04-09 10:39:06 +02:00
Sasha Hilton
6df977907e
Merge pull request #664 from philippe44/passthrough-update
separated stream for each seek
2021-04-09 01:40:12 +01:00
Roderick van Domburg
928a673653 DRY up constructors 2021-04-05 23:14:02 +02:00
Roderick van Domburg
78bc621ebb Move SamplesConverter into convert.rs 2021-04-05 21:30:40 +02:00
Roderick van Domburg
0149725d77 Log error instead of panicking when child fails to start 2021-03-31 22:16:34 +02:00
Roderick van Domburg
07d710e14f Use AudioFormat size for SDL 2021-03-31 20:41:09 +02:00
Ash
d4dfd4890f
Merge pull request #674 from Johannesd3/proxy-support
[Tokio migration] Add back hyper-proxy
2021-03-29 21:00:18 +02:00
Roderick van Domburg
d252eeedc5 Warn about broken backends 2021-03-27 22:53:05 +01:00
Roderick van Domburg
cc60dc11dc Fix buffer size in JACK Audio backend 2021-03-27 22:52:43 +01:00
Roderick van Domburg
a200b25916 Fix formatting 2021-03-27 21:44:01 +01:00
Roderick van Domburg
cdbce21e71 Make S16 to F32 sample conversion less magical 2021-03-27 21:42:10 +01:00
Roderick van Domburg
bfca1ec15e Minor code improvements and crates bump 2021-03-27 21:13:14 +01:00
johannesd3
95fedf5357 Add back hyper-proxy 2021-03-27 15:36:33 +01:00
Ash
1051f983ed
Merge pull request #663 from ThouCheese/tokio_migration
Update examples
2021-03-24 19:56:16 +01:00
ThouCheese
ec1ec59b8a update examples
Re-add default impl to SessionConfig and make Credentials::with_password generic over Into<String>

add docs for Credential

reintroduce old Default impl for SessionConfig

use the third argument for the track-to-play rather than a testing id
2021-03-24 01:14:44 +01:00
Roderick van Domburg
74b2fea338 Refactor sample conversion into separate struct 2021-03-21 22:16:47 +01:00
philippe44
86dbaa8ed5
true/false don't need to be explicit
Co-authored-by: Johannesd3 <51954457+Johannesd3@users.noreply.github.com>
2021-03-20 12:11:49 -07:00
Roderick van Domburg
001d3ca1cf Bump Alsa, cpal and GStreamer crates 2021-03-19 22:28:55 +01:00
Roderick van Domburg
a1326ba9f4 First round of refactoring
- DRY-ups

 - Remove incorrect optimization attempt in the libvorbis decoder,
   that skewed 0.0 samples non-linear

 - PortAudio and SDL backends do not support S24 output. The PortAudio
   bindings could, but not through this API.
2021-03-18 22:06:43 +01:00
Roderick van Domburg
b94879de62 Fix GStreamer buffer pool size [ref #660 review] 2021-03-18 20:51:53 +01:00
Sasha Hilton
963d50e725
Merge pull request #658 from Johannesd3/refactor-audio-file-fetch
[Tokio migration] Refactor AudioFileFetch
2021-03-17 01:24:49 +00:00
Roderick van Domburg
770ea15498 Add support for S24 and S24_3 output formats 2021-03-17 00:00:27 +01:00
Roderick van Domburg
9dcaeee6d4 Default to S16 output 2021-03-16 20:22:00 +01:00
Roderick van Domburg
309e26456e Rename steepness to knee 2021-03-14 14:28:16 +01:00
Roderick van Domburg
5f26a745d7 Add support for S32 output format
While at it, add a small tweak when converting "silent" samples
from float to integer. This ensures 0.0 converts to 0 and vice
versa.
2021-03-13 23:43:24 +01:00
Roderick van Domburg
a4ef174fd0 Fix Alsa backend for 64-bit systems 2021-03-12 23:50:17 +01:00
Roderick van Domburg
6379926eb4 Fix example 2021-03-12 23:47:15 +01:00
Roderick van Domburg
5257be7824 Add command-line option to set F32 or S16 bit output
Usage: `--format {F32|S16}`. Default is F32.

 - Implemented for all backends, except for JACK audio which itself
 only supports 32-bit output at this time. Setting JACK audio to S16
 will panic and instruct the user to set output to F32.

 - The F32 default works fine for Rodio on macOS, but not on Raspian 10
 with Alsa as host. Therefore users on Linux systems are warned to set
 output to S16 in case of garbled sound with Rodio. This seems an issue
 with cpal incorrectly detecting the output stream format.

 - While at it, DRY up lots of code in the backends and by that virtue,
 also enable OggData passthrough on the subprocess backend.

 - I tested Rodio, ALSA, pipe and subprocess quite a bit, and call on
 others to join in and test the other backends.
2021-03-12 23:09:15 +01:00
Roderick van Domburg
1672eb87ab Fix build on Rust < 1.50.0 2021-03-12 23:09:15 +01:00
Roderick van Domburg
f29e5212c4 High-resolution volume control and normalisation
- Store and output samples as 32-bit floats instead of 16-bit integers.
   This provides 24-25 bits of transparency, allowing for 42-48 dB of
   headroom to do volume control and normalisation without throwing
   away bits or dropping dynamic range below 96 dB CD quality.

 - Perform volume control and normalisation in 64-bit arithmetic.

 - Add a dynamic limiter with configurable threshold, attack time,
   release or decay time, and steepness for the sigmoid transfer
   function. This mimics the native Spotify limiter, offering greater
   dynamic range than the old limiter, that just reduced overall gain
   to prevent clipping.

 - Make the configurable threshold also apply to the old limiter, which
   is still available.

Resolves: librespot-org/librespot#608
2021-03-12 23:09:15 +01:00
johannesd3
ca255c17f0 Split file fetch.rs 2021-03-11 18:09:51 +01:00
johannesd3
e71a004e93 Refactor AudioFileFetch using async/await
Previously, polling `AudioFileFetch` consisted of three parts: Handling
stream loader commands, handling received data, and triggering preloading
in stream mode when the number of open requests is sufficiently small. The
first steps use channels which are polled, and if something's available,
it's handled. The third step is executed on every call of `poll`.

The first two could easily be refactored using a `tokio::select!`-loop.
Therefore, counting the number of open requests was also refactored to fit
into this scheme. They were previously counted using a shared
`AtomicUsize`. Now, the number of open requests is stored exclusively in
`AudioFileFetch`, increased on starting a request, and decreased by an
oneshot channel that is fired when a request is finished.

This allows us to `select` that channel in the loop too, and since
loading ahead makes only sense if the number of open requests decreases,
the third step is only executed in this case.

`AudioFileFetch` does not implement `Future` anymore, but is rather used
as helper struct in an async fn `audio_file_fetch`.
2021-03-11 18:08:00 +01:00
Ash
173a36332f
Merge pull request #667 from Johannesd3/small-fixes
Fix remaining clippy warnings
2021-03-11 15:19:09 +01:00
johannesd3
059b9029de Remove redundant field names 2021-03-10 22:41:46 +01:00
johannesd3
5616004dbe Fix many clippy lints
...and other small improvements
2021-03-10 22:41:44 +01:00
Jack Strickland
eb4dacbc59 Add shuffle command and command handling 2021-03-09 15:37:11 -06:00
Ash
38761395d3
Merge pull request #652 from leshow/cleanup
clean up imports & clippy lints
2021-03-09 22:29:02 +01:00
Evan Cameron
3388508141
use current_thread 2021-02-28 22:09:46 -05:00
Evan Cameron
6a33eb4efa
minor cleanup 2021-02-28 21:54:19 -05:00
Philippe G
8dc1e80633 separated stream for each seek 2021-02-27 14:59:53 -08:00
Ash
9d77fef008
Merge pull request #649 from Johannesd3/tokio-migration-refactor-deps
[Tokio migration] Merge dev and refactor
2021-02-26 10:49:10 +01:00
Ash
56f1fb6dae
Merge pull request #595 from Johannesd3/const_versions
Replace version functions by constants
2021-02-26 10:47:44 +01:00