nu_wav 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nu_wav/chunk.rb +8 -8
- data/lib/nu_wav/version.rb +1 -1
- data/lib/nu_wav/wave_file.rb +3 -3
- data/test/files/test_odd.mp2 +0 -0
- data/test/test_nu_wav.rb +25 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c30891ab0c891a3979c1941e18e9c12a1bbd440
|
4
|
+
data.tar.gz: 96f2fc0f82f3fcd1bb82b8fa4a88292e2bbb1da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877cb25d33a3679a51a2f7c229628536b7696efeb1385639af751b82b05c11a2fca5e443cddd5217d12c6f287261c6e81212cf8d112b70cb4e7849439ab472e2
|
7
|
+
data.tar.gz: ebc5112bf96fee32b4851cd0e1c09a1ea3fe65dda6c5b87aed483bdd7579fc8d8366920136e9b0162e2919ed0fb78611479a3e2d9d6dd9c442e95f35ef358063
|
data/lib/nu_wav/chunk.rb
CHANGED
@@ -49,7 +49,7 @@ module NuWav
|
|
49
49
|
out
|
50
50
|
end
|
51
51
|
|
52
|
-
def to_binary
|
52
|
+
def to_binary(options={})
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -94,7 +94,7 @@ module NuWav
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def to_binary
|
97
|
+
def to_binary(options={})
|
98
98
|
out = ''
|
99
99
|
out += write_word(@compression_code)
|
100
100
|
out += write_word(@number_of_channels)
|
@@ -138,7 +138,7 @@ module NuWav
|
|
138
138
|
"<chunk type:fact samples_number:#{@samples_number} />"
|
139
139
|
end
|
140
140
|
|
141
|
-
def to_binary
|
141
|
+
def to_binary(options={})
|
142
142
|
"fact" + write_dword(4) + write_dword(@samples_number)
|
143
143
|
end
|
144
144
|
|
@@ -159,7 +159,7 @@ module NuWav
|
|
159
159
|
"<chunk type:mext sound_information:(#{sound_information}) #{(0..15).inject(''){|s,x| "#{s}#{sound_information[x]}"}}, frame_size:#{frame_size}, ancillary_data_length:#{ancillary_data_length}, ancillary_data_def:#{(0..15).inject(''){|s,x| "#{s}#{ancillary_data_def[x]}"}}, reserved:'#{reserved}' />"
|
160
160
|
end
|
161
161
|
|
162
|
-
def to_binary
|
162
|
+
def to_binary(options={})
|
163
163
|
out = "mext" + write_dword(12)
|
164
164
|
out += write_word(@sound_information)
|
165
165
|
out += write_word(@frame_size)
|
@@ -192,7 +192,7 @@ module NuWav
|
|
192
192
|
"<chunk type:bext description:'#{description}', originator:'#{originator}', originator_reference:'#{originator_reference}', origination_date:'#{origination_date}', origination_time:'#{origination_time}', time_reference_low:#{time_reference_low}, time_reference_high:#{time_reference_high}, version:#{version}, umid:#{umid}, reserved:'#{reserved}', coding_history:#{coding_history} />"
|
193
193
|
end
|
194
194
|
|
195
|
-
def to_binary
|
195
|
+
def to_binary(options={})
|
196
196
|
out = "bext" + write_dword(602 + @coding_history.length )
|
197
197
|
out += write_char(@description, 256)
|
198
198
|
out += write_char(@originator, 32)
|
@@ -242,7 +242,7 @@ module NuWav
|
|
242
242
|
"<chunk type:cart version:#{version}, title:#{title}, artist:#{artist}, cut_id:#{cut_id}, client_id:#{client_id}, category:#{category}, classification:#{classification}, out_cue:#{out_cue}, start_date:#{start_date}, start_time:#{start_time}, end_date:#{end_date}, end_time:#{end_time}, producer_app_id:#{producer_app_id}, producer_app_version:#{producer_app_version}, user_def:#{user_def}, level_reference:#{level_reference}, post_timer:#{post_timer}, reserved:#{reserved}, url:#{url}, tag_text:#{tag_text} />"
|
243
243
|
end
|
244
244
|
|
245
|
-
def to_binary
|
245
|
+
def to_binary(options={})
|
246
246
|
out = "cart" + write_dword(2048 + @tag_text.length )
|
247
247
|
out += write_char(@version,4)
|
248
248
|
out += write_char(@title,64)
|
@@ -319,12 +319,12 @@ module NuWav
|
|
319
319
|
"<chunk type:data (size:#{data.size})/>"
|
320
320
|
end
|
321
321
|
|
322
|
-
def to_binary
|
322
|
+
def to_binary(options={})
|
323
323
|
NuWav::WaveFile.log "data chunk to_binary"
|
324
324
|
d = self.data
|
325
325
|
NuWav::WaveFile.log "got data size = #{d.size} #{d[0,10]}"
|
326
326
|
out = "data" + write_dword(d.size) + d
|
327
|
-
if d.size.odd?
|
327
|
+
if d.size.odd? && !options[:no_pad_byte]
|
328
328
|
NuWav::WaveFile.log "odd, adding a pad byte"
|
329
329
|
out += "\0"
|
330
330
|
end
|
data/lib/nu_wav/version.rb
CHANGED
data/lib/nu_wav/wave_file.rb
CHANGED
@@ -104,8 +104,8 @@ module NuWav
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def to_file(file_name,
|
108
|
-
if add_extension && !(file_name =~ /\.wav/)
|
107
|
+
def to_file(file_name, options={})
|
108
|
+
if options[:add_extension] && !(file_name =~ /\.wav/)
|
109
109
|
file_name += ".wav"
|
110
110
|
end
|
111
111
|
NuWav::WaveFile.log "NuWav::WaveFile.to_file: file_name = #{file_name}"
|
@@ -113,7 +113,7 @@ module NuWav
|
|
113
113
|
#get all the chunks together to get final length
|
114
114
|
chunks_out = [:fmt, :fact, :mext, :bext, :cart, :data].inject([]) do |list, chunk|
|
115
115
|
if self.chunks[chunk]
|
116
|
-
out = self.chunks[chunk].to_binary
|
116
|
+
out = self.chunks[chunk].to_binary(options)
|
117
117
|
NuWav::WaveFile.log out.length
|
118
118
|
list << out
|
119
119
|
end
|
Binary file
|
data/test/test_nu_wav.rb
CHANGED
@@ -98,15 +98,34 @@ class TestNuWav < Test::Unit::TestCase
|
|
98
98
|
assert File.exists?('test_from_mpeg.wav')
|
99
99
|
assert_equal File.size('test_from_mpeg.wav'), 182522
|
100
100
|
File.delete('test_from_mpeg.wav')
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_from_mpeg_no_pad
|
104
|
+
w = WaveFile.from_mpeg(File.expand_path(File.dirname(__FILE__) + '/files/test_odd.mp2'))
|
101
105
|
|
106
|
+
File.delete('test_no_pad.wav') rescue nil
|
107
|
+
w.to_file('test_no_pad.wav')
|
108
|
+
assert File.exists?('test_no_pad.wav')
|
109
|
+
assert_equal File.size('test_no_pad.wav'), 962226
|
110
|
+
File.delete('test_no_pad.wav')
|
102
111
|
|
103
|
-
File.delete('
|
104
|
-
w.
|
105
|
-
assert File.exists?('
|
106
|
-
assert_equal File.size('
|
107
|
-
File.delete('
|
112
|
+
File.delete('test_no_pad.wav') rescue nil
|
113
|
+
w.to_file('test_no_pad.wav', {:no_pad_byte=>true})
|
114
|
+
assert File.exists?('test_no_pad.wav')
|
115
|
+
assert_equal File.size('test_no_pad.wav'), 962225
|
116
|
+
File.delete('test_no_pad.wav')
|
108
117
|
end
|
109
|
-
|
118
|
+
|
119
|
+
def test_write_data_file
|
120
|
+
w = WaveFile.from_mpeg(File.expand_path(File.dirname(__FILE__) + '/files/test.mp2'))
|
121
|
+
|
122
|
+
File.delete('test_write_data_file.mp2') rescue nil
|
123
|
+
w.write_data_file('test_write_data_file.mp2')
|
124
|
+
assert File.exists?('test_write_data_file.mp2')
|
125
|
+
assert_equal File.size('test_write_data_file.mp2'), 179712
|
126
|
+
File.delete('test_write_data_file.mp2')
|
127
|
+
end
|
128
|
+
|
110
129
|
def unpad(str)
|
111
130
|
str.gsub(/\0*$/, '')
|
112
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nu_wav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kuklewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-mp3info
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- test/files/test.mp2
|
75
75
|
- test/files/test_basic.wav
|
76
76
|
- test/files/test_bwf.wav
|
77
|
+
- test/files/test_odd.mp2
|
77
78
|
- test/helper.rb
|
78
79
|
- test/test_nu_wav.rb
|
79
80
|
homepage: http://github.com/kookster/nu_wav
|
@@ -104,5 +105,6 @@ test_files:
|
|
104
105
|
- test/files/test.mp2
|
105
106
|
- test/files/test_basic.wav
|
106
107
|
- test/files/test_bwf.wav
|
108
|
+
- test/files/test_odd.mp2
|
107
109
|
- test/helper.rb
|
108
110
|
- test/test_nu_wav.rb
|