Module: Libsamplerate
- Defined in:
- lib/utils.rb,
lib/libsamplerate.rb,
lib/libsamplerate/version.rb,
lib/libsamplerate/static_resampler.rb
Defined Under Namespace
Modules: FFI
Classes: StaticResampler
Constant Summary
collapse
- CONVERTERS =
{
src_sinc_best_quality: 0,
src_sinc_medium_quality: 1,
src_sinc_fastest: 2,
src_zero_order_hold: 3,
src_linear: 4
}
- VERSION =
"0.0.1"
Class Method Summary
collapse
Class Method Details
.get_float_buffer_from_mono_file(file) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/utils.rb', line 12
def self.get_float_buffer_from_mono_file file
raise "This is not a mono file" if get_sound_file_info(file).channels == 1
buffer = []
RubyAudio::Sound.open(file) do |snd|
snd.read(:float, snd.info.frames).each do |sample|
buffer.push(sample)
end
end
buffer
end
|
.get_sound_file_info(file_path) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/utils.rb', line 23
def self.get_sound_file_info file_path
info = nil
RubyAudio::Sound.open(file_path) do |snd|
info = snd.info
end
info
end
|
.stereo_to_mono(file_path) ⇒ Object
2
3
4
5
6
7
8
9
10
|
# File 'lib/utils.rb', line 2
def self.stereo_to_mono file_path
buffer = []
RubyAudio::Sound.open(file_path) do |snd|
snd.read(:float, snd.info.frames).each do |sample|
buffer.push(sample[0])
end
end
buffer
end
|