Module: Libsamplerate::FFI

Extended by:
FFI::Library
Defined in:
lib/libsamplerate/ffi.rb

Defined Under Namespace

Classes: SRCCBDATA, SRCDATA, SRCSTATETag

Class Method Summary collapse

Class Method Details

._callback_src_callback_t_(cb_data, data) ⇒ FFI::Pointer(*Void)

User supplied callback function type for use with src_callback_new() and src_callback_read(). First parameter is the same pointer that was passed into src_callback_new(). Second parameter is pointer to a pointer. The user supplied callback function must modify *data to point to the start of the user supplied float array. The user supplied function must return the number of frames that **data points to.

This entry is only for documentation and no real method.

Parameters:

  • cb_data (FFI::Pointer(*Void))
  • data (FFI::Pointer(**Float))

Returns:

  • (FFI::Pointer(*Void))


76
# File 'lib/libsamplerate/ffi.rb', line 76

callback :src_callback_t, [:pointer, :pointer], :pointer

.attach_function(name, *_) ⇒ Object



9
10
11
12
13
# File 'lib/libsamplerate/ffi.rb', line 9

def self.attach_function(name, *_)
  begin; super; rescue FFI::NotFoundError => e
    (class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
  end
end

.src_callback_new(func, converter_type, channels, error, cb_data) ⇒ SRCSTATETag

Initilisation for callback based API : return an anonymous pointer to the internal state of the converter. Choose a converter from the enums below. The cb_data pointer can point to any data or be set to NULL. Whatever the value, when processing, user supplied function “func” gets called with cb_data as first parameter.

Parameters:

  • func (Proc(_callback_src_callback_t_))
  • converter_type (Integer)
  • channels (Integer)
  • error (FFI::Pointer(*Int))
  • cb_data (FFI::Pointer(*Void))

Returns:



104
# File 'lib/libsamplerate/ffi.rb', line 104

attach_function :src_callback_new, :src_callback_new, [:src_callback_t, :int, :int, :pointer, :pointer], SRCSTATETag

.src_callback_read(state, src_ratio, frames, data) ⇒ Integer

Callback based processing function. Read up to frames worth of data from the converter int *data and return frames read or -1 on error.

Parameters:

  • state (SRCSTATETag)
  • src_ratio (Float)
  • frames (Integer)
  • data (FFI::Pointer(*Float))

Returns:

  • (Integer)


135
# File 'lib/libsamplerate/ffi.rb', line 135

attach_function :src_callback_read, :src_callback_read, [SRCSTATETag, :double, :long, :pointer], :long

.src_delete(state) ⇒ SRCSTATETag

Cleanup all internal allocations. Always returns NULL.

Parameters:

Returns:



113
# File 'lib/libsamplerate/ffi.rb', line 113

attach_function :src_delete, :src_delete, [SRCSTATETag], SRCSTATETag

.src_error(state) ⇒ Integer

Return an error number.

Parameters:

Returns:

  • (Integer)


215
# File 'lib/libsamplerate/ffi.rb', line 215

attach_function :src_error, :src_error, [SRCSTATETag], :int

.src_float_to_int_array(in_, out, len) ⇒ nil

(Not documented)

Parameters:

  • in_ (FFI::Pointer(*Float))
  • out (FFI::Pointer(*Int))
  • len (Integer)

Returns:

  • (nil)


264
# File 'lib/libsamplerate/ffi.rb', line 264

attach_function :src_float_to_int_array, :src_float_to_int_array, [:pointer, :pointer, :int], :void

.src_float_to_short_array(in_, out, len) ⇒ nil

(Not documented)

Parameters:

  • in_ (FFI::Pointer(*Float))
  • out (FFI::Pointer(*Short))
  • len (Integer)

Returns:

  • (nil)


244
# File 'lib/libsamplerate/ffi.rb', line 244

attach_function :src_float_to_short_array, :src_float_to_short_array, [:pointer, :pointer, :int], :void

.src_get_description(converter_type) ⇒ String

(Not documented)

Parameters:

  • converter_type (Integer)

Returns:

  • (String)


169
# File 'lib/libsamplerate/ffi.rb', line 169

attach_function :src_get_description, :src_get_description, [:int], :string

.src_get_name(converter_type) ⇒ String

This library contains a number of different sample rate converters, numbered 0 through N.

Return a string giving either a name or a more full description of each sample rate converter or NULL if no sample rate converter exists for the given value. The converters are sequentially numbered from 0 to N.

Parameters:

  • converter_type (Integer)

Returns:

  • (String)


161
# File 'lib/libsamplerate/ffi.rb', line 161

attach_function :src_get_name, :src_get_name, [:int], :string

.src_get_versionString

(Not documented)

Returns:

  • (String)


176
# File 'lib/libsamplerate/ffi.rb', line 176

attach_function :src_get_version, :src_get_version, [], :string

.src_int_to_float_array(in_, out, len) ⇒ nil

(Not documented)

Parameters:

  • in_ (FFI::Pointer(*Int))
  • out (FFI::Pointer(*Float))
  • len (Integer)

Returns:

  • (nil)


254
# File 'lib/libsamplerate/ffi.rb', line 254

attach_function :src_int_to_float_array, :src_int_to_float_array, [:pointer, :pointer, :int], :void

.src_is_valid_ratio(ratio) ⇒ Integer

Return TRUE if ratio is a valid conversion ratio, FALSE otherwise.

Parameters:

  • ratio (Float)

Returns:

  • (Integer)


207
# File 'lib/libsamplerate/ffi.rb', line 207

attach_function :src_is_valid_ratio, :src_is_valid_ratio, [:double], :int

.src_new(converter_type, channels, error) ⇒ SRCSTATETag

Standard initialisation function : return an anonymous pointer to the internal state of the converter. Choose a converter from the enums below. Error returned in *error.

Parameters:

  • converter_type (Integer)
  • channels (Integer)
  • error (FFI::Pointer(*Int))

Returns:



88
# File 'lib/libsamplerate/ffi.rb', line 88

attach_function :src_new, :src_new, [:int, :int, :pointer], SRCSTATETag

.src_process(state, data) ⇒ Integer

Standard processing function. Returns non zero on error.

Parameters:

Returns:

  • (Integer)


123
# File 'lib/libsamplerate/ffi.rb', line 123

attach_function :src_process, :src_process, [SRCSTATETag, SRCDATA], :int

.src_reset(state) ⇒ Integer

Reset the internal SRC state. Does not modify the quality settings. Does not free any memory allocations. Returns non zero on error.

Parameters:

Returns:

  • (Integer)


198
# File 'lib/libsamplerate/ffi.rb', line 198

attach_function :src_reset, :src_reset, [SRCSTATETag], :int

.src_set_ratio(state, new_ratio) ⇒ Integer

Set a new SRC ratio. This allows step responses in the conversion ratio. Returns non zero on error.

Parameters:

Returns:

  • (Integer)


187
# File 'lib/libsamplerate/ffi.rb', line 187

attach_function :src_set_ratio, :src_set_ratio, [SRCSTATETag, :double], :int

.src_short_to_float_array(in_, out, len) ⇒ nil

Extra helper functions for converting from short to float and back again.

Parameters:

  • in_ (FFI::Pointer(*Short))
  • out (FFI::Pointer(*Float))
  • len (Integer)

Returns:

  • (nil)


234
# File 'lib/libsamplerate/ffi.rb', line 234

attach_function :src_short_to_float_array, :src_short_to_float_array, [:pointer, :pointer, :int], :void

.src_simple(data, converter_type, channels) ⇒ Integer

Simple interface for performing a single conversion from input buffer to output buffer at a fixed conversion ratio. Simple interface does not require initialisation as it can only operate on a single buffer worth of audio.

Parameters:

  • data (SRCDATA)
  • converter_type (Integer)
  • channels (Integer)

Returns:

  • (Integer)


148
# File 'lib/libsamplerate/ffi.rb', line 148

attach_function :src_simple, :src_simple, [SRCDATA, :int, :int], :int

.src_strerror(error) ⇒ String

Convert the error number into a string.

Parameters:

  • error (Integer)

Returns:

  • (String)


223
# File 'lib/libsamplerate/ffi.rb', line 223

attach_function :src_strerror, :src_strerror, [:int], :string