Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrick99e99/ac4a75c9ceb466da1b02 to your computer and use it in GitHub Desktop.
Save patrick99e99/ac4a75c9ceb466da1b02 to your computer and use it in GitHub Desktop.
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