opus-ruby 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fca9e603f46d71ec76f1754d72e57f4330d6b891
4
- data.tar.gz: 777e900ed821b7e9df95e1b80d69c6f0fe22bcd9
3
+ metadata.gz: 05a41f5c8b2fa5418aede1cc8206cd6e32c192a6
4
+ data.tar.gz: 0299fc8e0f5097db6ee8d7c0c889c455db813643
5
5
  SHA512:
6
- metadata.gz: 5513a93a70ff8b21125dd6c318409ec48f3fb15cc56d5e3a6f6bdcb237cfcb708eb33797f07c7a632f799f03a8943bda698f7854ba7c2192f2712b625fb28707
7
- data.tar.gz: 3a55dce53e1c7eb09832a9dd4479f137bea576fcef35956768babf2f24ccb2e10c814207e33f21c0bfc0a752ac7e70d0b5f3e9664c43da2c7ac7cd0b452daa1d
6
+ metadata.gz: 27d930f5bfe44ae0eedffe938f33c0ea1cec45a5522b057f06fa7a79b8a084cf75f4db0d8e547af5c1d36acf668ba0d984e1e72518000f9b7e14c07704d71c3b
7
+ data.tar.gz: 90e9cf26bafe6deefeee080653a2c36b416a79d4a8c247448dfcf43aac4f058b6f3e54c04136a0d72f1201e92cd112e811a2e70af2bea596acf04f8d67c16188
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.1.1
@@ -1,6 +1,7 @@
1
1
  require 'ffi'
2
2
  require 'opus-ruby/version'
3
3
  require 'opus-ruby/encoder'
4
+ require 'opus-ruby/decoder'
4
5
 
5
6
  module Opus
6
7
  extend FFI::Library
@@ -0,0 +1,69 @@
1
+ #################################################################################
2
+ # The MIT License (MIT) #
3
+ # #
4
+ # Copyright (c) 2014, Aaron Herting 'qwertos' <aaron@herting.cc> #
5
+ # Heavily based on code (c) GitHub User 'perrym5' and code found in the #
6
+ # libopus public documentation. #
7
+ # #
8
+ # Permission is hereby granted, free of charge, to any person obtaining a copy #
9
+ # of this software and associated documentation files (the "Software"), to deal #
10
+ # in the Software without restriction, including without limitation the rights #
11
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
12
+ # copies of the Software, and to permit persons to whom the Software is #
13
+ # furnished to do so, subject to the following conditions: #
14
+ # #
15
+ # The above copyright notice and this permission notice shall be included in #
16
+ # all copies or substantial portions of the Software. #
17
+ # #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
19
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
20
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
21
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
22
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
23
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN #
24
+ # THE SOFTWARE. #
25
+ #################################################################################
26
+
27
+
28
+
29
+ module Opus
30
+ class Decoder
31
+ attr_reader :sample_rate, :frame_size, :channels
32
+
33
+ def initialize( sample_rate, frame_size, channels )
34
+ @sample_rate = sample_rate
35
+ @frame_size = frame_size
36
+ @channels = channels
37
+
38
+ @decoder = Opus.opus_decoder_create sample_rate, channels, nil
39
+ end
40
+
41
+ def destroy
42
+ Opus.opus_decoder_destroy @decoder
43
+ end
44
+
45
+ def reset
46
+ Opus.opus_decoder_ctl @decoder, Opus::Constants::OPUS_RESET_STATE, :pointer, nil
47
+ end
48
+
49
+ def decode( data )
50
+ len = data.size
51
+
52
+ packet = FFI::MemoryPointer.new :char, len + 1
53
+ packet.put_string 0, data
54
+
55
+ max_size = @frame_size * @channels
56
+
57
+ decoded = FFI::MemoryPointer.new :short, max_size + 1
58
+
59
+ frame_size = Opus.opus_decode @decoder, packet, len, decoded, max_size, 0
60
+
61
+ # The times 2 is very important and caused much grief prior to an IRC
62
+ # chat with the Opus devs. Just remember a short is 2 bytes... Seems so
63
+ # simple now...
64
+ return decoded.read_string_length frame_size * 2
65
+ end
66
+ end
67
+ end
68
+
69
+
@@ -1,3 +1,3 @@
1
1
  module Opus
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opus-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Perry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-23 00:00:00.000000000 Z
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,7 @@ files:
67
67
  - README.md
68
68
  - Rakefile
69
69
  - lib/opus-ruby.rb
70
+ - lib/opus-ruby/decoder.rb
70
71
  - lib/opus-ruby/encoder.rb
71
72
  - lib/opus-ruby/version.rb
72
73
  - opus-ruby.gemspec