Sha256: 1c6a27e84d36196315a44b88d07752739c3134be2f8e518aaffd638c3c0278cd
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
module Opus class Encoder attr_reader :sample_rate, :frame_size, :channels, :vbr_rate, :bitrate def initialize(sample_rate, frame_size, channels) @sample_rate = sample_rate @frame_size = frame_size @channels = channels @encoder = Opus.opus_encoder_create sample_rate, channels, Constants::OPUS_APPLICATION_AUDIO, nil end def destroy Opus.opus_encoder_destroy @encoder end def reset Opus.opus_encoder_ctl @encoder, Opus::Constants::OPUS_RESET_STATE, :pointer, nil end def vbr_rate=(value) @vbr_rate = value Opus.opus_encoder_ctl @encoder, Opus::Constants::OPUS_SET_VBR_REQUEST, :int32, value end def bitrate=(value) @bitrate = value Opus.opus_encoder_ctl @encoder, Opus::Constants::OPUS_SET_BITRATE_REQUEST, :int32, value end 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 = Opus.opus_encode @encoder, buf, @frame_size, out, size out.read_string_length len end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
opus-ruby-1.0.1 | lib/opus-ruby/encoder.rb |
opus-ruby-1.0.0 | lib/opus-ruby/encoder.rb |
opus-ruby-0.0.1 | lib/opus-ruby/encoder.rb |