Module: Awaaz::Extensions::Samplerate
- Extended by:
- FFI::Library
- Defined in:
- lib/awaaz/extensions/samplerate.rb
Overview
The Samplerate module provides Ruby bindings to the ‘libsamplerate` C library using the FFI (Foreign Function Interface).
This module enables high-quality audio resampling directly from Ruby.
Defined Under Namespace
Classes: SRC_DATA
Constant Summary collapse
- SRC_SINC_BEST_QUALITY =
Best quality sinc-based sample rate converter.
0- SRC_SINC_MEDIUM_QUALITY =
Medium quality sinc-based converter.
1- SRC_SINC_FASTEST =
Fastest sinc-based converter (lower quality).
2- SRC_ZERO_ORDER_HOLD =
Zero-order hold converter (lowest quality, fastest).
3- SRC_LINEAR =
Linear interpolation converter (low quality, very fast).
4
Class Method Summary collapse
-
.resample_option(option) ⇒ Integer
Maps a symbolic or numeric option to a libsamplerate converter type constant.
Instance Method Summary collapse
-
#src_simple ⇒ Object
Performs a simple sample rate conversion.
-
#src_strerror ⇒ String
Converts an error code to a human-readable error message.
Class Method Details
.resample_option(option) ⇒ Integer
Maps a symbolic or numeric option to a libsamplerate converter type constant.
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/awaaz/extensions/samplerate.rb', line 100 def resample_option(option) case option when 0, :sinc_best_quality then SRC_SINC_BEST_QUALITY when 1, :sinc_medium_quality then SRC_SINC_MEDIUM_QUALITY when 2, :sinc_fastest then SRC_SINC_FASTEST when 3, :zero_order_hold then SRC_ZERO_ORDER_HOLD when 4, :linear then SRC_LINEAR else raise ArgumentError, "Not found" end end |
Instance Method Details
#src_simple ⇒ Object
Performs a simple sample rate conversion.
59 |
# File 'lib/awaaz/extensions/samplerate.rb', line 59 attach_function :src_simple, [SRC_DATA.by_ref, :int, :int], :int |
#src_strerror ⇒ String
Converts an error code to a human-readable error message.
65 |
# File 'lib/awaaz/extensions/samplerate.rb', line 65 attach_function :src_strerror, [:int], :string |