taglib-ruby 0.6.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +1 -1
- data/{CHANGES.md → CHANGELOG.md} +46 -11
- data/README.md +61 -17
- data/Rakefile +12 -3
- data/docs/taglib/aiff.rb +95 -0
- data/docs/taglib/base.rb +30 -2
- data/docs/taglib/flac.rb +60 -4
- data/docs/taglib/id3v1.rb +29 -0
- data/docs/taglib/id3v2.rb +22 -3
- data/docs/taglib/mp4.rb +124 -13
- data/docs/taglib/mpeg.rb +30 -1
- data/docs/taglib/ogg.rb +47 -5
- data/docs/taglib/riff.rb +3 -0
- data/docs/taglib/vorbis.rb +1 -1
- data/docs/taglib/wav.rb +116 -0
- data/ext/extconf_common.rb +24 -3
- data/ext/taglib_aiff/extconf.rb +4 -0
- data/ext/taglib_aiff/taglib_aiff.i +84 -0
- data/ext/taglib_aiff/taglib_aiff_wrap.cxx +3111 -0
- data/ext/taglib_base/includes.i +34 -5
- data/ext/taglib_base/taglib_base.i +42 -2
- data/ext/taglib_base/taglib_base_wrap.cxx +226 -186
- data/ext/taglib_flac/taglib_flac.i +21 -18
- data/ext/taglib_flac/taglib_flac_wrap.cxx +519 -955
- data/ext/taglib_flac_picture/extconf.rb +4 -0
- data/ext/taglib_flac_picture/includes.i +15 -0
- data/ext/taglib_flac_picture/taglib_flac_picture.i +15 -0
- data/ext/taglib_flac_picture/taglib_flac_picture_wrap.cxx +3087 -0
- data/ext/taglib_id3v1/taglib_id3v1.i +19 -0
- data/ext/taglib_id3v1/taglib_id3v1_wrap.cxx +391 -193
- data/ext/taglib_id3v2/relativevolumeframe.i +4 -17
- data/ext/taglib_id3v2/taglib_id3v2.i +72 -2
- data/ext/taglib_id3v2/taglib_id3v2_wrap.cxx +3051 -1113
- data/ext/taglib_mp4/taglib_mp4.i +101 -20
- data/ext/taglib_mp4/taglib_mp4_wrap.cxx +1088 -282
- data/ext/taglib_mpeg/taglib_mpeg.i +11 -16
- data/ext/taglib_mpeg/taglib_mpeg_wrap.cxx +646 -317
- data/ext/taglib_ogg/taglib_ogg.i +11 -0
- data/ext/taglib_ogg/taglib_ogg_wrap.cxx +478 -192
- data/ext/taglib_vorbis/taglib_vorbis.i +8 -0
- data/ext/taglib_vorbis/taglib_vorbis_wrap.cxx +202 -156
- data/ext/taglib_wav/extconf.rb +4 -0
- data/ext/taglib_wav/taglib_wav.i +90 -0
- data/ext/taglib_wav/taglib_wav_wrap.cxx +3423 -0
- data/lib/taglib.rb +2 -0
- data/lib/taglib/aiff.rb +7 -0
- data/lib/taglib/mp4.rb +2 -1
- data/lib/taglib/version.rb +2 -2
- data/lib/taglib/wav.rb +11 -0
- data/taglib-ruby.gemspec +42 -8
- data/tasks/ext.rake +48 -20
- data/tasks/gemspec_check.rake +1 -1
- data/tasks/swig.rake +36 -2
- data/test/aiff_examples_test.rb +39 -0
- data/test/aiff_file_test.rb +103 -0
- data/test/aiff_file_write_test.rb +88 -0
- data/test/data/Makefile +8 -2
- data/test/data/aiff-sample.aiff +0 -0
- data/test/data/flac_nopic.flac +0 -0
- data/test/data/vorbis-create.cpp +20 -1
- data/test/data/vorbis.oga +0 -0
- data/test/data/wav-create.cpp +55 -0
- data/test/data/wav-dump.cpp +74 -0
- data/test/data/wav-sample.wav +0 -0
- data/test/file_test.rb +21 -0
- data/test/fileref_properties_test.rb +1 -1
- data/test/flac_file_test.rb +45 -30
- data/test/flac_picture_memory_test.rb +43 -0
- data/test/id3v1_genres_test.rb +23 -0
- data/test/id3v1_tag_test.rb +1 -0
- data/test/id3v2_frames_test.rb +64 -0
- data/test/id3v2_tag_test.rb +6 -6
- data/test/id3v2_unknown_frames_test.rb +30 -0
- data/test/id3v2_write_test.rb +10 -13
- data/test/mp4_file_test.rb +33 -4
- data/test/mp4_file_write_test.rb +5 -5
- data/test/mp4_items_test.rb +83 -29
- data/test/mpeg_file_test.rb +120 -7
- data/test/vorbis_file_test.rb +2 -2
- data/test/vorbis_tag_test.rb +61 -7
- data/test/wav_examples_test.rb +42 -0
- data/test/wav_file_test.rb +108 -0
- data/test/wav_file_write_test.rb +113 -0
- metadata +86 -56
data/docs/taglib/id3v1.rb
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
module TagLib::ID3v1
|
2
2
|
# An ID3v1 tag.
|
3
3
|
class Tag < TagLib::Tag
|
4
|
+
# @return [Integer] the genre as a number
|
5
|
+
# @return [255] if not present
|
6
|
+
#
|
7
|
+
# @since 1.0.0
|
8
|
+
attr_accessor :genre_number
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<String>] the ID3v1 genre list.
|
12
|
+
#
|
13
|
+
# @since 1.0.0
|
14
|
+
def genre_list
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Map<String, int>] the map associating a genre to its index.
|
18
|
+
#
|
19
|
+
# @since 1.0.0
|
20
|
+
def genre_map
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String] the name of genre at `index` in the ID3v1 genre list.
|
24
|
+
#
|
25
|
+
# @since 1.0.0
|
26
|
+
def genre(index)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String] the genre index for the (case sensitive) genre `name`.
|
30
|
+
#
|
31
|
+
# @since 1.0.0
|
32
|
+
def genre_index(name)
|
4
33
|
end
|
5
34
|
end
|
data/docs/taglib/id3v2.rb
CHANGED
@@ -62,8 +62,13 @@ module TagLib::ID3v2
|
|
62
62
|
# file.save
|
63
63
|
# end
|
64
64
|
class Tag < TagLib::Tag
|
65
|
-
# Get a list of frames.
|
66
|
-
#
|
65
|
+
# Get a list of frames.
|
66
|
+
#
|
67
|
+
# Note that the frames returned are subclasses of {TagLib::ID3v2::Frame},
|
68
|
+
# depending on the frame ID. But it's also possible that a
|
69
|
+
# {TagLib::ID3v2::UnknownFrame} is returned (e.g. when TagLib discards a
|
70
|
+
# deprecated frame). So to make sure your code can handle all the cases, it
|
71
|
+
# should include a check for the returned class of the frame.
|
67
72
|
#
|
68
73
|
# @overload frame_list()
|
69
74
|
# Returns all frames.
|
@@ -405,7 +410,16 @@ module TagLib::ID3v2
|
|
405
410
|
end
|
406
411
|
|
407
412
|
# Text identification frame (`T???`).
|
413
|
+
#
|
414
|
+
# @example Create a new TIT2 frame
|
415
|
+
# frame = TagLib::ID3v2::TextIdentificationFrame.new("TIT2", TagLib::String::UTF8)
|
416
|
+
# frame.text = "Title"
|
408
417
|
class TextIdentificationFrame < Frame
|
418
|
+
# @param [String] type the frame ID, e.g. `TDRC`
|
419
|
+
# @param [TagLib::String constant] encoding text encoding, e.g. `TagLib::String::UTF8`
|
420
|
+
def initialize(type, encoding)
|
421
|
+
end
|
422
|
+
|
409
423
|
# Encoding for storing the text in the tag, e.g.
|
410
424
|
# `TagLib::String::UTF8`. See the section _String Encodings_ in
|
411
425
|
# {TagLib}.
|
@@ -435,6 +449,11 @@ module TagLib::ID3v2
|
|
435
449
|
attr_accessor :owner
|
436
450
|
end
|
437
451
|
|
452
|
+
# Unknown frame used by TagLib to represent a frame whose type is not
|
453
|
+
# known, not implemented or deprecated in later versions of ID3v2.
|
454
|
+
class UnknownFrame < Frame
|
455
|
+
end
|
456
|
+
|
438
457
|
# Unsynchronized lyrics frame (`USLT`).
|
439
458
|
class UnsynchronizedLyricsFrame < Frame
|
440
459
|
# @return [String] frame description
|
@@ -459,7 +478,7 @@ module TagLib::ID3v2
|
|
459
478
|
# @param [String] value simple text to set
|
460
479
|
attr_writer :text
|
461
480
|
|
462
|
-
# @
|
481
|
+
# @return [String] the URL
|
463
482
|
attr_accessor :url
|
464
483
|
end
|
465
484
|
|
data/docs/taglib/mp4.rb
CHANGED
@@ -54,7 +54,7 @@ module TagLib::MP4
|
|
54
54
|
# # #<TagLib::MP4::Item:0x007f9bab61d818 @__swigtype__="_p_TagLib__MP4__Item">]]
|
55
55
|
class File < TagLib::File
|
56
56
|
|
57
|
-
# {include
|
57
|
+
# {include:::TagLib::FileRef.open}
|
58
58
|
#
|
59
59
|
# @param (see #initialize)
|
60
60
|
# @yield [file] the {File} object, as obtained by {#initialize}
|
@@ -82,12 +82,48 @@ module TagLib::MP4
|
|
82
82
|
# @return [TagLib::MP4::Properties]
|
83
83
|
def audio_properties
|
84
84
|
end
|
85
|
+
|
86
|
+
# @return [Boolean] Returns whether or not the file actually has an MP4 tag, or the
|
87
|
+
# file has a Metadata Item List (ilst) atom.
|
88
|
+
#
|
89
|
+
# @since 1.0.0
|
90
|
+
def mp4_tag?
|
91
|
+
end
|
85
92
|
end
|
86
93
|
|
87
94
|
class Tag < TagLib::Tag
|
88
|
-
#
|
89
|
-
#
|
90
|
-
|
95
|
+
# @return [TagLib::MP4::ItemMap] The map containing all the items in the tag.
|
96
|
+
#
|
97
|
+
# @since 1.0.0
|
98
|
+
def item_map
|
99
|
+
end
|
100
|
+
|
101
|
+
# @return [TagLib::MP4::Item] The Item associated to `key` (will be invalid in `key` does not exists).
|
102
|
+
#
|
103
|
+
# @since 1.0.0
|
104
|
+
def [](key)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Associate the `value` Item to `key`, overwriting any previous value.
|
108
|
+
# @param key [String]
|
109
|
+
# @param value [TagLib::MP4::Item]
|
110
|
+
# @return [nil]
|
111
|
+
#
|
112
|
+
# @since 1.0.0
|
113
|
+
def []=(key, value)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Remove the [TagLib::MP4::Item] associated to `key`.
|
117
|
+
# @return [nil]
|
118
|
+
#
|
119
|
+
# @since 1.0.0
|
120
|
+
def remove_item(key)
|
121
|
+
end
|
122
|
+
|
123
|
+
# @return True if the tag has an entry for `key`, false otherwise.
|
124
|
+
#
|
125
|
+
# @since 1.0.0
|
126
|
+
def contains(key)
|
91
127
|
end
|
92
128
|
end
|
93
129
|
|
@@ -109,11 +145,32 @@ module TagLib::MP4
|
|
109
145
|
def self.from_bool(value)
|
110
146
|
end
|
111
147
|
|
148
|
+
# @param [Fixnum] value
|
149
|
+
# @return [TagLib::MP4::Item]
|
150
|
+
#
|
151
|
+
# @since 1.0.0
|
152
|
+
def self.from_byte(value)
|
153
|
+
end
|
154
|
+
|
155
|
+
# @param [Boolean] value
|
156
|
+
# @return [TagLib::MP4::Item]
|
157
|
+
#
|
158
|
+
# @since 1.0.0
|
159
|
+
def self.from_uint(value)
|
160
|
+
end
|
161
|
+
|
112
162
|
# @param [Fixnum] number
|
113
163
|
# @return [TagLib::MP4::Item]
|
114
164
|
def self.from_int(number)
|
115
165
|
end
|
116
166
|
|
167
|
+
# @param [Fixnum] number
|
168
|
+
# @return [TagLib::MP4::Item]
|
169
|
+
#
|
170
|
+
# @since 1.0.0
|
171
|
+
def self.from_long_long(number)
|
172
|
+
end
|
173
|
+
|
117
174
|
# @example
|
118
175
|
# TagLib::MP4::Item.from_int_pair([4, 11])
|
119
176
|
# @param [Array<Fixnum, Fixnum>] integer_pair
|
@@ -126,18 +183,43 @@ module TagLib::MP4
|
|
126
183
|
def self.from_string_list(string_array)
|
127
184
|
end
|
128
185
|
|
186
|
+
# @param [TagLib::ByteVectorList] list
|
187
|
+
# @return [TagLib::MP4::Item]
|
188
|
+
#
|
189
|
+
# @since 1.0.0
|
190
|
+
def self.from_byte_vector_list(list)
|
191
|
+
end
|
192
|
+
|
129
193
|
# @return [Boolean]
|
130
194
|
def to_bool
|
131
195
|
end
|
132
196
|
|
133
|
-
# @return [
|
134
|
-
|
197
|
+
# @return [Fixnum]
|
198
|
+
#
|
199
|
+
# @since 1.0.0
|
200
|
+
def to_byte
|
201
|
+
end
|
202
|
+
|
203
|
+
# @return [Fixnum]
|
204
|
+
#
|
205
|
+
# @since 1.0.0
|
206
|
+
def to_uint
|
135
207
|
end
|
136
208
|
|
137
209
|
# @return [Fixnum]
|
138
210
|
def to_int
|
139
211
|
end
|
140
212
|
|
213
|
+
# @return [Fixnum]
|
214
|
+
#
|
215
|
+
# @since 1.0.0
|
216
|
+
def to_long_long
|
217
|
+
end
|
218
|
+
|
219
|
+
# @return [Array<TagLib::MP4::CoverArt>]
|
220
|
+
def to_cover_art_list
|
221
|
+
end
|
222
|
+
|
141
223
|
# @return [Array<Fixnum, Fixnum>]
|
142
224
|
def to_int_pair
|
143
225
|
end
|
@@ -146,19 +228,25 @@ module TagLib::MP4
|
|
146
228
|
def to_string_list
|
147
229
|
end
|
148
230
|
|
231
|
+
# @return [TagLib::ByteVectorList]
|
232
|
+
#
|
233
|
+
# @since 1.0.0
|
234
|
+
def to_byte_vector_list
|
235
|
+
end
|
236
|
+
|
149
237
|
# @return [Boolean]
|
150
238
|
def valid?
|
151
239
|
end
|
152
240
|
end
|
153
241
|
|
154
|
-
# The underlying C++-structure of `
|
155
|
-
# Consequently, `
|
156
|
-
# places: the C++ memory management strategies of
|
242
|
+
# The underlying C++-structure of `ItemMap` inherits from `std::map`.
|
243
|
+
# Consequently, `ItemMap` behaves differently from a Ruby hash in a few
|
244
|
+
# places: the C++ memory management strategies of ItemMap can lead to
|
157
245
|
# a situation where a Ruby object refers to a location in memory that was
|
158
246
|
# freed by C++. To prevent Ruby from crashing on us with a segmentation
|
159
247
|
# fault, we raise an `ObjectPreviouslyDeleted` exception when we try to access
|
160
248
|
# data that is no longer available.
|
161
|
-
class
|
249
|
+
class ItemMap
|
162
250
|
# Return the Item under `key`, or `nil` if no Item is present.
|
163
251
|
# @param [String] key
|
164
252
|
# @return [TagLib::MP4::Item]
|
@@ -235,10 +323,30 @@ module TagLib::MP4
|
|
235
323
|
# @return [Array<Array<String, TagLib::MP4::Item>>]
|
236
324
|
def to_a
|
237
325
|
end
|
326
|
+
|
327
|
+
# Convert self into an hash.
|
328
|
+
# @return [Hash<String, TagLib::MP4::Item>]
|
329
|
+
#
|
330
|
+
# @since 1.0.0
|
331
|
+
def to_h
|
332
|
+
end
|
238
333
|
end
|
239
334
|
#
|
240
335
|
class Properties < TagLib::AudioProperties
|
241
|
-
|
336
|
+
Unknown = 0
|
337
|
+
AAC = 1
|
338
|
+
ALAC = 2
|
339
|
+
|
340
|
+
# @return [Integer] The number of bits per audio sample.
|
341
|
+
attr_reader :bits_per_sample
|
342
|
+
|
343
|
+
# @return [Boolean] Whether or not the file is encrypted.
|
344
|
+
attr_reader :encrypted?
|
345
|
+
|
346
|
+
# @return [Integer] The codec used in the file.
|
347
|
+
#
|
348
|
+
# @since 1.0.0
|
349
|
+
attr_reader :codec
|
242
350
|
end
|
243
351
|
|
244
352
|
# The `CoverArt` class is used to embed cover art images in MP4 tags.
|
@@ -247,8 +355,11 @@ module TagLib::MP4
|
|
247
355
|
# image_data = File.open('cover_art.jpeg', 'rb') { |f| f.read }
|
248
356
|
# cover_art = TagLib::MP4::CoverArt.new(TagLib::MP4::CoverArt::JPEG, image_data)
|
249
357
|
class CoverArt
|
250
|
-
|
251
|
-
|
358
|
+
Unknown = 0x00
|
359
|
+
JPEG = 0x0D
|
360
|
+
PNG = 0x0E
|
361
|
+
BMP = 0x1B
|
362
|
+
GIF = 0x0C # Deprecated
|
252
363
|
|
253
364
|
# Returns the format of the image data: `JPEG` or `PNG`.
|
254
365
|
# @return [Fixnum]
|
data/docs/taglib/mpeg.rb
CHANGED
@@ -14,7 +14,7 @@ module TagLib::MPEG
|
|
14
14
|
APE = 0x0004
|
15
15
|
AllTags = 0xffff
|
16
16
|
|
17
|
-
# {include
|
17
|
+
# {include:::TagLib::FileRef.open}
|
18
18
|
#
|
19
19
|
# @param (see #initialize)
|
20
20
|
# @yield [file] the {File} object, as obtained by {#initialize}
|
@@ -103,6 +103,24 @@ module TagLib::MPEG
|
|
103
103
|
# @return [Boolean] whether stripping was successful
|
104
104
|
def strip(tags=TagLib::MPEG::File::AllTags)
|
105
105
|
end
|
106
|
+
|
107
|
+
# @return [Boolean] Whether or not the file on disk actually has an ID3v1 tag.
|
108
|
+
#
|
109
|
+
# @since 1.0.0
|
110
|
+
def id3v1_tag?
|
111
|
+
end
|
112
|
+
|
113
|
+
# @return [Boolean] Whether or not the file on disk actually has an ID3v2 tag.
|
114
|
+
#
|
115
|
+
# @since 1.0.0
|
116
|
+
def id3v2_tag?
|
117
|
+
end
|
118
|
+
|
119
|
+
# @return [Boolean] Whether or not the file on disk actually has an APE tag.
|
120
|
+
#
|
121
|
+
# @since 1.0.0
|
122
|
+
def ape_tag?
|
123
|
+
end
|
106
124
|
end
|
107
125
|
|
108
126
|
# Audio properties for MPEG files.
|
@@ -153,6 +171,11 @@ module TagLib::MPEG
|
|
153
171
|
|
154
172
|
# Xing VBR header.
|
155
173
|
class XingHeader
|
174
|
+
|
175
|
+
Invalid = 0
|
176
|
+
Xing = 1
|
177
|
+
VBRI = 2
|
178
|
+
|
156
179
|
# @return [true] if a valid Xing header is present
|
157
180
|
def valid?
|
158
181
|
end
|
@@ -164,5 +187,11 @@ module TagLib::MPEG
|
|
164
187
|
# @return [Integer] total size of stream in bytes
|
165
188
|
def total_size
|
166
189
|
end
|
190
|
+
|
191
|
+
# @return [Integer] the type of the VBR header.
|
192
|
+
#
|
193
|
+
# @since 1.0.0
|
194
|
+
def type
|
195
|
+
end
|
167
196
|
end
|
168
197
|
end
|
data/docs/taglib/ogg.rb
CHANGED
@@ -29,10 +29,9 @@ module TagLib::Ogg
|
|
29
29
|
def contains?(name)
|
30
30
|
end
|
31
31
|
|
32
|
-
# Count the number of fields.
|
32
|
+
# Count the number of fields (including the pictures).
|
33
33
|
#
|
34
|
-
# @return [Integer] the number of fields in the comment (name-value
|
35
|
-
# pairs)
|
34
|
+
# @return [Integer] the number of fields in the comment (name-value pairs)
|
36
35
|
def field_count
|
37
36
|
end
|
38
37
|
|
@@ -44,7 +43,7 @@ module TagLib::Ogg
|
|
44
43
|
# 'GENRE' => ["Rock", "Pop"] }
|
45
44
|
#
|
46
45
|
# Note that the returned hash is read-only. Changing it will have no
|
47
|
-
# effect on the comment; use {#add_field} and {#
|
46
|
+
# effect on the comment; use {#add_field} and {#remove_fields} for
|
48
47
|
# that.
|
49
48
|
#
|
50
49
|
# @return [Hash<String, Array<String>>] a hash from field names to
|
@@ -66,7 +65,50 @@ module TagLib::Ogg
|
|
66
65
|
# @param [String] value field value
|
67
66
|
#
|
68
67
|
# @return [void]
|
69
|
-
|
68
|
+
#
|
69
|
+
# @since 1.0.0
|
70
|
+
def remove_fields
|
71
|
+
end
|
72
|
+
|
73
|
+
# Remove all the fields.
|
74
|
+
#
|
75
|
+
# @since 1.0.0
|
76
|
+
def remove_all_fields
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [Boolean] True if the specified string is a valid Xiph comment key.
|
80
|
+
#
|
81
|
+
# @since 1.0.0
|
82
|
+
def self.check_key(key)
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Array<TagLib::FLAC::Picture>] The list of the pictures associated to this comment.
|
86
|
+
#
|
87
|
+
# @since 1.0.0
|
88
|
+
def picture_list
|
89
|
+
end
|
90
|
+
|
91
|
+
# Add a picture.
|
92
|
+
# @param [TagLib::FLAC::Picture] picture
|
93
|
+
# @return [void]
|
94
|
+
#
|
95
|
+
# @since 1.0.0
|
96
|
+
def add_picture(picture)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Remove a picture.
|
100
|
+
# @param [TagLib::FLAC::Picture] picture
|
101
|
+
# @return [void]
|
102
|
+
#
|
103
|
+
# @since 1.0.0
|
104
|
+
def remove_picture(picture)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Remove all the pictures.
|
108
|
+
# @return [void]
|
109
|
+
#
|
110
|
+
# @since 1.0.0
|
111
|
+
def remove_all_pictures
|
70
112
|
end
|
71
113
|
|
72
114
|
# @return [String] vendor ID of the encoder used
|
data/docs/taglib/riff.rb
ADDED
data/docs/taglib/vorbis.rb
CHANGED
data/docs/taglib/wav.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# @since 0.7.0
|
2
|
+
module TagLib::RIFF::WAV
|
3
|
+
|
4
|
+
FORMAT_UNKNOWN = 0x0000 # @since 1.0.0
|
5
|
+
FORMAT_PCM = 0x0001 # @since 1.0.0
|
6
|
+
|
7
|
+
# The file class for `.wav` files.
|
8
|
+
#
|
9
|
+
# @example Reading the title
|
10
|
+
# title = TagLib::RIFF::WAV::File.open("sample.wav") do |file|
|
11
|
+
# file.tag.title
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# @example Reading WAV-specific audio properties
|
15
|
+
# TagLib::RIFF::WAV::File.open("sample.wav") do |file|
|
16
|
+
# file.audio_properties.sample_width #=> 16
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# @example Saving ID3v2 cover-art to disk
|
20
|
+
# TagLib::RIFF::WAV::File.open("sample.wav") do |file|
|
21
|
+
# id3v2_tag = file.tag
|
22
|
+
# cover = id3v2_tag.frame_list('APIC').first
|
23
|
+
# ext = cover.mime_type.rpartition('/')[2]
|
24
|
+
# File.open("cover-art.#{ext}", "wb") { |f| f.write cover.picture }
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# @see ID3v2::Tag ID3v2 examples.
|
28
|
+
#
|
29
|
+
class File < TagLib::File
|
30
|
+
|
31
|
+
NoTags = 0x0000
|
32
|
+
ID3v1 = 0x0001
|
33
|
+
ID3v2 = 0x0002
|
34
|
+
APE = 0x0004
|
35
|
+
AllTags = 0xffff
|
36
|
+
|
37
|
+
# {include:::TagLib::FileRef.open}
|
38
|
+
#
|
39
|
+
# @param (see #initialize)
|
40
|
+
# @yield [file] the {File} object, as obtained by {#initialize}
|
41
|
+
# @return the return value of the block
|
42
|
+
#
|
43
|
+
def self.open(filename, read_properties=true)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Load a WAV file.
|
47
|
+
#
|
48
|
+
# @param [String] filename
|
49
|
+
# @param [Boolean] read_properties if audio properties should be
|
50
|
+
# read
|
51
|
+
def initialize(filename, read_properties=true)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the ID3v2 tag.
|
55
|
+
#
|
56
|
+
# @return [TagLib::ID3v2::Tag]
|
57
|
+
def tag
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the ID3v2 tag.
|
61
|
+
#
|
62
|
+
# @return [TagLib::ID3v2::Tag]
|
63
|
+
#
|
64
|
+
# @since 1.0.0
|
65
|
+
def id3v2_tag
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns audio properties.
|
69
|
+
#
|
70
|
+
# @return [TagLib::RIFF::WAV::Properties]
|
71
|
+
def audio_properties
|
72
|
+
end
|
73
|
+
|
74
|
+
# Remove the tags matching the specified OR-ed types.
|
75
|
+
#
|
76
|
+
# @param [int] tags The types of tags to remove.
|
77
|
+
# @return [void]
|
78
|
+
#
|
79
|
+
# @since 1.0.0
|
80
|
+
def strip(tags=TagLib::RIFF::WAV::File::AllTags)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
class Properties < TagLib::AudioProperties
|
86
|
+
# @return [Integer] Number of bits per audio sample.
|
87
|
+
#
|
88
|
+
# @since 1.0.0
|
89
|
+
attr_reader :bits_per_sample
|
90
|
+
|
91
|
+
# @return [Integer] Number of sample frames.
|
92
|
+
#
|
93
|
+
# @since 1.0.0
|
94
|
+
attr_reader :sample_frames
|
95
|
+
|
96
|
+
# @return [Integer] length of the file in seconds
|
97
|
+
#
|
98
|
+
# @since 1.0.0
|
99
|
+
attr_reader :length_in_seconds
|
100
|
+
|
101
|
+
# @return [Integer] length of the file in milliseconds
|
102
|
+
#
|
103
|
+
# @since 1.0.0
|
104
|
+
attr_reader :length_in_milliseconds
|
105
|
+
|
106
|
+
# @return [Integer] The format ID of the file.
|
107
|
+
#
|
108
|
+
# 0 for unknown, 1 for PCM, 2 for ADPCM, 3 for 32/64-bit IEEE754, and
|
109
|
+
# so forth. For further information, refer to the WAVE Form
|
110
|
+
# Registration Numbers in RFC 2361.
|
111
|
+
#
|
112
|
+
# @since 1.0.0
|
113
|
+
attr_reader :format
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|