lamer 0.1.2 → 1.0.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.
@@ -1,161 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "A high-quality VBR encoder without a file" do
4
-
5
- before(:each) do
6
- @la = Lamer.new
7
- @la.vbr_quality 4
8
- @la.sample_rate 44.1
9
- end
10
-
11
- it "should ouput the correct command line options" do
12
- [ /-v/,/-V 4/,/--resample 44\.1/].each do |match|
13
- @la.argument_list.should =~ match
14
- end
15
- end
16
-
17
- it "should balk at returning the command line" do
18
- lambda {@la.command_line}.should raise_error(ArgumentError)
19
- end
20
-
21
- it "should balk at running the conversion" do
22
- lambda {@la.convert!}.should raise_error(ArgumentError)
23
- end
24
-
25
- end
26
-
27
- describe "An encoder with a file specified" do
28
-
29
- before(:each) do
30
- @la = Lamer.new
31
- @la.input_file "/Path/to/my/audio_file.wav"
32
- end
33
-
34
- it "should provide the right command line" do
35
- @la.command_line.should == "lame /Path/to/my/audio_file.wav"
36
- end
37
-
38
- end
39
-
40
- describe "An encoder with options and an input and output file specified" do
41
-
42
- before(:each) do
43
- @la = Lamer.new
44
- @la.encode_quality :high
45
- @la.input_file "/Path/to/my/audio_file.wav"
46
- @la.output_file "/Path/to/my/audio_file.mp3"
47
- end
48
-
49
- it "should provide the right command line" do
50
- @la.command_line.should == "lame -q 2 /Path/to/my/audio_file.wav /Path/to/my/audio_file.mp3"
51
- end
52
-
53
- end
54
-
55
- describe "An encoder sent various id3 information" do
56
-
57
- before(:each) do
58
- @la = Lamer.new
59
- end
60
-
61
- it "should set the title" do
62
- @la.id3 :title => "The All-Knowning Mind of Minolta"
63
- @la.id3_options[:title].should == "The All-Knowning Mind of Minolta"
64
- @la.id3_arguments.should == "--tt The All-Knowning Mind of Minolta"
65
- end
66
-
67
- it "should set multiple values" do
68
- @la.id3 :title => "The All-Knowning Mind of Minolta"
69
- @la.id3 :artist => "Tin Man Shuffler"
70
- @la.id3_options[:title].should == "The All-Knowning Mind of Minolta"
71
- @la.id3_options[:artist].should == "Tin Man Shuffler"
72
- @la.id3_arguments.should =~ /--tt The All-Knowning Mind of Minolta/
73
- @la.id3_arguments.should =~ /--ta Tin Man Shuffler/
74
- end
75
-
76
- it "should set the title, artist, album, year, comment, track number, and genre" do
77
- @la.id3 :title => 'title', :artist => 'artist', :album => 'album',
78
- :year => 1998, :comment => 'comment', :track_number => 1,
79
- :genre => 'genre'
80
- [/--tt title/,/--ta artist/, /--tl album/,/--ty 1998/,/--tc comment/,/--tn 1/,/--tg genre/].each do |match|
81
- @la.id3_arguments.should =~ match
82
- end
83
- end
84
-
85
- it "should ignore nonsense values" do
86
- @la.id3 :bugz => "Not Real"
87
- @la.id3_arguments.should_not =~ /Real/
88
- @la.id3 :title => "Coolbeans"
89
- @la.id3_arguments.should =~ /Coolbeans/
90
- end
91
-
92
- it "should add v1 or v2 id3 tags as requested" do
93
- 2.times do |n|
94
- @la.id3_version_only n
95
- @la.options[:id3_version].should == "--id3v#{n}-only"
96
- end
97
- end
98
-
99
- it "should allow adding v2 tags on top of default behaviour" do
100
- @la.id3_add_v2!
101
- @la.options[:id3_version].should == "--add-id3v2"
102
- end
103
-
104
- it "should not output id3_version unless tags are set" do
105
- @la.id3_version_only 1
106
- @la.argument_list.should == ""
107
- end
108
-
109
- describe "An encoder with id3 options and an input file" do
110
- before(:each) do
111
- @la = Lamer.new
112
- @la.id3 :title => 'title', :artist => 'artist', :album => 'album',
113
- :year => 1998, :comment => 'comment', :track_number => 1,
114
- :genre => 'genre'
115
- @la.input_file File.join( File.dirname( __FILE__ ), 'test.mp3' )
116
- end
117
-
118
- it "should output those options to the command line" do
119
- [/--tt title/,/--ta artist/, /--tl album/,/--ty 1998/,/--tc comment/,/--tn 1/,/--tg genre/].each do |match|
120
- @la.command_line.should =~ match
121
- end
122
- end
123
- end
124
-
125
- describe "An encoder starting with an mp3 file" do
126
- before(:each) do
127
- @root = './spec/'
128
- begin
129
- File.delete File.join( File.dirname( __FILE__ ), 'output.mp3' )
130
- rescue
131
- end
132
- @la = Lamer.new
133
- @la.input_file "#{@root}test.mp3"
134
- @la.output_file "#{@root}output.mp3"
135
- @la.input_mp3!
136
- end
137
-
138
- it "should provide the right command line" do
139
- [/lame/,/--mp3input/, /-o/,/#{@root}test.mp3/,/#{@root}output.mp3/].each do |match|
140
- @la.command_line.should =~ match
141
- end
142
- end
143
-
144
- it "should successfully output a low bitrate version" do
145
- @la.bitrate 32
146
- @la.mode :mono
147
- File.exists?("#{@root}output.mp3").should == false
148
- @la.convert!
149
- File.exists?("#{@root}output.mp3").should == true
150
- end
151
- end
152
-
153
- describe "The runtime environment" do
154
- it "should have lame version 3.9x installed" do
155
- version = `lame --help`
156
- version.should =~ /LAME/
157
- version.should =~ /3\.9+/
158
- end
159
- end
160
-
161
- end
data/spec/lamer_spec.rb DELETED
@@ -1,126 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "A new Lamer" do
4
-
5
- before(:each) do
6
- @la = Lamer.new
7
- end
8
-
9
- it "should have a blank argument list" do
10
- @la.argument_list.empty?.should == true
11
- end
12
-
13
- it "should record valid bitrates" do
14
- @la.bitrate 128
15
- @la.options[:bitrate].should == "-b 128"
16
- end
17
-
18
- it "should record valid sample rates" do
19
- @la.sample_rate 44.1
20
- @la.options[:sample_rate].should == "--resample 44.1"
21
- end
22
-
23
- it "should record valid VBR quality" do
24
- @la.vbr_quality 5
25
- @la.options[:vbr_quality].should == "-V 5"
26
- @la.options[:vbr].should == "-v"
27
- end
28
-
29
- it "should record valid quality" do
30
- @la.encode_quality 1
31
- @la.options[:encode_quality].should == "-q 1"
32
- end
33
-
34
- it "should record valid quality" do
35
- @la.encode_quality 5
36
- @la.options[:encode_quality].should == "-q 5"
37
- end
38
-
39
- it "should record valid quality shortcut" do
40
- @la.encode_quality :high
41
- @la.options[:encode_quality].should == "-q 2"
42
- @la.encode_quality :fast
43
- @la.options[:encode_quality].should == "-q 7"
44
- end
45
-
46
- it "should balk at invalid bitrates" do
47
- lambda {@la.bitrate 113}.should raise_error(ArgumentError)
48
- end
49
-
50
- it "should balk at invalid sample rates" do
51
- lambda {@la.sample_rate 113}.should raise_error(ArgumentError)
52
- end
53
-
54
- it "should balk at invalid VBR qualities" do
55
- lambda {@la.vbr_quality 113}.should raise_error(ArgumentError)
56
- end
57
-
58
- it "should balk at invalid encode qualities" do
59
- lambda {@la.encode_quality 113}.should raise_error(ArgumentError)
60
- end
61
-
62
- it "should set mode to stereo or mono" do
63
- {:stereo => '-m s', :mono => '-m m', :joint => '-m j'}.each do |option, setting|
64
- @la.mode option
65
- @la.options[:mode].should == setting
66
- end
67
- end
68
-
69
- it "should set mode to nil on bad option" do
70
- @la.mode :bugz
71
- @la.options[:mode].should == nil
72
- end
73
-
74
- it "should accept flag that input is mp3" do
75
- @la.input_mp3!
76
- @la.options[:input_mp3].should == "--mp3input"
77
- end
78
-
79
- it "should accept an input filename" do
80
- @la.input_file "/Path/to/my/audio_file.wav"
81
- @la.command_line.should == "lame /Path/to/my/audio_file.wav"
82
- end
83
-
84
- it "should accept replygain options" do
85
- {:accurate => "--replaygain-accurate",
86
- :fast => "--replaygain-fast",
87
- :none => "--noreplaygain",
88
- :clip_detect => "--clipdetect",
89
- :default => nil
90
- }.each do |option, setting|
91
- @la.replay_gain option
92
- @la.options[:replay_gain].should == setting
93
- end
94
- end
95
-
96
- it "should accept raw PCM files" do
97
- @la.input_raw 44.1
98
- @la.options[:input_raw].should == "-r -s 44.1"
99
- @la.input_raw 32, true
100
- @la.options[:input_raw].should == "-r -s 32 -x"
101
- end
102
-
103
- it "should mark as copy when requested" do
104
- @la.mark_as_copy!
105
- @la.options[:copy].should == "-o"
106
- end
107
- it "should mark as copy when starting from a file ending in .mp3" do
108
- @la.input_file "/Path/to/my/audio_file.mp3"
109
- @la.options[:copy].should == "-o"
110
- end
111
- it "should mark as copy when starting from an mp3 file" do
112
- @la.input_mp3!
113
- @la.options[:copy].should == "-o"
114
- end
115
- it "should not mark as copy when starting from a file not ending in .mp3" do
116
- @la.input_file "/Path/to/my/audio_file.aif"
117
- @la.options[:copy].should == nil
118
- end
119
-
120
- it "should output ogg files when requested" do
121
- @la.output_ogg!
122
- @la.options[:output_ogg].should == "--ogg"
123
- end
124
-
125
- end
126
-
data/spec/output.mp3 DELETED
Binary file
data/spec/spec_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'rubygems'
2
-
3
- def smart_require(lib_name, gem_name, gem_version = '>= 0.0.0')
4
- begin
5
- require lib_name if lib_name
6
- rescue LoadError
7
- if gem_name
8
- gem gem_name, gem_version
9
- require lib_name if lib_name
10
- end
11
- end
12
- end
13
-
14
- smart_require 'spec', 'spec', '>= 1.2.6'
15
-
16
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/lamer'))
data/spec/test.mp3 DELETED
Binary file