Class: Celt::Encoder
- Inherits:
-
Object
- Object
- Celt::Encoder
- Defined in:
- lib/celt-ruby/encoder.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#frame_size ⇒ Object
readonly
Returns the value of attribute frame_size.
-
#prediction_request ⇒ Object
Returns the value of attribute prediction_request.
-
#sample_rate ⇒ Object
readonly
Returns the value of attribute sample_rate.
-
#vbr_rate ⇒ Object
Returns the value of attribute vbr_rate.
Instance Method Summary collapse
- #bitstream_version ⇒ Object
- #destroy ⇒ Object
- #encode(data, size) ⇒ Object
-
#initialize(sample_rate, frame_size, channels) ⇒ Encoder
constructor
A new instance of Encoder.
Constructor Details
#initialize(sample_rate, frame_size, channels) ⇒ Encoder
Returns a new instance of Encoder.
6 7 8 9 10 11 12 13 |
# File 'lib/celt-ruby/encoder.rb', line 6 def initialize(sample_rate, frame_size, channels) @sample_rate = sample_rate @frame_size = frame_size @channels = channels @mode = Celt.celt_mode_create sample_rate, frame_size, nil @encoder = Celt.celt_encoder_create @mode, channels, nil end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
3 4 5 |
# File 'lib/celt-ruby/encoder.rb', line 3 def channels @channels end |
#frame_size ⇒ Object (readonly)
Returns the value of attribute frame_size.
3 4 5 |
# File 'lib/celt-ruby/encoder.rb', line 3 def frame_size @frame_size end |
#prediction_request ⇒ Object
Returns the value of attribute prediction_request.
3 4 5 |
# File 'lib/celt-ruby/encoder.rb', line 3 def prediction_request @prediction_request end |
#sample_rate ⇒ Object (readonly)
Returns the value of attribute sample_rate.
3 4 5 |
# File 'lib/celt-ruby/encoder.rb', line 3 def sample_rate @sample_rate end |
#vbr_rate ⇒ Object
Returns the value of attribute vbr_rate.
3 4 5 |
# File 'lib/celt-ruby/encoder.rb', line 3 def vbr_rate @vbr_rate end |
Instance Method Details
#bitstream_version ⇒ Object
20 21 22 23 24 |
# File 'lib/celt-ruby/encoder.rb', line 20 def bitstream_version bv = FFI::MemoryPointer.new :int32 Celt.celt_mode_info @mode, Celt::Constants::CELT_GET_BITSTREAM_VERSION, bv bv.read_int32 end |
#destroy ⇒ Object
15 16 17 18 |
# File 'lib/celt-ruby/encoder.rb', line 15 def destroy Celt.celt_encoder_destroy @encoder Celt.celt_mode_destroy @mode end |
#encode(data, size) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/celt-ruby/encoder.rb', line 40 def encode(data, size) out = FFI::MemoryPointer.new :char, data.size + 1 buf = FFI::MemoryPointer.new :char, data.size + 1 buf.put_string 0, data len = Celt.celt_encode @encoder, buf, nil, out, size out.read_string_length len end |