Class Audio::Soundfile
In: lib/audio/sndfile.rb
Parent: Object

libsndfile

Synopsis

  require 'audio/sndfile'

  Audio::Soundfile.open('chunky_bacon.wav') do |sf|
    sound = sf.readf_float(sf.frames)
    puts "Maximum amplitude: #{sound.abs.max}"
  end

Details

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

Methods

channels   format   format_check   frames   new   read   samplerate   sections   seekable   write  

External Aliases

new -> open

Attributes

info  [R]  SF_INFO
mode  [R] 

Public Class methods

mode:One of %w{r w rw}
info:Instance of SF_INFO or nil

Public Instance methods

The following are equivalent:

  sf_format_check(info) /* C */
  sf.format_check       # ruby

Automagic read method. Type is autodetected.

Automagic write method. Type is autodetected.

[Validate]