Skip to content

Commit

Permalink
Add audio normalization device config option (#255)
Browse files Browse the repository at this point in the history
- Add `normalization` device config option for audio normalization
- Update device default config

Co-authored-by: Thang Pham <[email protected]>
  • Loading branch information
jsbmg and aome510 authored Sep 22, 2023
1 parent 05fbda6 commit d06ec2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 8 additions & 7 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ esac

The configuration options for the [Librespot](https://github.com/librespot-org/librespot) integrated device are specified under the `[device]` section in the `app.toml` file:

| Option | Description | Default |
| ------------- | ----------------------------------------------------------------------- | ---------------- |
| `name` | The librespot device's name | `spotify-player` |
| `device_type` | The librespot device's type | `speaker` |
| `volume` | Initial volume (in percentage) of the device | `50` |
| `bitrate` | Bitrate in kbps (`96`, `160`, or `320`) | `160` |
| `audio_cache` | Enable caching audio files (store in `$APP_CACHE_FOLDER/audio/` folder) | `false` |
| Option | Description | Default |
| --------------- | ----------------------------------------------------------------------- | ---------------- |
| `name` | The librespot device's name | `spotify-player` |
| `device_type` | The librespot device's type | `speaker` |
| `volume` | Initial volume (in percentage) of the device | `70` |
| `bitrate` | Bitrate in kbps (`96`, `160`, or `320`) | `320` |
| `audio_cache` | Enable caching audio files (store in `$APP_CACHE_FOLDER/audio/` folder) | `false` |
| `normalization` | Enable audio normalization | `false` |

More details on the above configuration options can be found under the [Librespot wiki page](https://github.com/librespot-org/librespot/wiki/Options).

Expand Down
5 changes: 3 additions & 2 deletions examples/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ playback_window_width = 6
[device]
name = "spotify-player"
device_type = "speaker"
volume = 50
bitrate = 160
volume = 70
bitrate = 320
audio_cache = false
normalization = false
6 changes: 4 additions & 2 deletions spotify_player/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ pub struct DeviceConfig {
pub volume: u8,
pub bitrate: u16,
pub audio_cache: bool,
pub normalization: bool,
}

#[derive(Debug, Deserialize, Serialize, ConfigParse, Clone)]
Expand Down Expand Up @@ -258,9 +259,10 @@ impl Default for DeviceConfig {
Self {
name: "spotify-player".to_string(),
device_type: "speaker".to_string(),
volume: 50,
bitrate: 160,
volume: 70,
bitrate: 320,
audio_cache: false,
normalization: false,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions spotify_player/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub fn new_connection(
.to_string()
.parse::<Bitrate>()
.unwrap_or_default(),
normalisation: device.normalization,
..Default::default()
};

Expand Down

0 comments on commit d06ec2a

Please sign in to comment.