lame 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.gitignore +20 -0
  2. data/.rspec +3 -0
  3. data/.rvmrc +1 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +181 -0
  8. data/Rakefile +6 -0
  9. data/docs/id3v2.4.0-structure.txt +731 -0
  10. data/docs/lame-3.99.5.h +1323 -0
  11. data/lame.gemspec +28 -0
  12. data/lib/lame.rb +31 -0
  13. data/lib/lame/buffer.rb +21 -0
  14. data/lib/lame/configuration.rb +228 -0
  15. data/lib/lame/decoder.rb +38 -0
  16. data/lib/lame/decoding/decoded_frame.rb +25 -0
  17. data/lib/lame/decoding/id3_tag_parser.rb +53 -0
  18. data/lib/lame/decoding/mp3_data_header_parser.rb +64 -0
  19. data/lib/lame/decoding/mpeg_audio_frame_finder.rb +46 -0
  20. data/lib/lame/decoding/mpeg_audio_frame_matcher.rb +98 -0
  21. data/lib/lame/decoding/single_frame_decoder.rb +51 -0
  22. data/lib/lame/decoding/stream_decoder.rb +37 -0
  23. data/lib/lame/delegation.rb +68 -0
  24. data/lib/lame/encoder.rb +73 -0
  25. data/lib/lame/encoding/encode_short_buffer.rb +26 -0
  26. data/lib/lame/encoding/flusher.rb +22 -0
  27. data/lib/lame/encoding/id3.rb +46 -0
  28. data/lib/lame/encoding/vbr_info.rb +22 -0
  29. data/lib/lame/error.rb +13 -0
  30. data/lib/lame/ffi.rb +20 -0
  31. data/lib/lame/ffi/decode_flags.rb +19 -0
  32. data/lib/lame/ffi/enums.rb +75 -0
  33. data/lib/lame/ffi/functions.rb +272 -0
  34. data/lib/lame/ffi/global_flags.rb +20 -0
  35. data/lib/lame/ffi/mp3_data.rb +37 -0
  36. data/lib/lame/ffi/version.rb +17 -0
  37. data/lib/lame/version.rb +3 -0
  38. data/spec/buffer_spec.rb +26 -0
  39. data/spec/configuration_spec.rb +391 -0
  40. data/spec/decoder_spec.rb +120 -0
  41. data/spec/decoding/decoded_frame_spec.rb +44 -0
  42. data/spec/decoding/id3_tag_parser_spec.rb +54 -0
  43. data/spec/decoding/mp3_data_header_parser_spec.rb +95 -0
  44. data/spec/decoding/mpeg_audio_frame_finder_spec.rb +50 -0
  45. data/spec/decoding/mpeg_audio_frame_matcher_spec.rb +179 -0
  46. data/spec/decoding/single_frame_decoder_spec.rb +104 -0
  47. data/spec/decoding/stream_decoder_spec.rb +43 -0
  48. data/spec/delegation_spec.rb +146 -0
  49. data/spec/encoder_spec.rb +279 -0
  50. data/spec/encoding/encode_short_buffer_spec.rb +72 -0
  51. data/spec/encoding/flusher_spec.rb +47 -0
  52. data/spec/encoding/id3_spec.rb +106 -0
  53. data/spec/encoding/vbr_info_spec.rb +47 -0
  54. data/spec/ffi/decode_flags_spec.rb +16 -0
  55. data/spec/ffi/encoding_spec.rb +223 -0
  56. data/spec/ffi/global_flags_spec.rb +542 -0
  57. data/spec/ffi/id3tag_spec.rb +135 -0
  58. data/spec/ffi/mp3_data_spec.rb +26 -0
  59. data/spec/files/dies-irae.wav +0 -0
  60. data/spec/integration/decoding_spec.rb +179 -0
  61. data/spec/integration/encoding_spec.rb +126 -0
  62. data/spec/integration/id3_tags_spec.rb +96 -0
  63. data/spec/spec_helper.rb +175 -0
  64. metadata +254 -0
@@ -0,0 +1,542 @@
1
+ require 'spec_helper'
2
+
3
+ module LAME
4
+ describe GlobalFlags do
5
+ it "initializes LAME" do
6
+ pointer = ::FFI::Pointer.new(0)
7
+ LAME.should_receive(:lame_init).and_return(pointer)
8
+ GlobalFlags.new
9
+ end
10
+
11
+ it "closes the LAME struct pointer" do
12
+ pointer = ::FFI::Pointer.new(0)
13
+ LAME.should_receive(:lame_close).with(pointer)
14
+ GlobalFlags.release(pointer)
15
+ end
16
+ end
17
+
18
+ describe "FFI calls to global flags" do
19
+
20
+ before do
21
+ @flags_pointer = LAME.lame_init
22
+ end
23
+
24
+ after do
25
+ LAME.lame_close(@flags_pointer)
26
+ end
27
+
28
+ it "sets msgf" do
29
+ callback = ::FFI::Function.new(:void, [:string, :pointer]) do |format, arguments|
30
+ # the :pointer is a va_list, FFI doesn't support that in callbacks..
31
+ # puts format
32
+ end
33
+
34
+ LAME.lame_set_msgf(@flags_pointer, callback).should eql 0
35
+ LAME.lame_set_errorf(@flags_pointer, callback).should eql 0
36
+ LAME.lame_set_debugf(@flags_pointer, callback).should eql 0
37
+
38
+ LAME.lame_init_params(@flags_pointer)
39
+
40
+ LAME.lame_print_config(@flags_pointer)
41
+ LAME.lame_print_internals(@flags_pointer)
42
+ end
43
+
44
+ context "global flags" do
45
+
46
+ before do
47
+ LAME.lame_init_params(@flags_pointer)
48
+ end
49
+
50
+ it "has a number of samples" do
51
+ LAME.should have_flag(:num_samples).with_value(2**32-1).for(@flags_pointer)
52
+ LAME.should be_able_to_set(:num_samples).to(1).for(@flags_pointer)
53
+ end
54
+
55
+ it "has an input samplerate" do
56
+ LAME.should have_flag(:in_samplerate).with_value(44100).for(@flags_pointer)
57
+ LAME.should be_able_to_set(:in_samplerate).to(22050).for(@flags_pointer)
58
+ end
59
+
60
+ it "has a number of channels" do
61
+ LAME.should have_flag(:num_channels).with_value(2).for(@flags_pointer)
62
+ LAME.should be_able_to_set(:num_channels).to(1).for(@flags_pointer)
63
+ end
64
+
65
+ it "has a scale" do
66
+ LAME.should have_flag(:scale).with_value(0.95).for(@flags_pointer)
67
+ LAME.should be_able_to_set(:scale).to(2.0).for(@flags_pointer)
68
+ end
69
+
70
+ it "has a scale_left" do
71
+ LAME.should have_flag(:scale_left).with_value(1.0).for(@flags_pointer)
72
+ LAME.should be_able_to_set(:scale_left).to(2.0).for(@flags_pointer)
73
+ end
74
+
75
+ it "has a scale_right" do
76
+ LAME.should have_flag(:scale_right).with_value(1.0).for(@flags_pointer)
77
+ LAME.should be_able_to_set(:scale_right).to(2.0).for(@flags_pointer)
78
+ end
79
+
80
+ it "has a output samplerate" do
81
+ LAME.should have_flag(:out_samplerate).with_value(44100).for(@flags_pointer)
82
+ LAME.should be_able_to_set(:out_samplerate).to(48000).for(@flags_pointer)
83
+ end
84
+
85
+ it "has an analysis" do
86
+ LAME.should have_flag(:analysis).with_value(0).for(@flags_pointer)
87
+ LAME.should be_able_to_set(:analysis).to(1).for(@flags_pointer)
88
+ end
89
+
90
+ it "has bWriteVbrTag" do
91
+ LAME.should have_flag(:bWriteVbrTag).with_value(1).for(@flags_pointer)
92
+ LAME.should be_able_to_set(:bWriteVbrTag).to(0).for(@flags_pointer)
93
+ end
94
+
95
+ it "has decode only" do
96
+ LAME.should have_flag(:decode_only).with_value(0).for(@flags_pointer)
97
+ LAME.should be_able_to_set(:decode_only).to(1).for(@flags_pointer)
98
+ end
99
+
100
+ it "has a quality" do
101
+ LAME.should have_flag(:quality).with_value(3).for(@flags_pointer)
102
+ LAME.should be_able_to_set(:quality).to(1).for(@flags_pointer)
103
+ end
104
+
105
+ it "has a mode" do
106
+ LAME.should have_flag(:mode).with_value(:joint_stereo).for(@flags_pointer)
107
+ LAME.should be_able_to_set(:mode).to(:stereo).for(@flags_pointer)
108
+ end
109
+
110
+ it "has force ms" do
111
+ LAME.should have_flag(:force_ms).with_value(0).for(@flags_pointer)
112
+ LAME.should be_able_to_set(:force_ms).to(1).for(@flags_pointer)
113
+ end
114
+
115
+ it "has free format" do
116
+ LAME.should have_flag(:free_format).with_value(0).for(@flags_pointer)
117
+ LAME.should be_able_to_set(:free_format).to(1).for(@flags_pointer)
118
+ end
119
+
120
+ it "has find replay gain" do
121
+ LAME.should have_flag(:findReplayGain).with_value(0).for(@flags_pointer)
122
+ LAME.should be_able_to_set(:findReplayGain).to(1).for(@flags_pointer)
123
+ end
124
+
125
+ it "has decode on the fly" do
126
+ LAME.should have_flag(:decode_on_the_fly).with_value(0).for(@flags_pointer)
127
+ LAME.should be_able_to_set(:decode_on_the_fly).to(1).for(@flags_pointer)
128
+ end
129
+
130
+ it "has nogap total" do
131
+ LAME.should have_flag(:nogap_total).with_value(0).for(@flags_pointer)
132
+ LAME.should be_able_to_set(:nogap_total).to(1).for(@flags_pointer)
133
+ end
134
+
135
+ it "has nogap current index" do
136
+ LAME.should have_flag(:nogap_currentindex).with_value(0).for(@flags_pointer)
137
+ LAME.should be_able_to_set(:nogap_currentindex).to(1).for(@flags_pointer)
138
+ end
139
+
140
+ # lame_set_errorf
141
+ # lame_set_debugf
142
+ # lame_set_msgf
143
+
144
+ it "has a brate" do
145
+ LAME.should have_flag(:brate).with_value(128).for(@flags_pointer)
146
+ LAME.should be_able_to_set(:brate).to(192).for(@flags_pointer)
147
+ end
148
+
149
+ it "has a compression ratio" do
150
+ LAME.should have_flag(:compression_ratio).with_value(1).for(@flags_pointer)
151
+ #LAME.should be_able_to_set(:compression_ratio).to(11.025).for(@flags_pointer) # can't set it..?
152
+ end
153
+
154
+ it "has a preset" do
155
+ LAME.lame_set_preset(@flags_pointer, :V0).should eql :V0
156
+ end
157
+
158
+ it "sets asm optimizations" do
159
+ LAME.lame_set_asm_optimizations(@flags_pointer, :MMX, 1).should eql :MMX
160
+ end
161
+
162
+ it "has a copyright mark" do
163
+ LAME.should have_flag(:copyright).with_value(0).for(@flags_pointer)
164
+ LAME.should be_able_to_set(:copyright).to(1).for(@flags_pointer)
165
+ end
166
+
167
+ it "has an original mark" do
168
+ LAME.should have_flag(:original).with_value(1).for(@flags_pointer)
169
+ LAME.should be_able_to_set(:original).to(0).for(@flags_pointer)
170
+ end
171
+
172
+ it "has error protection" do
173
+ LAME.should have_flag(:error_protection).with_value(0).for(@flags_pointer)
174
+ LAME.should be_able_to_set(:error_protection).to(1).for(@flags_pointer)
175
+ end
176
+
177
+ it "has extension mark" do
178
+ LAME.should have_flag(:extension).with_value(0).for(@flags_pointer)
179
+ LAME.should be_able_to_set(:extension).to(1).for(@flags_pointer)
180
+ end
181
+
182
+ it "has strict ISO" do
183
+ LAME.should have_flag(:strict_ISO).with_value(2).for(@flags_pointer) # ?
184
+ LAME.should be_able_to_set(:strict_ISO).to(1).for(@flags_pointer)
185
+ end
186
+
187
+ context "quantization/noise shaping" do
188
+
189
+ it "has disable reservoir" do
190
+ LAME.should have_flag(:disable_reservoir).with_value(0).for(@flags_pointer)
191
+ LAME.should be_able_to_set(:disable_reservoir).to(1).for(@flags_pointer)
192
+ end
193
+
194
+ it "has quant comp" do
195
+ LAME.should have_flag(:quant_comp).with_value(9).for(@flags_pointer)
196
+ LAME.should be_able_to_set(:quant_comp).to(11).for(@flags_pointer)
197
+ end
198
+
199
+ it "has quant comp short" do
200
+ LAME.should have_flag(:quant_comp_short).with_value(9).for(@flags_pointer)
201
+ LAME.should be_able_to_set(:quant_comp_short).to(11).for(@flags_pointer)
202
+ end
203
+
204
+ it "has experimentalX" do
205
+ LAME.should have_flag(:experimentalX).with_value(9).for(@flags_pointer)
206
+ LAME.should be_able_to_set(:experimentalX).to(11).for(@flags_pointer)
207
+ end
208
+
209
+ it "has experimentalY" do
210
+ LAME.should have_flag(:experimentalY).with_value(0).for(@flags_pointer)
211
+ LAME.should be_able_to_set(:experimentalY).to(1).for(@flags_pointer)
212
+ end
213
+
214
+ it "has experimentalZ" do
215
+ LAME.should have_flag(:experimentalZ).with_value(0).for(@flags_pointer)
216
+ LAME.should be_able_to_set(:experimentalZ).to(1).for(@flags_pointer)
217
+ end
218
+
219
+ it "has exp nspsytune" do
220
+ LAME.should have_flag(:exp_nspsytune).with_value(1).for(@flags_pointer)
221
+ LAME.should be_able_to_set(:exp_nspsytune).to(0).for(@flags_pointer)
222
+ end
223
+
224
+ it "has msfix" do
225
+ LAME.should have_flag(:msfix).with_value(1.95).for(@flags_pointer)
226
+ LAME.should be_able_to_set(:msfix).to(1.55).and_return(nil).for(@flags_pointer)
227
+ end
228
+ end
229
+
230
+ context "VBR" do
231
+ it "has VBR mode" do
232
+ LAME.should have_flag(:VBR).with_value(:vbr_off).for(@flags_pointer)
233
+ LAME.should be_able_to_set(:VBR).to(:vbr_mt).for(@flags_pointer)
234
+ end
235
+
236
+ it "has VBR q" do
237
+ LAME.should have_flag(:VBR_q).with_value(4).for(@flags_pointer)
238
+ LAME.should be_able_to_set(:VBR_q).to(5).for(@flags_pointer)
239
+ end
240
+
241
+ it "has VBR quality" do
242
+ LAME.should have_flag(:VBR_quality).with_value(4.0).for(@flags_pointer)
243
+ LAME.should be_able_to_set(:VBR_quality).to(5.0).for(@flags_pointer)
244
+ end
245
+
246
+ it "has VBR mean bitrate kbps" do
247
+ LAME.should have_flag(:VBR_mean_bitrate_kbps).with_value(128).for(@flags_pointer)
248
+ LAME.should be_able_to_set(:VBR_mean_bitrate_kbps).to(192).for(@flags_pointer)
249
+ end
250
+
251
+ it "has VBR min bitrate kbps" do
252
+ LAME.should have_flag(:VBR_min_bitrate_kbps).with_value(0).for(@flags_pointer)
253
+ LAME.should be_able_to_set(:VBR_min_bitrate_kbps).to(128).for(@flags_pointer)
254
+ end
255
+
256
+ it "has VBR max bitrate kbps" do
257
+ LAME.should have_flag(:VBR_max_bitrate_kbps).with_value(0).for(@flags_pointer)
258
+ LAME.should be_able_to_set(:VBR_max_bitrate_kbps).to(256).for(@flags_pointer)
259
+ end
260
+
261
+ it "has VBR hard min bitrate kbps" do
262
+ LAME.should have_flag(:VBR_hard_min).with_value(0).for(@flags_pointer)
263
+ LAME.should be_able_to_set(:VBR_hard_min).to(1).for(@flags_pointer)
264
+ end
265
+ end
266
+
267
+ context "filtering control" do
268
+ it "has lowpassfreq" do
269
+ LAME.should have_flag(:lowpassfreq).with_value(17000).for(@flags_pointer)
270
+ LAME.should be_able_to_set(:lowpassfreq).to(18000).for(@flags_pointer)
271
+ end
272
+
273
+ it "has lowpasswidth" do
274
+ LAME.should have_flag(:lowpasswidth).with_value(-1).for(@flags_pointer)
275
+ LAME.should be_able_to_set(:lowpasswidth).to(200).for(@flags_pointer)
276
+ end
277
+
278
+ it "has highpassfreq" do
279
+ LAME.should have_flag(:highpassfreq).with_value(0).for(@flags_pointer)
280
+ LAME.should be_able_to_set(:highpassfreq).to(-1).for(@flags_pointer)
281
+ end
282
+
283
+ it "has highpasswidth" do
284
+ LAME.should have_flag(:highpasswidth).with_value(-1).for(@flags_pointer)
285
+ LAME.should be_able_to_set(:highpasswidth).to(200).for(@flags_pointer)
286
+ end
287
+ end
288
+
289
+ context "psycho acoustics" do
290
+ it "has ATHonly" do
291
+ LAME.should have_flag(:ATHonly).with_value(0).for(@flags_pointer)
292
+ LAME.should be_able_to_set(:ATHonly).to(1).for(@flags_pointer)
293
+ end
294
+
295
+ it "has ATHshort" do
296
+ LAME.should have_flag(:ATHshort).with_value(0).for(@flags_pointer)
297
+ LAME.should be_able_to_set(:ATHshort).to(1).for(@flags_pointer)
298
+ end
299
+
300
+ it "has noATH" do
301
+ LAME.should have_flag(:noATH).with_value(0).for(@flags_pointer)
302
+ LAME.should be_able_to_set(:noATH).to(1).for(@flags_pointer)
303
+ end
304
+
305
+ it "has ATHtype" do
306
+ LAME.should have_flag(:ATHtype).with_value(4).for(@flags_pointer)
307
+ LAME.should be_able_to_set(:ATHtype).to(5).for(@flags_pointer)
308
+ end
309
+
310
+ it "has ATHlower" do
311
+ LAME.should have_flag(:ATHlower).with_value(3.0).for(@flags_pointer)
312
+ LAME.should be_able_to_set(:ATHlower).to(4.0).for(@flags_pointer)
313
+ end
314
+
315
+ it "has athaa type" do
316
+ LAME.should have_flag(:athaa_type).with_value(-1).for(@flags_pointer)
317
+ LAME.should be_able_to_set(:athaa_type).to(1).for(@flags_pointer)
318
+ end
319
+
320
+ it "has athaa sensitivity" do
321
+ LAME.should have_flag(:athaa_sensitivity).with_value(0.0).for(@flags_pointer)
322
+ LAME.should be_able_to_set(:athaa_sensitivity).to(1.0).for(@flags_pointer)
323
+ end
324
+ end
325
+
326
+ context "blocks" do
327
+ it "has allow diff short" do
328
+ LAME.should have_flag(:allow_diff_short).with_value(0).for(@flags_pointer)
329
+ LAME.should be_able_to_set(:allow_diff_short).to(1).for(@flags_pointer)
330
+ end
331
+
332
+ it "has useTemporal" do
333
+ LAME.should have_flag(:useTemporal).with_value(1).for(@flags_pointer)
334
+ LAME.should be_able_to_set(:useTemporal).to(0).for(@flags_pointer)
335
+ end
336
+
337
+ it "has interChRatio" do
338
+ LAME.should have_flag(:interChRatio).with_value(0.0002).for(@flags_pointer)
339
+ LAME.should be_able_to_set(:interChRatio).to(0.0003).for(@flags_pointer)
340
+ end
341
+
342
+ it "has no short blocks" do
343
+ LAME.should have_flag(:no_short_blocks).with_value(0).for(@flags_pointer)
344
+ LAME.should be_able_to_set(:no_short_blocks).to(1).for(@flags_pointer)
345
+ end
346
+
347
+ it "has force short blocks" do
348
+ LAME.should have_flag(:force_short_blocks).with_value(0).for(@flags_pointer)
349
+ LAME.should be_able_to_set(:force_short_blocks).to(1).for(@flags_pointer)
350
+ end
351
+
352
+ it "has emphasis" do
353
+ LAME.should have_flag(:emphasis).with_value(0).for(@flags_pointer)
354
+ LAME.should be_able_to_set(:emphasis).to(1).for(@flags_pointer)
355
+ end
356
+ end
357
+
358
+ context "internal variables" do
359
+ it "has a version" do
360
+ LAME.should have_getter(:version).with_value(1).for(@flags_pointer)
361
+ end
362
+
363
+ it "has encoder delay" do
364
+ LAME.should have_getter(:encoder_delay).with_value(576).for(@flags_pointer)
365
+ end
366
+
367
+ it "has encoder padding" do
368
+ LAME.should have_getter(:encoder_padding).with_value(0).for(@flags_pointer)
369
+ end
370
+
371
+ it "has framesize" do
372
+ LAME.should have_getter(:framesize).with_value(1152).for(@flags_pointer)
373
+ end
374
+
375
+ it "has mf samples to encode" do
376
+ LAME.should have_getter(:mf_samples_to_encode).with_value(1728).for(@flags_pointer)
377
+ end
378
+
379
+ # mp3buffer (see below)
380
+
381
+ it "has frameNum" do
382
+ LAME.should have_getter(:frameNum).with_value(0).for(@flags_pointer)
383
+ end
384
+
385
+ # unpredictable default value between versions:
386
+ it "has totalframes" do
387
+ # LAME.should have_getter(:totalframes).with_value(3728272).for(@flags_pointer)
388
+ LAME.should have_getter(:totalframes).for(@flags_pointer)
389
+ end
390
+
391
+ it "has RatioGain" do
392
+ LAME.should have_getter(:RadioGain).with_value(0).for(@flags_pointer)
393
+ end
394
+
395
+ it "has AudiophileGain" do
396
+ LAME.should have_getter(:AudiophileGain).with_value(0).for(@flags_pointer)
397
+ end
398
+
399
+ it "has PeakSample" do
400
+ LAME.should have_getter(:PeakSample).with_value(0.0).for(@flags_pointer)
401
+ end
402
+
403
+ it "has noclipGainChange" do
404
+ LAME.should have_getter(:noclipGainChange).with_value(0).for(@flags_pointer)
405
+ end
406
+
407
+ it "has noclipScale" do
408
+ LAME.should have_getter(:noclipScale).with_value(-1.0).for(@flags_pointer)
409
+ end
410
+ end
411
+
412
+ context "version" do
413
+ it "has a version" do
414
+ LAME.get_lame_version.should =~ /3\.\d\d\.\d/
415
+ end
416
+
417
+ it "has a short version" do
418
+ LAME.get_lame_short_version.should =~ /3\.\d\d\.\d/
419
+ end
420
+
421
+ it "has a very short version" do
422
+ LAME.get_lame_very_short_version.should =~ /LAME3\.\d\dr\d/
423
+ end
424
+
425
+ it "has a psy version" do
426
+ LAME.get_psy_version.should eql "1.0"
427
+ end
428
+
429
+ it "has a url" do
430
+ LAME.get_lame_url.should eql "http://lame.sf.net"
431
+ end
432
+
433
+ it "has os bitness" do
434
+ LAME.get_lame_os_bitness.should =~ /(32|64)bits/
435
+ end
436
+
437
+ context "numerical version" do
438
+
439
+ let(:version) { LAME.get_lame_version_numerical(@flags_pointer) }
440
+ it "has a major version" do
441
+ version[:major].should eql 3
442
+
443
+ end
444
+ it "has a minor version" do
445
+ version[:minor].should eql 99
446
+ end
447
+
448
+ it "has a alpha version" do
449
+ version[:alpha].should eql 0
450
+ end
451
+
452
+ it "has a beta version" do
453
+ version[:beta].should eql 0
454
+ end
455
+
456
+ it "has a psy_major version" do
457
+ version[:psy_major].should eql 1
458
+ end
459
+
460
+ it "has a psy_minor version" do
461
+ version[:psy_minor].should eql 0
462
+ end
463
+
464
+ it "has a psy_alpha version" do
465
+ version[:psy_alpha].should eql 0
466
+ end
467
+
468
+ it "has a psy_beta version" do
469
+ version[:psy_beta].should eql 0
470
+ end
471
+
472
+ it "has features" do
473
+ version[:features].should eql ""
474
+ end
475
+ end
476
+
477
+ end
478
+ end
479
+
480
+ context "with custom logging" do
481
+
482
+ it "has size mp3buffer" do
483
+ # this call produces a 'stange error flushing buffer' warning, suppress it:
484
+ callback = ::FFI::Function.new(:void, [:string, :pointer]) do |format, arguments|
485
+ # do nothing
486
+ end
487
+
488
+ LAME.lame_set_errorf(@flags_pointer, callback)
489
+ LAME.lame_init_params(@flags_pointer)
490
+
491
+ LAME.should have_getter(:size_mp3buffer).with_value(834).for(@flags_pointer)
492
+ end
493
+
494
+ it "prints config" do
495
+ pending "we need to be able to tweak logging to be able to test this"
496
+ LAME.lame_print_config(@flags_pointer)
497
+ end
498
+
499
+ it "prints internals" do
500
+ pending "we need to be able to tweak logging to be able to test this"
501
+ LAME.lame_print_internals(@flags_pointer)
502
+ end
503
+
504
+ end
505
+
506
+ context "tables" do
507
+
508
+ it "has the bitrate table" do
509
+ table = (0...3).map do |mpeg_version|
510
+ (0...16).map do |table_index|
511
+ LAME.lame_get_bitrate(mpeg_version, table_index)
512
+ end
513
+ end
514
+ expected = [
515
+ [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1],
516
+ [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1],
517
+ [0, 8, 16, 24, 32, 40, 48, 56, 64, -1, -1, -1, -1, -1, -1, -1]
518
+ ]
519
+
520
+ table.should eql expected
521
+ end
522
+
523
+ it "has the samplerate table" do
524
+ table = (0...3).map do |mpeg_version|
525
+ (0...4).map do |table_index|
526
+ LAME.lame_get_samplerate(mpeg_version, table_index)
527
+ end
528
+ end
529
+
530
+ expected = [
531
+ [22050, 24000, 16000, -1],
532
+ [44100, 48000, 32000, -1],
533
+ [11025, 12000, 8000, -1]
534
+ ]
535
+
536
+ table.should eql expected
537
+ end
538
+
539
+ end
540
+
541
+ end
542
+ end