lame 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +3 -4
  3. data/README.md +51 -17
  4. data/lib/lame.rb +1 -0
  5. data/lib/lame/buffer.rb +1 -1
  6. data/lib/lame/encoder.rb +10 -11
  7. data/lib/lame/encoding/long_buffer_encoder.rb +1 -1
  8. data/lib/lame/encoding/stereo_buffer_encoder.rb +1 -0
  9. data/lib/lame/ffi.rb +2 -0
  10. data/lib/lame/version.rb +1 -1
  11. data/spec/buffer_spec.rb +8 -8
  12. data/spec/configuration_spec.rb +76 -76
  13. data/spec/decoder_spec.rb +34 -34
  14. data/spec/decoding/decoded_frame_spec.rb +7 -7
  15. data/spec/decoding/id3_tag_parser_spec.rb +3 -3
  16. data/spec/decoding/mp3_data_header_parser_spec.rb +21 -21
  17. data/spec/decoding/mpeg_audio_frame_finder_spec.rb +15 -15
  18. data/spec/decoding/mpeg_audio_frame_matcher_spec.rb +2 -2
  19. data/spec/decoding/single_frame_decoder_spec.rb +36 -35
  20. data/spec/decoding/stream_decoder_spec.rb +10 -10
  21. data/spec/delegation_spec.rb +37 -37
  22. data/spec/encoder_spec.rb +100 -100
  23. data/spec/encoding/flusher_spec.rb +16 -16
  24. data/spec/encoding/id3_spec.rb +38 -38
  25. data/spec/encoding/interleaved_buffer_encoder_spec.rb +25 -25
  26. data/spec/encoding/stereo_buffer_encoder_spec.rb +34 -33
  27. data/spec/encoding/vbr_info_spec.rb +16 -16
  28. data/spec/ffi/decode_flags_spec.rb +3 -2
  29. data/spec/ffi/encoding_spec.rb +22 -22
  30. data/spec/ffi/global_flags_spec.rb +159 -157
  31. data/spec/ffi/id3tag_spec.rb +24 -24
  32. data/spec/ffi/mp3_data_spec.rb +3 -3
  33. data/spec/integration/encoding_spec.rb +75 -3
  34. data/spec/integration/id3_tags_spec.rb +18 -18
  35. data/spec/lib/custom_matchers.rb +4 -4
  36. data/spec/lib/wave_file_generator.rb +9 -9
  37. data/spec/spec_helper.rb +0 -1
  38. metadata +38 -60
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f9c8a30dc79a2724fb0a6361ee9d3e7d04524a8
4
+ data.tar.gz: 9a104153f78a75fcf6dbece38724d53a6f4b70c5
5
+ SHA512:
6
+ metadata.gz: 3dc02e4a9f569481f0c5d071150f882f284f5509a341ccd797431318034061b2a54a56da0de88a36e4a770d37c7ac6af90bbbaca0ccf14d31948654e58473db5
7
+ data.tar.gz: 2fa5a1aa873a10ec03538953260a0dde515b32dde49d464022d097d28ba7f480541923efff32d50fc551bfbe5aba530a52658f86b926fc92e5afb7748c0a8c8f
@@ -1,13 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.0
4
+ - 2.1.5
3
5
  - 2.0.0
4
6
  - 1.9.3
5
- - 1.8.7
6
- - rbx-18mode
7
- - rbx-19mode
7
+ - rbx-2.2.7
8
8
  - ruby-head
9
9
  - jruby-19mode
10
- - jruby-18mode
11
10
  - jruby-head
12
11
  before_install:
13
12
  - sudo apt-get install -qq libmp3lame-dev
data/README.md CHANGED
@@ -1,13 +1,17 @@
1
1
  # LAME
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/lame.png)](http://badge.fury.io/rb/lame)
3
4
  [![Build Status](https://travis-ci.org/rdvdijk/lame.png?branch=master)](https://travis-ci.org/rdvdijk/lame)
4
5
  [![Code Climate](https://codeclimate.com/github/rdvdijk/lame.png)](https://codeclimate.com/github/rdvdijk/lame)
5
6
  [![Coverage Status](https://coveralls.io/repos/rdvdijk/lame/badge.png?branch=master)](https://coveralls.io/r/rdvdijk/lame)
7
+ [![Dependency Status](https://gemnasium.com/rdvdijk/lame.png)](https://gemnasium.com/rdvdijk/lame)
6
8
 
7
9
  FFI powered library for the [LAME MP3 encoder](http://lame.sourceforge.net/).
8
10
 
9
11
  ## Installation
10
12
 
13
+ ### Installing the gem
14
+
11
15
  Add this line to your application's Gemfile:
12
16
 
13
17
  gem 'lame'
@@ -20,6 +24,16 @@ Or install it yourself as:
20
24
 
21
25
  $ gem install lame
22
26
 
27
+ ### Installing LAME
28
+
29
+ To use this gem, you need to have the LAME development library (`libmp3lame-dev`) installed.
30
+
31
+ Ubuntu/Debian: `sudo apt-get install libmp3lame-dev`
32
+
33
+ Mac OS X with Homebrew: `brew install lame`
34
+
35
+ Or build it from source, visit the [LAME website](http://lame.sourceforge.net/).
36
+
23
37
  ## Usage
24
38
 
25
39
  Create a default `LAME::Encoder` with default settings:
@@ -54,27 +68,28 @@ See all encoding methods in the Encoding section below.
54
68
 
55
69
  ### Configuration
56
70
 
57
- (work in progress)
71
+ Here are all the encoding configuration options. The values use here are the
72
+ defaults. You can set any option prior to encoding.
58
73
 
59
74
  ```ruby
60
- # These are the defaults:
61
75
  encoder.configure do |config|
76
+ config.bitrate = 128
77
+ config.quality = 3
78
+ config.mode = :join_stereo
79
+
62
80
  config.number_of_samples = 4294967295
63
- config.input_samplerate = 44100
64
81
  config.number_of_channels = 2
82
+ config.input_samplerate = 44100
83
+ config.output_samplerate = 44100
65
84
  config.scale = 0.95
66
85
  config.scale_left = 1.0
67
86
  config.scale_left = 1.0
68
- config.output_samplerate = 44100
69
87
  config.analysis = false
70
88
  config.decode_only = false
71
- config.quality = 3
72
- config.mode = :join_stereo
73
89
  config.force_mid_side = false
74
90
  config.free_format = false
75
91
  config.replay_gain = false
76
92
  config.decode_on_the_fly = false
77
- config.bitrate = 128
78
93
  config.preset = :EXTREME # no LAME default
79
94
  config.copyright = false
80
95
  config.original = true
@@ -89,11 +104,11 @@ encoder.configure do |config|
89
104
  config.emphasis = false
90
105
 
91
106
  # auto-detected by default
92
- config.asm_optimization.mmx = true
93
- config.asm_optimization.amd3now = true
94
- config.asm_optimization.sse = true
107
+ config.asm_optimization.mmx = true
108
+ config.asm_optimization.amd_3dnow = true
109
+ config.asm_optimization.sse = true
95
110
 
96
- # these values can't be "unset" once set to true
111
+ # these options can't be "unset" once set to true
97
112
  config.id3.v2 = false
98
113
  config.id3.v1_only = false
99
114
  config.id3.v2_only = false
@@ -101,6 +116,15 @@ encoder.configure do |config|
101
116
  config.id3.v2_padding = false
102
117
  config.id3.v2_padding_size = 128
103
118
 
119
+ config.id3.write_automatic = true
120
+ config.id3.title = nil
121
+ config.id3.artist = nil
122
+ config.id3.album = nil
123
+ config.id3.year = nil
124
+ config.id3.comment = nil
125
+ config.id3.track = nil
126
+ config.id3.genre = nil
127
+
104
128
  config.quantization.reservoir = true
105
129
  config.quantization.comp = 9
106
130
  config.quantization.comp_short = 9
@@ -136,8 +160,8 @@ end
136
160
 
137
161
  ### Encoding
138
162
 
139
- See `spec/integration/encoding_spec.rb` for an example how to encode a WAV file
140
- to an MP3 file.
163
+ See [`encoding_spec.rb`](spec/integration/encoding_spec.rb) for examples how
164
+ to encode a WAV file to an MP3 file.
141
165
 
142
166
  The available encoding functions are:
143
167
 
@@ -174,13 +198,23 @@ The `left` and `right` are arrays of sample values for the given data type.
174
198
 
175
199
  ### Decoding
176
200
 
177
- See `spec/integration/decoding_spec.rb` for an example how to decode an MP3 file
178
- to an WAV file.
201
+ See [`decoding_spec.rb`](spec/integration/decoding_spec.rb) for examples how
202
+ to decode an MP3 file to an WAV file.
179
203
 
180
204
  ### Development
181
205
 
182
206
  This section contains some references used during development of this gem.
183
207
 
208
+ #### Testing
209
+
210
+ Run the unit tests with rspec:
211
+
212
+ $ rspec
213
+
214
+ Run the integration tests by using the `slow` tag:
215
+
216
+ $ rspec -t slow
217
+
184
218
  #### ID3v2 tags
185
219
 
186
220
  To use ID3v2 tags in files, see this post on the `lame-dev` mailing list:
@@ -195,7 +229,7 @@ So:
195
229
  4. Write id3v1 tag at end of file
196
230
  5. Write vbr 'lametag' at start of audio (using the size of the id3v2 tag)
197
231
 
198
- See the example code in `spec/integration/encoding_spec.rb` for an example.
232
+ See the example code in [`encoding_spec.rb`](spec/integration/encoding_spec.rb).
199
233
 
200
234
  #### Decoding
201
235
 
@@ -225,7 +259,7 @@ After this, we are ready to decode MP3 data.
225
259
  5. Handle the decoded audio.
226
260
  6. Now repeat this process (`GOTO 1`) until the end of the MP3 file.
227
261
 
228
- See the example code in `spec/integration/decoding_spec.rb` for an example.
262
+ See the example code in [`decoding_spec.rb`](spec/integration/decoding_spec.rb).
229
263
 
230
264
  ## Contributing
231
265
 
@@ -1,4 +1,5 @@
1
1
  require "ffi"
2
+ require "forwardable"
2
3
  require "lame/version"
3
4
  require "lame/ffi"
4
5
  require "lame/error"
@@ -3,7 +3,7 @@ module LAME
3
3
 
4
4
  def self.create(type, input)
5
5
  buffer = ::FFI::MemoryPointer.new(type, input.size)
6
- buffer.put_array_of_short(0, input)
6
+ buffer.send(:"put_array_of_#{type}", 0, input)
7
7
  buffer
8
8
  end
9
9
 
@@ -1,15 +1,12 @@
1
1
  module LAME
2
2
  class Encoder
3
3
 
4
- STEREO_ENCODERS = {
4
+ BUFFER_ENCODERS = {
5
5
  :short => Encoding::ShortBufferEncoder,
6
6
  :float => Encoding::FloatBufferEncoder,
7
- :long => Encoding::LongBufferEncoder
8
- }
9
-
10
- INTERLEAVED_ENCODERS = {
11
- :short => Encoding::InterleavedShortBufferEncoder,
12
- :float => Encoding::InterleavedFloatBufferEncoder
7
+ :long => Encoding::LongBufferEncoder,
8
+ :short_interleaved => Encoding::InterleavedShortBufferEncoder,
9
+ :float_interleaved => Encoding::InterleavedFloatBufferEncoder
13
10
  }
14
11
 
15
12
  attr_reader :global_flags
@@ -36,11 +33,11 @@ module LAME
36
33
  end
37
34
 
38
35
  def encode_interleaved_short(samples, &block)
39
- encode_interleaved(samples, :short, &block)
36
+ encode_interleaved(samples, :short_interleaved, &block)
40
37
  end
41
38
 
42
39
  def encode_interleaved_float(samples, &block)
43
- encode_interleaved(samples, :float, &block)
40
+ encode_interleaved(samples, :float_interleaved, &block)
44
41
  end
45
42
 
46
43
  def flush(&block)
@@ -81,7 +78,8 @@ module LAME
81
78
  apply_configuration
82
79
 
83
80
  each_frame(left, right) do |left_frame, right_frame|
84
- mp3_data = STEREO_ENCODERS[data_type].new(configuration).encode_frame(left_frame, right_frame)
81
+ encoder = BUFFER_ENCODERS[data_type].new(configuration)
82
+ mp3_data = encoder.encode_frame(left_frame, right_frame)
85
83
  yield mp3_data
86
84
  end
87
85
  end
@@ -90,7 +88,8 @@ module LAME
90
88
  apply_configuration
91
89
 
92
90
  each_interleaved_frame(interleaved_samples) do |interleaved_frame|
93
- mp3_data = INTERLEAVED_ENCODERS[data_type].new(configuration).encode_frame(interleaved_frame)
91
+ encoder = BUFFER_ENCODERS[data_type].new(configuration)
92
+ mp3_data = encoder.encode_frame(interleaved_frame)
94
93
  yield mp3_data
95
94
  end
96
95
  end
@@ -3,7 +3,7 @@ module LAME
3
3
  class LongBufferEncoder < StereoBufferEncoder
4
4
 
5
5
  def data_type
6
- :long
6
+ :"int#{::LAME::FFI::LONG_SIZE}"
7
7
  end
8
8
 
9
9
  def lame_function
@@ -14,6 +14,7 @@ module LAME
14
14
  def encode_frame(left, right)
15
15
  left_buffer = Buffer.create(data_type, left)
16
16
  right_buffer = Buffer.create(data_type, right)
17
+
17
18
  output = Buffer.create_empty(:uchar, output_buffer_size)
18
19
 
19
20
  mp3_size = LAME.send(lame_function, global_flags,
@@ -9,6 +9,8 @@ require 'lame/ffi/mp3_data'
9
9
  module LAME
10
10
  module FFI
11
11
 
12
+ LONG_SIZE = ::FFI.type_size(:long) * 8
13
+
12
14
  def self.included(base)
13
15
  base.class_eval do
14
16
  include Enums
@@ -1,3 +1,3 @@
1
1
  module LAME
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -7,19 +7,19 @@ module LAME
7
7
  input = [-42, 0, 42]
8
8
  buffer = Buffer.create(:short, input)
9
9
 
10
- buffer.should be_a(::FFI::MemoryPointer)
11
- buffer.size.should eql 6 # shorts are two bytes
12
- buffer.type_size.should eql 2
13
- buffer.get_array_of_short(0, 3).should eql [-42, 0, 42]
10
+ expect(buffer).to be_a(::FFI::MemoryPointer)
11
+ expect(buffer.size).to eql 6 # shorts are two bytes
12
+ expect(buffer.type_size).to eql 2
13
+ expect(buffer.get_array_of_short(0, 3)).to eql [-42, 0, 42]
14
14
  end
15
15
 
16
16
  it "creates an empty buffer" do
17
17
  buffer = Buffer.create_empty(:uchar, 100)
18
18
 
19
- buffer.should be_a(::FFI::MemoryPointer)
20
- buffer.size.should eql 100
21
- buffer.type_size.should eql 1
22
- buffer.get_array_of_uchar(0, 100).should eql [0]*100
19
+ expect(buffer).to be_a(::FFI::MemoryPointer)
20
+ expect(buffer.size).to eql 100
21
+ expect(buffer.type_size).to eql 1
22
+ expect(buffer.get_array_of_uchar(0, 100)).to eql [0]*100
23
23
  end
24
24
 
25
25
  end
@@ -4,84 +4,84 @@ module LAME
4
4
  describe Configuration do
5
5
 
6
6
  context "intialization" do
7
- let(:global_flags) { stub }
7
+ let(:global_flags) { double("global_flags") }
8
8
 
9
9
  subject(:configuration) { Configuration.new(global_flags) }
10
10
 
11
11
  it "initializes with global flags" do
12
- configuration.global_flags.should eql global_flags
12
+ expect(configuration.global_flags).to eql global_flags
13
13
  end
14
14
 
15
15
  it "initializes a AsmOptimization configuration object" do
16
- Configuration::AsmOptimization.should_receive(:new).with(global_flags)
16
+ expect(Configuration::AsmOptimization).to receive(:new).with(global_flags)
17
17
  configuration.asm_optimization
18
18
  end
19
19
 
20
20
  it "memoizes one AsmOptimization configuration object" do
21
- Configuration::AsmOptimization.stub(:new).and_return(stub)
22
- Configuration::AsmOptimization.should_receive(:new).exactly(:once)
21
+ allow(Configuration::AsmOptimization).to receive(:new).and_return(double)
22
+ expect(Configuration::AsmOptimization).to receive(:new).exactly(:once)
23
23
  2.times { configuration.asm_optimization }
24
24
  end
25
25
 
26
26
  it "initializes a Id3 configuration object" do
27
- Configuration::Id3.should_receive(:new).with(global_flags)
27
+ expect(Configuration::Id3).to receive(:new).with(global_flags)
28
28
  configuration.id3
29
29
  end
30
30
 
31
31
  it "memoizes one Id3 configuration object" do
32
- Configuration::Id3.stub(:new).and_return(stub)
33
- Configuration::Id3.should_receive(:new).exactly(:once)
32
+ allow(Configuration::Id3).to receive(:new).and_return(double)
33
+ expect(Configuration::Id3).to receive(:new).exactly(:once)
34
34
  2.times { configuration.id3 }
35
35
  end
36
36
 
37
37
  it "initializes a Quantization configuration object" do
38
- Configuration::Quantization.should_receive(:new).with(global_flags)
38
+ expect(Configuration::Quantization).to receive(:new).with(global_flags)
39
39
  configuration.quantization
40
40
  end
41
41
 
42
42
  it "memoizes one Quantization configuration object" do
43
- Configuration::Quantization.stub(:new).and_return(stub)
44
- Configuration::Quantization.should_receive(:new).exactly(:once)
43
+ allow(Configuration::Quantization).to receive(:new).and_return(double)
44
+ expect(Configuration::Quantization).to receive(:new).exactly(:once)
45
45
  2.times { configuration.quantization }
46
46
  end
47
47
 
48
48
  it "initializes a VBR configuration object" do
49
- Configuration::VBR.should_receive(:new).with(global_flags)
49
+ expect(Configuration::VBR).to receive(:new).with(global_flags)
50
50
  configuration.vbr
51
51
  end
52
52
 
53
53
  it "memoizes one VBR configuration object" do
54
- Configuration::VBR.stub(:new).and_return(stub)
55
- Configuration::VBR.should_receive(:new).exactly(:once)
54
+ allow(Configuration::VBR).to receive(:new).and_return(double)
55
+ expect(Configuration::VBR).to receive(:new).exactly(:once)
56
56
  2.times { configuration.vbr }
57
57
  end
58
58
 
59
59
  it "initializes a Filtering configuration object" do
60
- Configuration::Filtering.should_receive(:new).with(global_flags)
60
+ expect(Configuration::Filtering).to receive(:new).with(global_flags)
61
61
  configuration.filtering
62
62
  end
63
63
 
64
64
  it "memoizes one Filtering configuration object" do
65
- Configuration::Filtering.stub(:new).and_return(stub)
66
- Configuration::Filtering.should_receive(:new).exactly(:once)
65
+ allow(Configuration::Filtering).to receive(:new).and_return(double)
66
+ expect(Configuration::Filtering).to receive(:new).exactly(:once)
67
67
  2.times { configuration.filtering }
68
68
  end
69
69
 
70
70
  it "initializes a PsychoAcoustics configuration object" do
71
- Configuration::PsychoAcoustics.should_receive(:new).with(global_flags)
71
+ expect(Configuration::PsychoAcoustics).to receive(:new).with(global_flags)
72
72
  configuration.psycho_acoustics
73
73
  end
74
74
 
75
75
  it "memoizes one PsychoAcoustics configuration object" do
76
- Configuration::PsychoAcoustics.stub(:new).and_return(stub)
77
- Configuration::PsychoAcoustics.should_receive(:new).exactly(:once)
76
+ allow(Configuration::PsychoAcoustics).to receive(:new).and_return(double)
77
+ expect(Configuration::PsychoAcoustics).to receive(:new).exactly(:once)
78
78
  2.times { configuration.psycho_acoustics }
79
79
  end
80
80
 
81
81
  context "Id3" do
82
82
 
83
83
  it "initializes the Id3 tag" do
84
- LAME.should_receive(:id3tag_init).with(global_flags)
84
+ expect(LAME).to receive(:id3tag_init).with(global_flags)
85
85
  Configuration::Id3.new(global_flags)
86
86
  end
87
87
 
@@ -89,17 +89,17 @@ module LAME
89
89
 
90
90
  describe "#apply! / #applied?" do
91
91
  it "is not applied by default" do
92
- configuration.should_not be_applied
92
+ expect(configuration).not_to be_applied
93
93
  end
94
94
 
95
95
  it "applies the configuration" do
96
- LAME.should_receive(:lame_init_params).with(global_flags)
96
+ expect(LAME).to receive(:lame_init_params).with(global_flags)
97
97
  configuration.apply!
98
- configuration.should be_applied
98
+ expect(configuration).to be_applied
99
99
  end
100
100
 
101
101
  it "raises an error if configuration could not be applied" do
102
- LAME.stub(:lame_init_params).and_return(-1)
102
+ allow(LAME).to receive(:lame_init_params).and_return(-1)
103
103
  expect {
104
104
  configuration.apply!
105
105
  }.to raise_error(ConfigurationError)
@@ -109,12 +109,12 @@ module LAME
109
109
  describe "#framesize" do
110
110
 
111
111
  it "gets framesize from LAME if configuration was applied" do
112
- LAME.stub(:lame_init_params)
112
+ allow(LAME).to receive(:lame_init_params)
113
113
  configuration.apply!
114
114
 
115
- LAME.stub(:lame_get_framesize).and_return(42)
116
- LAME.should_receive(:lame_get_framesize).with(global_flags)
117
- configuration.framesize.should eql 42
115
+ allow(LAME).to receive(:lame_get_framesize).and_return(42)
116
+ expect(LAME).to receive(:lame_get_framesize).with(global_flags)
117
+ expect(configuration.framesize).to eql 42
118
118
  end
119
119
 
120
120
  it "raises an error if configuration was not applied" do
@@ -124,12 +124,12 @@ module LAME
124
124
  end
125
125
 
126
126
  it "calculates the output buffer size based on the framesize" do
127
- LAME.stub(:lame_init_params)
127
+ allow(LAME).to receive(:lame_init_params)
128
128
  configuration.apply!
129
129
 
130
- LAME.stub(:lame_get_framesize).and_return(1152)
131
- LAME.should_receive(:lame_get_framesize).with(global_flags)
132
- configuration.output_buffer_size.should eql 8640
130
+ allow(LAME).to receive(:lame_get_framesize).and_return(1152)
131
+ expect(LAME).to receive(:lame_get_framesize).with(global_flags)
132
+ expect(configuration.output_buffer_size).to eql 8640
133
133
  end
134
134
 
135
135
  end
@@ -148,7 +148,7 @@ module LAME
148
148
  #
149
149
  context "set/get delegation" do
150
150
 
151
- let(:global_flags) { stub(GlobalFlags) }
151
+ let(:global_flags) { double(GlobalFlags) }
152
152
  subject(:configuration) { Configuration.new(global_flags) }
153
153
 
154
154
  context "basic fields" do
@@ -183,8 +183,8 @@ module LAME
183
183
  it { should delegate(:emphasis) }
184
184
 
185
185
  it "delegates #preset= to LAME.lame_set_preset" do
186
- LAME.should_receive(:lame_set_preset).with(global_flags, anything)
187
- configuration.preset = stub
186
+ expect(LAME).to receive(:lame_set_preset).with(global_flags, anything)
187
+ configuration.preset = double
188
188
  end
189
189
 
190
190
  end
@@ -193,17 +193,17 @@ module LAME
193
193
  subject(:asm_optimization) { configuration.asm_optimization }
194
194
 
195
195
  it "delegates #mmx to LAME.lame_set_asm_optimizations" do
196
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :MMX, 1)
196
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :MMX, 1)
197
197
  asm_optimization.mmx = true
198
198
  end
199
199
 
200
200
  it "delegates #amd_3dnow to LAME.lame_set_asm_optimizations" do
201
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :AMD_3DNOW, 1)
201
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :AMD_3DNOW, 1)
202
202
  asm_optimization.amd_3dnow = true
203
203
  end
204
204
 
205
205
  it "delegates #sse to LAME.lame_set_asm_optimizations" do
206
- LAME.should_receive(:lame_set_asm_optimizations).with(global_flags, :SSE, 1)
206
+ expect(LAME).to receive(:lame_set_asm_optimizations).with(global_flags, :SSE, 1)
207
207
  asm_optimization.sse = true
208
208
  end
209
209
  end
@@ -215,37 +215,37 @@ module LAME
215
215
  it { should delegate(:write_automatic).to(:write_id3tag_automatic) }
216
216
 
217
217
  before do
218
- LAME.stub(:id3tag_init)
218
+ allow(LAME).to receive(:id3tag_init)
219
219
  end
220
220
 
221
221
  it "delegates #v2= to LAME.id3tag_add_v2" do
222
- LAME.should_receive(:id3tag_add_v2).with(global_flags)
222
+ expect(LAME).to receive(:id3tag_add_v2).with(global_flags)
223
223
  id3.v2 = true
224
224
  end
225
225
 
226
226
  it "delegates #v1_only= to LAME.id3tag_v1_only" do
227
- LAME.should_receive(:id3tag_v1_only).with(global_flags)
227
+ expect(LAME).to receive(:id3tag_v1_only).with(global_flags)
228
228
  id3.v1_only = true
229
229
  end
230
230
 
231
231
  it "delegates #v2_only= to LAME.id3tag_v2_only" do
232
- LAME.should_receive(:id3tag_v2_only).with(global_flags)
232
+ expect(LAME).to receive(:id3tag_v2_only).with(global_flags)
233
233
  id3.v2_only = true
234
234
  end
235
235
 
236
236
  it "delegates #v1_space= to LAME.id3tag_v1_space" do
237
- LAME.should_receive(:id3tag_space_v1).with(global_flags)
237
+ expect(LAME).to receive(:id3tag_space_v1).with(global_flags)
238
238
  id3.v1_space = true
239
239
  end
240
240
 
241
241
  it "delegates #v2_padding= to LAME.id3tag_pad_v2" do
242
- LAME.should_receive(:id3tag_pad_v2).with(global_flags)
242
+ expect(LAME).to receive(:id3tag_pad_v2).with(global_flags)
243
243
  id3.v2_padding = true
244
244
  end
245
245
 
246
246
  it "delegates #v2_padding_size= to LAME.id3tag_set_pad" do
247
- value = stub
248
- LAME.should_receive(:id3tag_set_pad).with(global_flags, value)
247
+ value = double
248
+ expect(LAME).to receive(:id3tag_set_pad).with(global_flags, value)
249
249
  id3.v2_padding_size = value
250
250
  end
251
251
 
@@ -253,10 +253,10 @@ module LAME
253
253
  [ :title, :artist, :album, :year, :comment ].each do |field|
254
254
 
255
255
  it "sets the #{field} with string buffer" do
256
- LAME.should_receive(:"id3tag_set_#{field}") do |flags, string_buffer|
257
- flags.should eql global_flags
258
- string_buffer.should be_a(::FFI::MemoryPointer)
259
- string_buffer.get_string(0).should eql "Some #{field}"
256
+ expect(LAME).to receive(:"id3tag_set_#{field}") do |flags, string_buffer|
257
+ expect(flags).to eql global_flags
258
+ expect(string_buffer).to be_a(::FFI::MemoryPointer)
259
+ expect(string_buffer.get_string(0)).to eql "Some #{field}"
260
260
  end
261
261
  id3.send(:"#{field}=", "Some #{field}")
262
262
  end
@@ -264,37 +264,37 @@ module LAME
264
264
  end
265
265
 
266
266
  it "sets the track" do
267
- LAME.should_receive(:"id3tag_set_track") do |flags, value|
268
- flags.should eql global_flags
269
- value.should eql 42
267
+ expect(LAME).to receive(:"id3tag_set_track") do |flags, value|
268
+ expect(flags).to eql global_flags
269
+ expect(value).to eql 42
270
270
  end
271
271
  id3.track = 42
272
272
  end
273
273
 
274
274
  it "sets the genre by name" do
275
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
276
- flags.should eql global_flags
277
- value.should be_a(::FFI::MemoryPointer)
278
- value.get_string(0).should eql "147"
275
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
276
+ expect(flags).to eql global_flags
277
+ expect(value).to be_a(::FFI::MemoryPointer)
278
+ expect(value.get_string(0)).to eql "147"
279
279
  end
280
280
  id3.genre = "SynthPop"
281
281
  end
282
282
 
283
283
  it "sets the genre by id" do
284
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
285
- flags.should eql global_flags
286
- value.should be_a(::FFI::MemoryPointer)
287
- value.get_string(0).should eql "81"
284
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
285
+ expect(flags).to eql global_flags
286
+ expect(value).to be_a(::FFI::MemoryPointer)
287
+ expect(value.get_string(0)).to eql "81"
288
288
  end
289
289
 
290
290
  id3.genre = 81
291
291
  end
292
292
 
293
293
  it "sets non-standard genre name" do
294
- LAME.should_receive(:id3tag_set_genre) do |flags, value|
295
- flags.should eql global_flags
296
- value.should be_a(::FFI::MemoryPointer)
297
- value.get_string(0).should eql "Ruby FFI Rock"
294
+ expect(LAME).to receive(:id3tag_set_genre) do |flags, value|
295
+ expect(flags).to eql global_flags
296
+ expect(value).to be_a(::FFI::MemoryPointer)
297
+ expect(value.get_string(0)).to eql "Ruby FFI Rock"
298
298
  end
299
299
  id3.genre = "Ruby FFI Rock"
300
300
  end
@@ -312,23 +312,23 @@ module LAME
312
312
  it { should delegate(:msfix) }
313
313
 
314
314
  it "delegates #reservoir= to LAME.lame_set_disable_reservoir" do
315
- LAME.should_receive(:lame_set_disable_reservoir).with(global_flags, 1)
315
+ expect(LAME).to receive(:lame_set_disable_reservoir).with(global_flags, 1)
316
316
  quantization.reservoir = false
317
317
  end
318
318
 
319
319
  it "delegates #reservoir to LAME.lame_get_disable_reservoir" do
320
- LAME.should_receive(:lame_get_disable_reservoir).with(global_flags)
320
+ expect(LAME).to receive(:lame_get_disable_reservoir).with(global_flags)
321
321
  quantization.reservoir
322
322
  end
323
323
 
324
324
  it "delegates #reservoir? to LAME.lame_get_disable_reservoir" do
325
- LAME.should_receive(:lame_get_disable_reservoir).with(global_flags)
325
+ expect(LAME).to receive(:lame_get_disable_reservoir).with(global_flags)
326
326
  quantization.reservoir?
327
327
  end
328
328
 
329
329
  it "converts the return value 0 for #reservoir? to false" do
330
- LAME.stub(:lame_get_disable_reservoir).and_return(0)
331
- quantization.reservoir?.should be_false
330
+ allow(LAME).to receive(:lame_get_disable_reservoir).and_return(0)
331
+ expect(quantization.reservoir?).to be_falsy
332
332
  end
333
333
  end
334
334
 
@@ -365,23 +365,23 @@ module LAME
365
365
  it { should delegate(:athaa_sensitivity) }
366
366
 
367
367
  it "delegates #ath= to LAME.lame_set_noATH" do
368
- LAME.should_receive(:lame_set_noATH).with(global_flags, 1)
368
+ expect(LAME).to receive(:lame_set_noATH).with(global_flags, 1)
369
369
  psycho_acoustics.ath = false
370
370
  end
371
371
 
372
372
  it "delegates #ath to LAME.lame_get_noATH" do
373
- LAME.should_receive(:lame_get_noATH).with(global_flags)
373
+ expect(LAME).to receive(:lame_get_noATH).with(global_flags)
374
374
  psycho_acoustics.ath
375
375
  end
376
376
 
377
377
  it "delegates #ath? to LAME.lame_get_noATH" do
378
- LAME.should_receive(:lame_get_noATH).with(global_flags)
378
+ expect(LAME).to receive(:lame_get_noATH).with(global_flags)
379
379
  psycho_acoustics.ath?
380
380
  end
381
381
 
382
382
  it "converts the return value 0 for #ath? to true" do
383
- LAME.stub(:lame_get_noATH).and_return(0)
384
- psycho_acoustics.ath?.should be_true
383
+ allow(LAME).to receive(:lame_get_noATH).and_return(0)
384
+ expect(psycho_acoustics.ath?).to be_truthy
385
385
  end
386
386
  end
387
387