[PR #773] [MERGED] Keep samples in 64 bit #1072

Closed
opened 2026-02-27 20:01:03 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/773
Author: @roderickvd
Created: 5/27/2021
Status: Merged
Merged: 5/30/2021
Merged by: @roderickvd

Base: devHead: keep-samples-in-64-bit


📝 Commits (7)

  • c2e2a64 Keep samples in 64 bit
  • d65dfd3 Add f32 and f64 sample sizes
  • 4c7cc64 Move scale factors into named constants
  • 66dbd8a Handle 64-bit samples on other backends
  • 7039cf1 Update changelog
  • fa21aa7 Merge branch 'dev' into keep-samples-in-64-bit
  • 11f8c70 Merge branch 'dev' into keep-samples-in-64-bit

📊 Changes

19 files changed (+177 additions, -149 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 playback/src/audio_backend/alsa.rs (+1 -0)
📝 playback/src/audio_backend/jackaudio.rs (+4 -3)
📝 playback/src/audio_backend/mod.rs (+9 -5)
📝 playback/src/audio_backend/portaudio.rs (+4 -3)
📝 playback/src/audio_backend/pulseaudio.rs (+3 -0)
📝 playback/src/audio_backend/rodio.rs (+7 -3)
📝 playback/src/audio_backend/sdl.rs (+4 -3)
📝 playback/src/config.rs (+13 -9)
📝 playback/src/convert.rs (+22 -15)
📝 playback/src/decoder/lewton_decoder.rs (+3 -5)
📝 playback/src/decoder/mod.rs (+7 -2)
📝 playback/src/dither.rs (+8 -8)
📝 playback/src/mixer/alsamixer.rs (+13 -13)
📝 playback/src/mixer/mappings.rs (+25 -25)
📝 playback/src/mixer/mod.rs (+1 -1)
📝 playback/src/mixer/softmixer.rs (+10 -10)
📝 playback/src/player.rs (+32 -35)
📝 src/main.rs (+9 -9)

📄 Description

Perhaps counter-intuitively, the main reason for doing this is higher performance. Until now we are storing samples in f32 but casting them to f64 every time we manipulate them (normalisation, volume control), then cast them back again. The idea is that we can save CPU cycles and RAM copies by just keeping them in f64.

Added benefits are:

  • Support for F64 audio format
  • Even lower quantization error (bragging rights)

To re-iterate, 64 bit sample processing is already in, this just two places of casting back and forth while introducing one new one (reading lewton samples). So compared to the current situation, this should result in the following cases:

Volume control Normalisation Performance Sound quality
Softvol Disabled Equal Better
Softvol Enabled Faster Better
Softvol @ MAX Disabled Slower Equal
Softvol @ MAX Enabled Equal Better
Alsa mixer Disabled Slower Equal
Alsa mixer Enabled Equal Better

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/773 **Author:** [@roderickvd](https://github.com/roderickvd) **Created:** 5/27/2021 **Status:** ✅ Merged **Merged:** 5/30/2021 **Merged by:** [@roderickvd](https://github.com/roderickvd) **Base:** `dev` ← **Head:** `keep-samples-in-64-bit` --- ### 📝 Commits (7) - [`c2e2a64`](https://github.com/librespot-org/librespot/commit/c2e2a649c47cbd98e3dac57a62b40f791bc98ff8) Keep samples in 64 bit - [`d65dfd3`](https://github.com/librespot-org/librespot/commit/d65dfd385fe39d74301a0efb693d55d8faa14a47) Add `f32` and `f64` sample sizes - [`4c7cc64`](https://github.com/librespot-org/librespot/commit/4c7cc6410bb40927e4d41ffeeb0854dd611e000a) Move scale factors into named constants - [`66dbd8a`](https://github.com/librespot-org/librespot/commit/66dbd8a7a0b4167a8f14de6a6e7f983db8f4d58c) Handle 64-bit samples on other backends - [`7039cf1`](https://github.com/librespot-org/librespot/commit/7039cf12ed4d7a51d2629142bd669c3b7d212ccd) Update changelog - [`fa21aa7`](https://github.com/librespot-org/librespot/commit/fa21aa748d473fd976d3f493a9638f35381acd6e) Merge branch 'dev' into keep-samples-in-64-bit - [`11f8c70`](https://github.com/librespot-org/librespot/commit/11f8c70268fd4c59bf0d44b33b44784e8a68f801) Merge branch 'dev' into keep-samples-in-64-bit ### 📊 Changes **19 files changed** (+177 additions, -149 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `playback/src/audio_backend/alsa.rs` (+1 -0) 📝 `playback/src/audio_backend/jackaudio.rs` (+4 -3) 📝 `playback/src/audio_backend/mod.rs` (+9 -5) 📝 `playback/src/audio_backend/portaudio.rs` (+4 -3) 📝 `playback/src/audio_backend/pulseaudio.rs` (+3 -0) 📝 `playback/src/audio_backend/rodio.rs` (+7 -3) 📝 `playback/src/audio_backend/sdl.rs` (+4 -3) 📝 `playback/src/config.rs` (+13 -9) 📝 `playback/src/convert.rs` (+22 -15) 📝 `playback/src/decoder/lewton_decoder.rs` (+3 -5) 📝 `playback/src/decoder/mod.rs` (+7 -2) 📝 `playback/src/dither.rs` (+8 -8) 📝 `playback/src/mixer/alsamixer.rs` (+13 -13) 📝 `playback/src/mixer/mappings.rs` (+25 -25) 📝 `playback/src/mixer/mod.rs` (+1 -1) 📝 `playback/src/mixer/softmixer.rs` (+10 -10) 📝 `playback/src/player.rs` (+32 -35) 📝 `src/main.rs` (+9 -9) </details> ### 📄 Description Perhaps counter-intuitively, the main reason for doing this is higher performance. Until now we are storing samples in `f32` but casting them to `f64` every time we manipulate them (normalisation, volume control), then cast them back again. The idea is that we can save CPU cycles and RAM copies by just keeping them in `f64`. Added benefits are: - Support for F64 audio format - Even lower quantization error (bragging rights) To re-iterate, 64 bit sample processing is already in, this just two places of casting back and forth while introducing one new one (reading `lewton` samples). So compared to the current situation, this should result in the following cases: Volume control | Normalisation | Performance | Sound quality -------------- | ------------- | ----------- | ------------- Softvol | Disabled | Equal | Better Softvol | Enabled | Faster | Better Softvol @ MAX | Disabled | Slower | Equal Softvol @ MAX | Enabled | Equal | Better Alsa mixer | Disabled | Slower | Equal Alsa mixer | Enabled | Equal | Better --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:01:03 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#1072
No description provided.