-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Consider the following code:
require 'wavefile'
include WaveFile
#1 second 440 Hz square wave
format = Format.new(:mono, 16, 44100)
writer = Writer.new("square.wav", format)
cycle = ([2**15] * 50) + ([-2**15] * 50)
buffer = Buffer.new(cycle, format)
441.times do
writer.write(buffer)
end
writer.close()
# square.wav now has 44100 samples
# read square wave in at half the sampling rate
samples = []
format = Format.new(:mono, 16, 22050)
reader = Reader.new("square.wav", format).each_buffer(1024) do |buffer|
samples += buffer.samples
end
puts "#{samples.length} samples read"
# outputs "44100 samples read"
I would assume to get 22050 samples instead of 44100, thus a resampled version of the file. Am i the only one feeling this way?
taf2
Metadata
Metadata
Assignees
Labels
No labels