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,22 @@
1
+ module LAME
2
+ module Encoding
3
+ class VBRInfo
4
+ extend Forwardable
5
+
6
+ def_delegators :@configuration, :global_flags, :framesize, :output_buffer_size
7
+
8
+ def initialize(configuration)
9
+ @configuration = configuration
10
+ end
11
+
12
+ def frame
13
+ output = Buffer.create_empty(:uchar, output_buffer_size)
14
+
15
+ mp3_size = LAME.lame_get_lametag_frame(global_flags, output, output_buffer_size)
16
+
17
+ output.get_bytes(0, mp3_size)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ module LAME
2
+
3
+ class LAMEError < StandardError; end
4
+
5
+ class ConfigurationError < LAMEError; end
6
+
7
+ class Mp3DataHeaderNotFoundError < LAMEError; end
8
+
9
+ class MPEGAudioFrameNotFoundError < LAMEError; end
10
+
11
+ class DecodingError < LAMEError; end
12
+
13
+ end
@@ -0,0 +1,20 @@
1
+ require 'lame/ffi/global_flags'
2
+ require 'lame/ffi/enums'
3
+ require 'lame/ffi/version'
4
+ require 'lame/ffi/functions'
5
+
6
+ require 'lame/ffi/decode_flags'
7
+ require 'lame/ffi/mp3_data'
8
+
9
+ module LAME
10
+ module FFI
11
+
12
+ def self.included(base)
13
+ base.class_eval do
14
+ include Enums
15
+ include Functions
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module LAME
2
+ module FFI
3
+
4
+ # We need a ManagedStruct to clean up after LAME.
5
+ class DecodeFlags < ::FFI::ManagedStruct
6
+ layout :head, :uchar # Not actually used, but FFI needs a layout..
7
+
8
+ def initialize
9
+ hip_struct = LAME.hip_decode_init
10
+ super(hip_struct)
11
+ end
12
+
13
+ def self.release(ptr)
14
+ LAME.hip_decode_exit(ptr)
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,75 @@
1
+ module LAME
2
+ module FFI
3
+ module Enums
4
+
5
+ def self.included(base)
6
+ base.class_eval do
7
+
8
+ enum :vbr_mode, [
9
+ :vbr_off, 0,
10
+ :vbr_mt,
11
+ :vbr_rh,
12
+ :vbr_abr,
13
+ :vbr_default, 4, # two enums with value 4
14
+ :vbr_mtrh, 4,
15
+ :vbr_max_indicator
16
+ ]
17
+
18
+ enum :mpeg_mode, [
19
+ :stereo, 0,
20
+ :joint_stereo,
21
+ :dual_channel, # unsupported
22
+ :mono,
23
+ :not_set,
24
+ :max_indicator # used internally
25
+ ]
26
+
27
+ enum :preset_mode, [
28
+ # FhG style:
29
+ # These double enum values break in jruby-19mode.
30
+ # Internally FFI uses hashes, jruby might have implemented this differently?
31
+ # :VBR_10, 410,
32
+ # :VBR_20, 420,
33
+ # :VBR_30, 430,
34
+ # :VBR_40, 440,
35
+ # :VBR_50, 450,
36
+ # :VBR_60, 460,
37
+ # :VBR_70, 470,
38
+ # :VBR_80, 480,
39
+ # :VBR_90, 490,
40
+ # :VBR_100, 500,
41
+
42
+ # LAME style:
43
+ :V9, 410,
44
+ :V8, 420,
45
+ :V7, 430,
46
+ :V6, 440,
47
+ :V5, 450,
48
+ :V4, 460,
49
+ :V3, 470,
50
+ :V2, 480,
51
+ :V1, 490,
52
+ :V0, 500,
53
+
54
+ # old presets:
55
+ :R3MIX, 1000,
56
+ :STANDARD, 1001,
57
+ :EXTREME, 1002,
58
+ :INSANE, 1003,
59
+ :STANDARD_FAST, 1004,
60
+ :EXTREME_FAST, 1005,
61
+ :MEDIUM, 1006,
62
+ :MEDIUM_FAST, 1007
63
+ ]
64
+
65
+ enum :asm_optimizations, [
66
+ :MMX, 1,
67
+ :AMD_3DNOW, 2,
68
+ :SSE, 3
69
+ ]
70
+ end
71
+ end
72
+
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,272 @@
1
+ module LAME
2
+ module Functions
3
+
4
+ def self.included(base)
5
+ base.class_eval do
6
+
7
+ typedef :pointer, :global_flags
8
+
9
+ # These `attach_function` declarations are in the order of lame.h:
10
+
11
+ # initialization
12
+ attach_function :lame_init, [], :global_flags
13
+
14
+ # global flags
15
+ attach_function :lame_set_num_samples, [:global_flags, :ulong], :int
16
+ attach_function :lame_get_num_samples, [:global_flags], :ulong
17
+ attach_function :lame_set_in_samplerate, [:global_flags, :int], :int
18
+ attach_function :lame_get_in_samplerate, [:global_flags], :int
19
+ attach_function :lame_set_num_channels, [:global_flags, :int], :int
20
+ attach_function :lame_get_num_channels, [:global_flags], :int
21
+ attach_function :lame_set_scale, [:global_flags, :float], :int
22
+ attach_function :lame_get_scale, [:global_flags], :float
23
+ attach_function :lame_set_scale_left, [:global_flags, :float], :int
24
+ attach_function :lame_get_scale_left, [:global_flags], :float
25
+ attach_function :lame_set_scale_right, [:global_flags, :float], :int
26
+ attach_function :lame_get_scale_right, [:global_flags], :float
27
+ attach_function :lame_set_out_samplerate, [:global_flags, :int], :int
28
+ attach_function :lame_get_out_samplerate, [:global_flags], :int
29
+ attach_function :lame_set_analysis, [:global_flags, :int], :int
30
+ attach_function :lame_get_analysis, [:global_flags], :int
31
+ attach_function :lame_set_bWriteVbrTag, [:global_flags, :int], :int
32
+ attach_function :lame_get_bWriteVbrTag, [:global_flags], :int
33
+ attach_function :lame_set_decode_only, [:global_flags, :int], :int
34
+ attach_function :lame_get_decode_only, [:global_flags], :int
35
+ attach_function :lame_set_quality, [:global_flags, :int], :int
36
+ attach_function :lame_get_quality, [:global_flags], :int
37
+ attach_function :lame_set_mode, [:global_flags, :mpeg_mode], :int
38
+ attach_function :lame_get_mode, [:global_flags], :mpeg_mode
39
+ attach_function :lame_set_force_ms, [:global_flags, :int], :int
40
+ attach_function :lame_get_force_ms, [:global_flags], :int
41
+ attach_function :lame_set_free_format, [:global_flags, :int], :int
42
+ attach_function :lame_get_free_format, [:global_flags], :int
43
+ attach_function :lame_set_findReplayGain, [:global_flags, :int], :int
44
+ attach_function :lame_get_findReplayGain, [:global_flags], :int
45
+ attach_function :lame_set_decode_on_the_fly, [:global_flags, :int], :int
46
+ attach_function :lame_get_decode_on_the_fly, [:global_flags], :int
47
+
48
+ # counters for gaplass encoding
49
+ attach_function :lame_set_nogap_total, [:global_flags, :int], :int
50
+ attach_function :lame_get_nogap_total, [:global_flags], :int
51
+ attach_function :lame_set_nogap_currentindex, [:global_flags, :int], :int
52
+ attach_function :lame_get_nogap_currentindex, [:global_flags], :int
53
+
54
+ # the :pointer is a va_list, FFI doesn't support that in callbacks..
55
+ callback :log_function, [:string, :pointer], :void
56
+ attach_function :lame_set_errorf, [:global_flags, :log_function], :int
57
+ attach_function :lame_set_debugf, [:global_flags, :log_function], :int
58
+ attach_function :lame_set_msgf, [:global_flags, :log_function], :int
59
+
60
+ attach_function :lame_set_brate, [:global_flags, :int], :int
61
+ attach_function :lame_get_brate, [:global_flags], :int
62
+ attach_function :lame_set_compression_ratio, [:global_flags, :int], :int
63
+ attach_function :lame_get_compression_ratio, [:global_flags], :int
64
+ attach_function :lame_set_preset, [:global_flags, :preset_mode], :preset_mode
65
+ attach_function :lame_set_asm_optimizations, [:global_flags, :asm_optimizations, :int], :asm_optimizations
66
+ attach_function :lame_set_copyright, [:global_flags, :int], :int
67
+ attach_function :lame_get_copyright, [:global_flags], :int
68
+ attach_function :lame_set_original, [:global_flags, :int], :int
69
+ attach_function :lame_get_original, [:global_flags], :int
70
+ attach_function :lame_set_error_protection, [:global_flags, :int], :int
71
+ attach_function :lame_get_error_protection, [:global_flags], :int
72
+ attach_function :lame_set_extension, [:global_flags, :int], :int
73
+ attach_function :lame_get_extension, [:global_flags], :int
74
+ attach_function :lame_set_strict_ISO, [:global_flags, :int], :int
75
+ attach_function :lame_get_strict_ISO, [:global_flags], :int
76
+
77
+ # quantization/noise shaping
78
+ attach_function :lame_set_disable_reservoir, [:global_flags, :int], :int
79
+ attach_function :lame_get_disable_reservoir, [:global_flags], :int
80
+ attach_function :lame_set_quant_comp, [:global_flags, :int], :int
81
+ attach_function :lame_get_quant_comp, [:global_flags], :int
82
+ attach_function :lame_set_quant_comp_short, [:global_flags, :int], :int
83
+ attach_function :lame_get_quant_comp_short, [:global_flags], :int
84
+ attach_function :lame_set_experimentalX, [:global_flags, :int], :int
85
+ attach_function :lame_get_experimentalX, [:global_flags], :int
86
+ attach_function :lame_set_experimentalY, [:global_flags, :int], :int
87
+ attach_function :lame_get_experimentalY, [:global_flags], :int
88
+ attach_function :lame_set_experimentalZ, [:global_flags, :int], :int
89
+ attach_function :lame_get_experimentalZ, [:global_flags], :int
90
+ attach_function :lame_set_exp_nspsytune, [:global_flags, :int], :int
91
+ attach_function :lame_get_exp_nspsytune, [:global_flags], :int
92
+ attach_function :lame_set_msfix, [:global_flags, :double], :void
93
+ attach_function :lame_get_msfix, [:global_flags], :float
94
+
95
+ # VBR
96
+ attach_function :lame_set_VBR, [:global_flags, :vbr_mode], :int
97
+ attach_function :lame_get_VBR, [:global_flags], :vbr_mode
98
+ attach_function :lame_set_VBR_q, [:global_flags, :int], :int
99
+ attach_function :lame_get_VBR_q, [:global_flags], :int
100
+ attach_function :lame_set_VBR_quality, [:global_flags, :float], :int
101
+ attach_function :lame_get_VBR_quality, [:global_flags], :float
102
+ attach_function :lame_set_VBR_mean_bitrate_kbps, [:global_flags, :int], :int
103
+ attach_function :lame_get_VBR_mean_bitrate_kbps, [:global_flags], :int
104
+ attach_function :lame_set_VBR_min_bitrate_kbps, [:global_flags, :int], :int
105
+ attach_function :lame_get_VBR_min_bitrate_kbps, [:global_flags], :int
106
+ attach_function :lame_set_VBR_max_bitrate_kbps, [:global_flags, :int], :int
107
+ attach_function :lame_get_VBR_max_bitrate_kbps, [:global_flags], :int
108
+ attach_function :lame_set_VBR_hard_min, [:global_flags, :int], :int
109
+ attach_function :lame_get_VBR_hard_min, [:global_flags], :int
110
+
111
+ # Filtering control
112
+ attach_function :lame_set_lowpassfreq, [:global_flags, :int], :int
113
+ attach_function :lame_get_lowpassfreq, [:global_flags], :int
114
+ attach_function :lame_set_lowpasswidth, [:global_flags, :int], :int
115
+ attach_function :lame_get_lowpasswidth, [:global_flags], :int
116
+ attach_function :lame_set_highpassfreq, [:global_flags, :int], :int
117
+ attach_function :lame_get_highpassfreq, [:global_flags], :int
118
+ attach_function :lame_set_highpasswidth, [:global_flags, :int], :int
119
+ attach_function :lame_get_highpasswidth, [:global_flags], :int
120
+
121
+ # psycho acoustics ("absolute threshold of hearing")
122
+ attach_function :lame_set_ATHonly, [:global_flags, :int], :int
123
+ attach_function :lame_get_ATHonly, [:global_flags], :int
124
+ attach_function :lame_set_ATHshort, [:global_flags, :int], :int
125
+ attach_function :lame_get_ATHshort, [:global_flags], :int
126
+ attach_function :lame_set_noATH, [:global_flags, :int], :int
127
+ attach_function :lame_get_noATH, [:global_flags], :int
128
+ attach_function :lame_set_ATHtype, [:global_flags, :int], :int
129
+ attach_function :lame_get_ATHtype, [:global_flags], :int
130
+ attach_function :lame_set_ATHlower, [:global_flags, :float], :int
131
+ attach_function :lame_get_ATHlower, [:global_flags], :float
132
+ attach_function :lame_set_athaa_type, [:global_flags, :int], :int
133
+ attach_function :lame_get_athaa_type, [:global_flags], :int
134
+ attach_function :lame_set_athaa_sensitivity, [:global_flags, :float], :int
135
+ attach_function :lame_get_athaa_sensitivity, [:global_flags], :float
136
+
137
+ # misc
138
+ attach_function :lame_set_allow_diff_short, [:global_flags, :int], :int
139
+ attach_function :lame_get_allow_diff_short, [:global_flags], :int
140
+ attach_function :lame_set_useTemporal, [:global_flags, :int], :int
141
+ attach_function :lame_get_useTemporal, [:global_flags], :int
142
+ attach_function :lame_set_interChRatio, [:global_flags, :float], :int
143
+ attach_function :lame_get_interChRatio, [:global_flags], :float
144
+ attach_function :lame_set_no_short_blocks, [:global_flags, :int], :int
145
+ attach_function :lame_get_no_short_blocks, [:global_flags], :int
146
+ attach_function :lame_set_force_short_blocks, [:global_flags, :int], :int
147
+ attach_function :lame_get_force_short_blocks, [:global_flags], :int
148
+ attach_function :lame_set_emphasis, [:global_flags, :int], :int
149
+ attach_function :lame_get_emphasis, [:global_flags], :int
150
+
151
+ # internal variables
152
+ attach_function :lame_get_version, [:global_flags], :int
153
+ attach_function :lame_get_encoder_delay, [:global_flags], :int
154
+ attach_function :lame_get_encoder_padding, [:global_flags], :int
155
+ attach_function :lame_get_framesize, [:global_flags], :int
156
+ attach_function :lame_get_mf_samples_to_encode, [:global_flags], :int
157
+ attach_function :lame_get_size_mp3buffer, [:global_flags], :int
158
+ attach_function :lame_get_frameNum, [:global_flags], :int
159
+ attach_function :lame_get_totalframes, [:global_flags], :int
160
+ attach_function :lame_get_RadioGain, [:global_flags], :int
161
+ attach_function :lame_get_AudiophileGain, [:global_flags], :int
162
+ attach_function :lame_get_PeakSample, [:global_flags], :float
163
+ attach_function :lame_get_noclipGainChange, [:global_flags], :int
164
+ attach_function :lame_get_noclipScale, [:global_flags], :float
165
+
166
+ # initializing parameters
167
+ attach_function :lame_init_params, [:global_flags], :int
168
+
169
+ # version
170
+ attach_function :get_lame_version, [], :string
171
+ attach_function :get_lame_short_version, [], :string
172
+ attach_function :get_lame_very_short_version, [], :string
173
+ attach_function :get_psy_version, [], :string
174
+ attach_function :get_lame_url, [], :string
175
+ attach_function :get_lame_os_bitness, [], :string
176
+
177
+ attach_function :get_lame_version_numerical, [:global_flags], FFI::Version.by_value
178
+
179
+ # TODO: test when we have implemented lame_set_msgf
180
+ attach_function :lame_print_config, [:global_flags], :void
181
+ attach_function :lame_print_internals, [:global_flags], :void
182
+
183
+ # encoding
184
+ attach_function :lame_encode_buffer, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
185
+ attach_function :lame_encode_buffer_interleaved, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
186
+ attach_function :lame_encode_buffer_float, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
187
+ attach_function :lame_encode_buffer_ieee_float, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
188
+ attach_function :lame_encode_buffer_interleaved_ieee_float, [:global_flags, :buffer_in, :int, :buffer_out, :int], :int
189
+ attach_function :lame_encode_buffer_ieee_double, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
190
+ attach_function :lame_encode_buffer_interleaved_ieee_double, [:global_flags, :buffer_in, :int, :buffer_out, :int], :int
191
+ attach_function :lame_encode_buffer_long, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
192
+ attach_function :lame_encode_buffer_long2, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
193
+ attach_function :lame_encode_buffer_int, [:global_flags, :buffer_in, :buffer_in, :int, :buffer_out, :int], :int
194
+
195
+ # flushing
196
+ attach_function :lame_encode_flush, [:global_flags, :pointer, :int], :int
197
+ attach_function :lame_encode_flush_nogap, [:global_flags, :pointer, :int], :int
198
+
199
+ # bitstream
200
+ attach_function :lame_init_bitstream, [:global_flags], :int
201
+
202
+ # TODO: statistics (multi-dimensional arrays..)
203
+ attach_function :lame_bitrate_hist, [:global_flags, :pointer], :void
204
+ attach_function :lame_bitrate_kbps, [:global_flags, :pointer], :void
205
+ attach_function :lame_stereo_mode_hist, [:global_flags, :pointer], :void
206
+ # attach_function :lame_bitrate_stereo_mode_hist, [:global_flags, :pointer], :void
207
+ attach_function :lame_block_type_hist, [:global_flags, :pointer], :void
208
+ # attach_function :lame_bitrate_block_type_hist, [:global_flags, :pointer], :void
209
+
210
+ # NOTE: needs a file pointer, will be deprecated (?)
211
+ # attach_function :lame_mp3_tags_fid, [:pointer], :void
212
+
213
+ attach_function :lame_get_lametag_frame, [:global_flags, :buffer_out, :size_t], :size_t
214
+
215
+ # closing
216
+ attach_function :lame_close, [:global_flags], :int
217
+
218
+ # decoding
219
+ typedef :pointer, :decode_flags
220
+ typedef :pointer, :mp3_data
221
+
222
+ attach_function :hip_decode_init, [], :decode_flags
223
+ attach_function :hip_decode_exit, [:decode_flags], :int
224
+ attach_function :hip_set_errorf, [:decode_flags, :log_function], :void
225
+ attach_function :hip_set_debugf, [:decode_flags, :log_function], :void
226
+ attach_function :hip_set_msgf, [:decode_flags, :log_function], :void
227
+
228
+ attach_function :hip_decode, [:decode_flags, :buffer_in, :size_t, :buffer_out, :buffer_out], :int
229
+ attach_function :hip_decode_headers, [:decode_flags, :buffer_in, :size_t, :buffer_out, :buffer_out, :mp3_data], :int
230
+ attach_function :hip_decode1, [:decode_flags, :buffer_in, :size_t, :buffer_out, :buffer_out], :int
231
+ attach_function :hip_decode1_headers, [:decode_flags, :buffer_in, :size_t, :buffer_out, :buffer_out, :mp3_data], :int
232
+ attach_function :hip_decode1_headersB, [:decode_flags, :buffer_in, :size_t, :buffer_out, :buffer_out, :mp3_data, :pointer, :pointer], :int
233
+
234
+ # id3
235
+ callback :genre_callback, [:int, :string, :pointer], :void
236
+ attach_function :id3tag_genre_list, [:genre_callback, :pointer], :void
237
+ attach_function :id3tag_init, [:global_flags], :void
238
+ attach_function :id3tag_add_v2, [:global_flags], :void
239
+ attach_function :id3tag_v1_only, [:global_flags], :void
240
+ attach_function :id3tag_v2_only, [:global_flags], :void
241
+ attach_function :id3tag_space_v1, [:global_flags], :void
242
+ attach_function :id3tag_pad_v2, [:global_flags], :void
243
+ attach_function :id3tag_set_pad, [:global_flags, :size_t], :void
244
+ attach_function :id3tag_set_title, [:global_flags, :pointer], :void
245
+ attach_function :id3tag_set_artist, [:global_flags, :pointer], :void
246
+ attach_function :id3tag_set_album, [:global_flags, :pointer], :void
247
+ attach_function :id3tag_set_year, [:global_flags, :pointer], :void
248
+ attach_function :id3tag_set_comment, [:global_flags, :pointer], :void
249
+ attach_function :id3tag_set_track, [:global_flags, :pointer], :int
250
+ attach_function :id3tag_set_genre, [:global_flags, :pointer], :int
251
+ attach_function :id3tag_set_fieldvalue, [:global_flags, :pointer], :int
252
+ attach_function :id3tag_set_albumart, [:global_flags, :buffer_in, :size_t], :int
253
+ attach_function :lame_get_id3v1_tag, [:global_flags, :buffer_out, :size_t], :size_t
254
+ attach_function :lame_get_id3v2_tag, [:global_flags, :buffer_out, :size_t], :size_t
255
+ attach_function :lame_set_write_id3tag_automatic, [:global_flags, :int], :void
256
+ attach_function :lame_get_write_id3tag_automatic, [:global_flags], :int
257
+ # experimental id3:
258
+ # attach_function :id3tag_set_textinfo_latin1, [:global_flags, :string, :string], :int
259
+ # attach_function :id3tag_set_comment_latin1, [:global_flags, :string, :string, :string], :int
260
+ attach_function :id3tag_set_fieldvalue_utf16, [:global_flags, :pointer], :int
261
+ # attach_function :id3tag_set_textinfo_utf16, [:global_flags, :string, :pointer], :int
262
+ # attach_function :id3tag_set_comment_utf16, [:global_flags, :string, :pointer, :pointer], :int
263
+
264
+ # tables
265
+ attach_function :lame_get_bitrate, [:int, :int], :int
266
+ attach_function :lame_get_samplerate, [:int, :int], :int
267
+
268
+ end
269
+ end
270
+
271
+ end
272
+ end
@@ -0,0 +1,20 @@
1
+ module LAME
2
+ module FFI
3
+
4
+ # We need a ManagedStruct to clean up after LAME.
5
+ class GlobalFlags < ::FFI::ManagedStruct
6
+ layout :class_id, :uint # Not actually used, but FFI needs a layout..
7
+
8
+ def initialize
9
+ lame_struct = LAME.lame_init
10
+ super(lame_struct)
11
+ end
12
+
13
+ def self.release(ptr)
14
+ LAME.lame_close(ptr)
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+