Skip to content

Commit 808f85d

Browse files
committed
chore(deps): bump symphonia from 0.5.5 to 0.6.0
Bumps [symphonia](https://github.com/pdeljanov/Symphonia) from 0.5.5 to 0.6.0. - [Release notes](https://github.com/pdeljanov/Symphonia/releases) - [Commits](pdeljanov/Symphonia@v0.5.5...v0.6.0) --- updated-dependencies: - dependency-name: symphonia dependency-version: 0.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent 02a20cb commit 808f85d

6 files changed

Lines changed: 163 additions & 170 deletions

File tree

Cargo.lock

Lines changed: 62 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ simplelog = "0.12.2"
3939
unicode-segmentation = "1.13.3"
4040
unicode-width = "0.2.2"
4141
itertools = "0.15.0"
42-
symphonia = { version = "0.5.5", features = ["all-formats", "all-codecs"] }
42+
symphonia = { version = "0.6.0", features = ["all-formats", "all-codecs"] }
4343
rusty-chromaprint = "0.3.0"
4444
base64 = "0.22.1"
4545
float_eq = "1"

src/analyzer/chromaprint.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::config::Config;
1717
use base64::prelude::{Engine, BASE64_URL_SAFE_NO_PAD};
1818

1919
use symphonia::core::audio::Channels;
20-
use symphonia::core::codecs::CodecParameters;
20+
use symphonia::core::formats::Track;
2121

2222
use rusty_chromaprint::{Configuration, FingerprintCompressor, Fingerprinter};
2323

@@ -56,12 +56,16 @@ const MAX_DURATION: usize = 120;
5656
impl Analyzer for ChromaprintFingerprintAnalyzer {
5757
type Result = ChromaprintFingerprintResult;
5858

59-
fn initialize(_config: &Config, codec_params: &CodecParameters) -> Result<Self, AnalyzerError> {
60-
let sample_rate = codec_params
61-
.sample_rate
62-
.ok_or(AnalyzerError::MissingSampleRate)?;
63-
let channels = codec_params
59+
fn initialize(_config: &Config, track: &Track) -> Result<Self, AnalyzerError> {
60+
let spec = track
61+
.codec_params
62+
.as_ref()
63+
.and_then(|params| params.audio())
64+
.ok_or(AnalyzerError::NoSupportedAudioTracks)?;
65+
let sample_rate = spec.sample_rate.ok_or(AnalyzerError::MissingSampleRate)?;
66+
let channels = spec
6467
.channels
68+
.as_ref()
6569
.map(Channels::count)
6670
.and_then(|channel_count| u32::try_from(channel_count).ok())
6771
.ok_or(AnalyzerError::MissingAudioChannels)?;
@@ -80,8 +84,15 @@ impl Analyzer for ChromaprintFingerprintAnalyzer {
8084
Ok(analyzer)
8185
}
8286

83-
fn feed(&mut self, samples: &[i16]) -> Result<(), AnalyzerError> {
87+
fn feed(&mut self, samples: &[f32]) -> Result<(), AnalyzerError> {
8488
let remaining = self.stream_size_max - self.stream_size;
89+
90+
#[allow(clippy::cast_possible_truncation)]
91+
let samples: Vec<i16> = samples
92+
.iter()
93+
.map(|&sample| (sample * 32_768.0).trunc() as i16)
94+
.collect();
95+
8596
let chunk_size = samples.len().min(remaining);
8697
self.stream_size += chunk_size;
8798
self.fingerprinter.consume(&samples[..chunk_size]);

src/analyzer/ebur128.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use super::{Analyzer, AnalyzerError};
1414
use crate::config::Config;
1515

1616
use symphonia::core::audio::Channels;
17-
use symphonia::core::codecs::CodecParameters;
17+
use symphonia::core::formats::Track;
1818

1919
use ebur128::{energy_to_loudness, EbuR128, Mode};
2020

@@ -178,12 +178,16 @@ fn ratio_to_dbfs(value: f64) -> f64 {
178178
impl Analyzer for EbuR128Analyzer {
179179
type Result = EbuR128Result;
180180

181-
fn initialize(_config: &Config, codec_params: &CodecParameters) -> Result<Self, AnalyzerError> {
182-
let sample_rate = codec_params
183-
.sample_rate
184-
.ok_or(AnalyzerError::MissingSampleRate)?;
185-
let channel_count = codec_params
181+
fn initialize(_config: &Config, track: &Track) -> Result<Self, AnalyzerError> {
182+
let params = track
183+
.codec_params
184+
.as_ref()
185+
.and_then(|params| params.audio())
186+
.ok_or(AnalyzerError::NoSupportedAudioTracks)?;
187+
let sample_rate = params.sample_rate.ok_or(AnalyzerError::MissingSampleRate)?;
188+
let channel_count = params
186189
.channels
190+
.as_ref()
187191
.map(Channels::count)
188192
.ok_or(AnalyzerError::MissingAudioChannels)?;
189193

@@ -202,11 +206,7 @@ impl Analyzer for EbuR128Analyzer {
202206
Ok(analyzer)
203207
}
204208

205-
fn feed(&mut self, samples: &[i16]) -> Result<(), AnalyzerError> {
206-
let samples: Vec<f32> = samples
207-
.iter()
208-
.map(|&sample| f32::from(sample) / f32::from(i16::MAX))
209-
.collect();
209+
fn feed(&mut self, samples: &[f32]) -> Result<(), AnalyzerError> {
210210
for chunk in samples.chunks(self.chunk_size) {
211211
self.ebur128.add_frames_f32(chunk)?;
212212
}

0 commit comments

Comments
 (0)