Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start doing some proper audio handling #19

Merged
merged 12 commits into from
Sep 4, 2024
200 changes: 200 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ opentelemetry = "0.23.0" # otel versions are tied to `init-tracing-opentelemetry
opentelemetry-otlp = "0.16.0"
opentelemetry-semantic-conventions = "0.15.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "trace"] }
rubato = "0.15.0"
serde = { version = "1.0.200", features = ["derive"] }
serde_json = "1.0.117"
tokio = { version = "1.37.0", features = ["macros", "signal", "sync", "rt-multi-thread"] }
Expand All @@ -37,8 +38,13 @@ tracing-opentelemetry = "0.24.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[dev-dependencies]
tracing-test = "0.2.4"
dasp = { version = "0.11.0", features = ["signal"] }
hound = "3.5.1"
tracing-test = { version = "0.2.4", features = ["no-env-filter"] }

[[bin]]
name = "client"
required-features = ["tokio-tungstenite", "hound"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
16 changes: 16 additions & 0 deletions src/api_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct StartMessage {
/// Trace ID for distributed tracing
pub trace_id: Option<String>,
/// Format information for the audio samples
pub format: AudioFormat,
}

/// Describes the PCM samples coming in. I could have gone for an enum instead of bit_depth +
/// is_float but I only really plan on doing f32, s16 and ignoring everything else including
/// compression schemes like mulaw etc. This may change in future.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct AudioFormat {
/// Number of channels in the audio
pub channels: usize,
/// Sample rate of the audio
pub sample_rate: usize,
/// Number of bits per sample
pub bit_depth: u16,
/// Whether audio uses floating point samples
pub is_float: bool,
}

impl Extractor for StartMessage {
Expand Down
Loading
Loading