fix: Correct ResamplingNode API usage for AudioChunkData

- Replace BitDepth::from_audio_chunk() with match pattern
- Use get_frames() instead of stereo() method (API change)
- Use as_i32() instead of to_i32() for I24 conversion

Also successfully installed libsoxr locally without sudo:
- Downloaded libsoxr-dev and libsoxr0 via apt-get
- Extracted to ~/.local using dpkg -x
- Set PKG_CONFIG_PATH and LD_LIBRARY_PATH
- Compilation now succeeds with libsoxr

The implementation is now complete and compiles successfully.
This commit is contained in:
Claude
2025-11-05 13:56:27 +00:00
parent 6a7ba01102
commit 83e9cca756

View File

@@ -68,7 +68,13 @@ impl ResamplingLogic {
/// Resample un chunk audio vers le sample rate cible /// Resample un chunk audio vers le sample rate cible
fn resample_chunk(&mut self, chunk: &AudioChunk) -> Result<AudioChunk, AudioError> { fn resample_chunk(&mut self, chunk: &AudioChunk) -> Result<AudioChunk, AudioError> {
let source_sr = chunk.sample_rate(); let source_sr = chunk.sample_rate();
let bit_depth = BitDepth::from_audio_chunk(chunk); let bit_depth = match chunk {
AudioChunk::I16(_) => BitDepth::B16,
AudioChunk::I24(_) => BitDepth::B24,
AudioChunk::I32(_) => BitDepth::B32,
AudioChunk::F32(_) => BitDepth::B32, // Traiter comme 32-bit
AudioChunk::F64(_) => BitDepth::B32, // Traiter comme 32-bit
};
// Si déjà au bon sample rate, retourner tel quel // Si déjà au bon sample rate, retourner tel quel
if source_sr == self.target_sample_rate { if source_sr == self.target_sample_rate {
@@ -179,44 +185,44 @@ impl NodeLogic for ResamplingLogic {
fn extract_channels_i32(chunk: &AudioChunk) -> Result<(Vec<i32>, Vec<i32>), AudioError> { fn extract_channels_i32(chunk: &AudioChunk) -> Result<(Vec<i32>, Vec<i32>), AudioError> {
match chunk { match chunk {
AudioChunk::I16(data) => { AudioChunk::I16(data) => {
let stereo = data.stereo(); let frames = data.get_frames();
let left = stereo.iter().map(|frame| frame[0] as i32).collect(); let left = frames.iter().map(|frame| frame[0] as i32).collect();
let right = stereo.iter().map(|frame| frame[1] as i32).collect(); let right = frames.iter().map(|frame| frame[1] as i32).collect();
Ok((left, right)) Ok((left, right))
} }
AudioChunk::I24(data) => { AudioChunk::I24(data) => {
let stereo = data.stereo(); let frames = data.get_frames();
let left = stereo.iter().map(|frame| frame[0].to_i32()).collect(); let left = frames.iter().map(|frame| frame[0].as_i32()).collect();
let right = stereo.iter().map(|frame| frame[1].to_i32()).collect(); let right = frames.iter().map(|frame| frame[1].as_i32()).collect();
Ok((left, right)) Ok((left, right))
} }
AudioChunk::I32(data) => { AudioChunk::I32(data) => {
let stereo = data.stereo(); let frames = data.get_frames();
let left = stereo.iter().map(|frame| frame[0]).collect(); let left = frames.iter().map(|frame| frame[0]).collect();
let right = stereo.iter().map(|frame| frame[1]).collect(); let right = frames.iter().map(|frame| frame[1]).collect();
Ok((left, right)) Ok((left, right))
} }
AudioChunk::F32(data) => { AudioChunk::F32(data) => {
let stereo = data.stereo(); let frames = data.get_frames();
// Convertir f32 → i32 (dénormaliser) // Convertir f32 → i32 (dénormaliser)
let left = stereo let left = frames
.iter() .iter()
.map(|frame| (frame[0] * i32::MAX as f32) as i32) .map(|frame| (frame[0] * i32::MAX as f32) as i32)
.collect(); .collect();
let right = stereo let right = frames
.iter() .iter()
.map(|frame| (frame[1] * i32::MAX as f32) as i32) .map(|frame| (frame[1] * i32::MAX as f32) as i32)
.collect(); .collect();
Ok((left, right)) Ok((left, right))
} }
AudioChunk::F64(data) => { AudioChunk::F64(data) => {
let stereo = data.stereo(); let frames = data.get_frames();
// Convertir f64 → i32 (dénormaliser) // Convertir f64 → i32 (dénormaliser)
let left = stereo let left = frames
.iter() .iter()
.map(|frame| (frame[0] * i32::MAX as f64) as i32) .map(|frame| (frame[0] * i32::MAX as f64) as i32)
.collect(); .collect();
let right = stereo let right = frames
.iter() .iter()
.map(|frame| (frame[1] * i32::MAX as f64) as i32) .map(|frame| (frame[1] * i32::MAX as f64) as i32)
.collect(); .collect();