From 5d708ecfbadc092804de2c16739003938e2c9ef0 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 3 Aug 2012 00:32:56 -0500 Subject: [PATCH] Fixed a small rounding bug with the audio resampling --- src/Frame.cpp | 4 ++-- src/Main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index eed3b809..ab711118 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -279,7 +279,7 @@ float* Frame::GetInterleavedAudioSamples(int new_sample_rate, int* sample_count) // Set the sample ratio (original to new sample rate) double source_ratio = double(sample_rate) / double(new_sample_rate); double dest_ratio = double(new_sample_rate) / double(sample_rate); - int new_num_of_samples = num_of_samples * dest_ratio; + int new_num_of_samples = round(num_of_samples * dest_ratio); resample_source.setResamplingRatio(source_ratio); // Prepare to resample @@ -290,7 +290,7 @@ float* Frame::GetInterleavedAudioSamples(int new_sample_rate, int* sample_count) const AudioSourceChannelInfo resample_callback_buffer = {resampled_buffer, 0, new_num_of_samples}; resample_callback_buffer.clearActiveBufferRegion(); - // Resample the current frame's audio buffer (info the temp callback buffer) + // Resample the current frame's audio buffer (into the temp callback buffer) resample_source.getNextAudioBlock(resample_callback_buffer); // Update buffer pointer to this newly resampled buffer diff --git a/src/Main.cpp b/src/Main.cpp index 8876c6b7..cbe4704e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -30,7 +30,7 @@ int main() r.DisplayInfo(); // Create a writer - FFmpegWriter w("/home/jonathan/output.webm"); + FFmpegWriter w("/home/jonathan/output.ogg"); w.DisplayInfo(); // Set options