scissor 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scissor/fragment.rb +46 -27
- data/lib/scissor/tape.rb +19 -14
- data/lib/scissor/writer.rb +4 -0
- data/scissor.gemspec +1 -1
- data/spec/fragment_spec.rb +6 -0
- data/spec/scissor_spec.rb +7 -0
- metadata +61 -22
- data/VERSION +0 -1
data/lib/scissor/fragment.rb
CHANGED
@@ -2,15 +2,16 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Scissor
|
4
4
|
class Fragment
|
5
|
-
attr_reader :filename, :start, :pitch
|
5
|
+
attr_reader :filename, :start, :pitch, :pan
|
6
6
|
|
7
|
-
def initialize(filename, start, duration, reverse = false, pitch = 100, stretch = false)
|
7
|
+
def initialize(filename, start, duration, reverse = false, pitch = 100, stretch = false, pan = 50)
|
8
8
|
@filename = Pathname.new(filename).realpath
|
9
9
|
@start = start
|
10
10
|
@duration = duration
|
11
11
|
@reverse = reverse
|
12
12
|
@pitch = pitch
|
13
13
|
@is_stretched = stretch
|
14
|
+
@pan = pan
|
14
15
|
|
15
16
|
freeze
|
16
17
|
end
|
@@ -32,37 +33,55 @@ module Scissor
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def create(remaining_start, remaining_length)
|
35
|
-
new_fragment = nil
|
36
|
-
|
37
36
|
if remaining_start >= duration
|
38
|
-
remaining_start
|
37
|
+
return [nil, remaining_start - duration, remaining_length]
|
38
|
+
end
|
39
|
+
|
40
|
+
have_remain_to_return = (remaining_start + remaining_length) >= duration
|
41
|
+
|
42
|
+
if have_remain_to_return
|
43
|
+
new_length = duration - remaining_start
|
44
|
+
remaining_length -= new_length
|
39
45
|
else
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
new_length = remaining_length
|
47
|
+
remaining_length = 0
|
48
|
+
end
|
49
|
+
|
50
|
+
new_fragment = clone do |attributes|
|
51
|
+
attributes.update(
|
52
|
+
:start => start + remaining_start * pitch.to_f / 100,
|
53
|
+
:duration => new_length * pitch.to_f / 100,
|
54
|
+
:reverse => false
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
return [new_fragment, 0, remaining_length]
|
59
|
+
end
|
48
60
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
61
|
+
def clone(&block)
|
62
|
+
attributes = {
|
63
|
+
:filename => filename,
|
64
|
+
:start => start,
|
65
|
+
:duration => original_duration,
|
66
|
+
:reverse => reversed?,
|
67
|
+
:pitch => pitch,
|
68
|
+
:stretch => stretched?,
|
69
|
+
:pan => pan
|
70
|
+
}
|
59
71
|
|
60
|
-
|
61
|
-
|
62
|
-
end
|
72
|
+
if block_given?
|
73
|
+
block.call(attributes)
|
63
74
|
end
|
64
75
|
|
65
|
-
|
76
|
+
self.class.new(
|
77
|
+
attributes[:filename],
|
78
|
+
attributes[:start],
|
79
|
+
attributes[:duration],
|
80
|
+
attributes[:reverse],
|
81
|
+
attributes[:pitch],
|
82
|
+
attributes[:stretch],
|
83
|
+
attributes[:pan]
|
84
|
+
)
|
66
85
|
end
|
67
86
|
end
|
68
87
|
end
|
data/lib/scissor/tape.rb
CHANGED
@@ -170,13 +170,9 @@ module Scissor
|
|
170
170
|
new_instance = self.class.new
|
171
171
|
|
172
172
|
@fragments.reverse.each do |fragment|
|
173
|
-
new_instance.add_fragment(
|
174
|
-
fragment.
|
175
|
-
|
176
|
-
fragment.original_duration,
|
177
|
-
!fragment.reversed?,
|
178
|
-
fragment.pitch,
|
179
|
-
fragment.stretched?))
|
173
|
+
new_instance.add_fragment(fragment.clone do |attributes|
|
174
|
+
attributes[:reverse] = !fragment.reversed?
|
175
|
+
end)
|
180
176
|
end
|
181
177
|
|
182
178
|
new_instance
|
@@ -186,13 +182,10 @@ module Scissor
|
|
186
182
|
new_instance = self.class.new
|
187
183
|
|
188
184
|
@fragments.each do |fragment|
|
189
|
-
new_instance.add_fragment(
|
190
|
-
fragment.
|
191
|
-
|
192
|
-
|
193
|
-
fragment.reversed?,
|
194
|
-
fragment.pitch * (pitch.to_f / 100),
|
195
|
-
stretch))
|
185
|
+
new_instance.add_fragment(fragment.clone do |attributes|
|
186
|
+
attributes[:pitch] = fragment.pitch * (pitch.to_f / 100)
|
187
|
+
attributes[:stretch] = stretch
|
188
|
+
end)
|
196
189
|
end
|
197
190
|
|
198
191
|
new_instance
|
@@ -203,6 +196,18 @@ module Scissor
|
|
203
196
|
pitch(factor_for_pitch, true)
|
204
197
|
end
|
205
198
|
|
199
|
+
def pan(right_percent)
|
200
|
+
new_instance = self.class.new
|
201
|
+
|
202
|
+
@fragments.each do |fragment|
|
203
|
+
new_instance.add_fragment(fragment.clone do |attributes|
|
204
|
+
attributes[:pan] = right_percent
|
205
|
+
end)
|
206
|
+
end
|
207
|
+
|
208
|
+
new_instance
|
209
|
+
end
|
210
|
+
|
206
211
|
def to_file(filename, options = {})
|
207
212
|
Scissor.mix([self], filename, options)
|
208
213
|
end
|
data/lib/scissor/writer.rb
CHANGED
@@ -49,6 +49,10 @@ module Scissor
|
|
49
49
|
|
50
50
|
cmd << "-a:#{index} -o:#{outfile} -y:#{position}#{is_mono[fragment_filename] ? ' -chcopy:1,2' : ''}"
|
51
51
|
|
52
|
+
if fragment.pan != 50
|
53
|
+
cmd << "-epp:%i" % fragment.pan
|
54
|
+
end
|
55
|
+
|
52
56
|
if fragment.stretched? && fragment.pitch.to_f != 100.0
|
53
57
|
rubberband_out = tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + "rubberband_#{index}.wav")
|
54
58
|
rubberband_temp = tmpdir + "_rubberband.wav"
|
data/scissor.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
gem.name = %q{scissor}
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = "0.
|
16
|
+
gem.version = "0.4.0"
|
17
17
|
|
18
18
|
gem.add_dependency('open4', '>= 1.3.0')
|
19
19
|
gem.add_dependency('ruby-mp3info')
|
data/spec/fragment_spec.rb
CHANGED
@@ -37,6 +37,12 @@ describe Scissor::Fragment do
|
|
37
37
|
fragment.duration.should eql(21.0)
|
38
38
|
end
|
39
39
|
|
40
|
+
it "should have a pan" do
|
41
|
+
fragment = Scissor::Fragment.new(fixture('sample.mp3'), 5, 10.5, false, 50, false, 10)
|
42
|
+
|
43
|
+
fragment.pan.should eql(10)
|
44
|
+
end
|
45
|
+
|
40
46
|
it "should return new fragment and remaining start point and length" do
|
41
47
|
new_fragment, remaining_start, remaining_length = @fragment.create(0.5, 1.0)
|
42
48
|
new_fragment.filename.should eql(fixture('sample.mp3'))
|
data/spec/scissor_spec.rb
CHANGED
@@ -212,6 +212,13 @@ describe Scissor do
|
|
212
212
|
scissor.fragments.first.should be_stretched
|
213
213
|
end
|
214
214
|
|
215
|
+
it "should pan" do
|
216
|
+
scissor = @mp3.slice(0, 10) + @mp3.slice(0, 5)
|
217
|
+
|
218
|
+
scissor.pan(10).fragments[0].pan.should eql(10)
|
219
|
+
scissor.pan(10).pan(10).fragments[0].pan.should eql(10)
|
220
|
+
end
|
221
|
+
|
215
222
|
it "should join instances of scissor" do
|
216
223
|
a = @mp3.slice(0, 120)
|
217
224
|
b = @mp3.slice(150, 20)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scissor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: open4
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: ruby-mp3info
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: riff
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - <=
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 0.3.0
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - <=
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.0
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: tempdir
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: streamio-ffmpeg
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rspec
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ~>
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: 2.8.0
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.8.0
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: rake
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,10 +117,15 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: fakeweb
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
94
129
|
none: false
|
95
130
|
requirements:
|
96
131
|
- - ! '>='
|
@@ -98,7 +133,12 @@ dependencies:
|
|
98
133
|
version: '0'
|
99
134
|
type: :development
|
100
135
|
prerelease: false
|
101
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
102
142
|
description: utility to chop sound files
|
103
143
|
email:
|
104
144
|
- youpy@buycheapviagraonlinenow.com
|
@@ -112,7 +152,6 @@ files:
|
|
112
152
|
- Gemfile
|
113
153
|
- README.rdoc
|
114
154
|
- Rakefile
|
115
|
-
- VERSION
|
116
155
|
- data/silence.mp3
|
117
156
|
- lib/scissor.rb
|
118
157
|
- lib/scissor/fragment.rb
|
@@ -146,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
185
|
version: '0'
|
147
186
|
segments:
|
148
187
|
- 0
|
149
|
-
hash:
|
188
|
+
hash: -2487823998857234402
|
150
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
190
|
none: false
|
152
191
|
requirements:
|
@@ -155,10 +194,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
194
|
version: '0'
|
156
195
|
segments:
|
157
196
|
- 0
|
158
|
-
hash:
|
197
|
+
hash: -2487823998857234402
|
159
198
|
requirements: []
|
160
199
|
rubyforge_project:
|
161
|
-
rubygems_version: 1.8.
|
200
|
+
rubygems_version: 1.8.24
|
162
201
|
signing_key:
|
163
202
|
specification_version: 3
|
164
203
|
summary: utility to chop sound files
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.9
|