| Class | Audio::Soundfile |
| In: |
lib/audio/sndfile.rb
|
| Parent: | Object |
require 'audio/sndfile'
Audio::Soundfile.open('chunky_bacon.wav') do |sf|
sound = sf.readf_float(sf.frames)
puts "Maximum amplitude: #{sound.abs.max}"
end
Refer to the libsndfile api.
Usage is quite straightforward: drop the sf_ prefix, omit the SNDFILE* parameter, and use Sound or Numeric instead of (pointer, size) pairs. So, if you have a Soundfile object named sf, then
sf_read_float(SNDFILE, float *ptr, sf_count_t items)
becomes
buf = Sound.float(items) sf.read_float(buf)
or
buf = sf.read_float(items) # creates a new Sound
Exceptions to this pattern are documented below.
Constants are accessed as Soundfile::SF_FORMAT_WAV
| new | -> | open |
| info | [R] | SF_INFO |
| mode | [R] |