MCPcopy Create free account
hub / github.com/PerroEngine/Perro / try_best_pmic

Function try_best_pmic

perro_source/audio_stack/perro_pawdio/src/mic.rs:259–279  ·  view source on GitHub ↗
(
    best: &mut Vec<u8>,
    codec: u8,
    channels: u16,
    sample_rate: u32,
    frames: u32,
    payload: Vec<u8>,
)

Source from the content-addressed store, hash-verified

257 return self.clone();
258 }
259 let mut state = MicDenoiseState::new(settings, self.sample_rate);
260 let samples = self
261 .samples
262 .iter()
263 .map(|sample| state.process_i16(*sample))
264 .collect();
265 Self::new(samples, self.sample_rate, self.channels)
266 }
267}
268
269fn decode_pcm_payload(payload: &[u8], frames: usize, channels: u16) -> Result<Vec<i16>, String> {
270 if !payload.len().is_multiple_of(2) {
271 return Err("mic clip odd payload len".to_string());
272 }
273 let expected_samples = checked_sample_len(frames, channels)?;
274 if payload.len() / 2 != expected_samples {
275 return Err(format!(
276 "mic clip len mismatch: expect {}, got {}",
277 expected_samples,
278 payload.len() / 2
279 ));
280 }
281 let mut samples = Vec::with_capacity(expected_samples);
282 for chunk in payload.chunks_exact(2) {

Callers 1

packMethod · 0.85

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected