Skip to content

Commit

Permalink
Merge pull request #19 from xd009642/feat/proper-audio
Browse files Browse the repository at this point in the history
Start doing some proper audio handling
  • Loading branch information
xd009642 authored Sep 4, 2024
2 parents 112ace0 + 0b36f45 commit cec485a
Show file tree
Hide file tree
Showing 6 changed files with 720 additions and 17 deletions.
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

0 comments on commit cec485a

Please sign in to comment.