diff --git a/src/command/render.rs b/src/command/render.rs index 0835544..2529d3c 100644 --- a/src/command/render.rs +++ b/src/command/render.rs @@ -291,7 +291,8 @@ pub async fn handle(state: State, interaction: Interaction) { let duration = end - start; tracing::info!(?voice_channel_id, ?start, ?end, ?duration); - let sample_rate = u32::from(state.audio_sample_rate); + let channels = state.audio_channels.into(); + let sample_rate = state.audio_sample_rate.into(); let total_samples = (duration.whole_seconds() as u32 * sample_rate) + (duration.subsec_microseconds() as u32 * sample_rate / 1_000_000); @@ -303,6 +304,8 @@ pub async fn handle(state: State, interaction: Interaction) { .recording_manager .between_in_vc(start, end, guild_id, voice_channel_id); + let mut recordings_used = 0; + while let Some(recording) = recordings.try_next().await.expect("TODO") { let recording_data = state .recording_manager @@ -341,6 +344,8 @@ pub async fn handle(state: State, interaction: Interaction) { + (after_start.subsec_microseconds() as u32 * sample_rate / 1_000_000); let origin = origin as usize; + tracing::debug!(origin, total_samples); + for (i, sample) in samples.into_iter().enumerate() { if let Some(composite_sample) = composite.get_mut(origin + i) { *composite_sample += sample; @@ -362,8 +367,12 @@ pub async fn handle(state: State, interaction: Interaction) { ); } } + + recordings_used += 1; } + tracing::debug!(?recordings_used); + let render = Render { start, end, @@ -371,7 +380,7 @@ pub async fn handle(state: State, interaction: Interaction) { voice_channel_id, }; let render_data = RenderData { - channels: state.audio_channels.into(), + channels, sample_rate, samples: composite, };