nu_wav 0.3.1 → 0.3.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
data/lib/nu_wav.rb CHANGED
@@ -178,8 +178,7 @@ module NuWav
178
178
  wave = WaveFile.new
179
179
 
180
180
  # data chunk
181
- data = DataChunk.new
182
- data.data = file.read
181
+ data = DataChunk.new_from_file(file)
183
182
  wave.chunks[:data] = data
184
183
 
185
184
  # fmt chunk
@@ -599,6 +598,14 @@ module NuWav
599
598
 
600
599
  return chunk
601
600
  end
601
+
602
+ def self.new_from_file(file)
603
+ tmp_data = Tempfile.open('data_chunk')
604
+ tmp_data.binmode
605
+ File.copy(file.path, tmp_data.path)
606
+ tmp_data.rewind
607
+ self.new('data', File.size(file.path), tmp_data)
608
+ end
602
609
 
603
610
  def initialize(id=nil, size=nil, tmp_data_file=nil)
604
611
  @id, @size, @tmp_data_file = id, size, tmp_data_file
data/nu_wav.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nu_wav}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kookster"]
12
- s.date = %q{2011-05-28}
12
+ s.date = %q{2011-05-29}
13
13
  s.description = %q{NuWav is a pure ruby audio WAV file parser and writer. It supports Broadcast Wave Format (BWF), inclluding MPEG audio data, and the public radio standard cart chunk.}
14
14
  s.email = %q{andrew@beginsinwonder.com}
15
15
  s.extra_rdoc_files = [
data/test/test_nu_wav.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'helper'
2
2
  require 'nu_wav'
3
3
  require 'tempfile'
4
+ require 'ftools'
4
5
 
5
6
  class TestNuWav < Test::Unit::TestCase
6
7
  include NuWav
@@ -85,6 +86,12 @@ class TestNuWav < Test::Unit::TestCase
85
86
  puts "end of test: #{memory_usage/1024} mb"
86
87
  end
87
88
 
89
+ def test_from_mpeg
90
+ w = WaveFile.from_mpeg(File.expand_path(File.dirname(__FILE__) + '/files/test.mp2'))
91
+ w.to_file('test_from_mpeg.wav')
92
+ w.write_data_file('test_from_mpeg.mp2')
93
+ end
94
+
88
95
  def unpad(str)
89
96
  str.gsub(/\0*$/, '')
90
97
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nu_wav
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - kookster
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-28 00:00:00 -04:00
18
+ date: 2011-05-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency