Last active
August 29, 2015 14:14
-
-
Save patrick99e99/ac4a75c9ceb466da1b02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def converted | |
low_pass!(buffer, 4000) | |
new_number_of_samples = ((8000.0 / 44100.0) * number_of_samples).ceil | |
period = 1 / buffer.sample_rate.to_f | |
new_period = 1 / target_sample_rate.to_f | |
new_number_of_samples.times do |m| | |
sum = 0 | |
number_of_samples.times do |n| | |
blob = ((m * new_period) - (n * period)) / period | |
sum += buffer[n] * Math.sin(blob)/blob | |
end | |
downsampled[m] = sum | |
end | |
downsampled | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment