youpy-scissor 0.0.20 → 0.0.21
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/README.rdoc +20 -7
- data/Rakefile +1 -1
- data/lib/scissor/chunk.rb +18 -7
- data/lib/scissor/fragment.rb +20 -7
- data/lib/scissor/writer.rb +2 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -31,29 +31,42 @@ supported file format:
|
|
31
31
|
|
32
32
|
== Synopsis
|
33
33
|
|
34
|
+
=== instanciate
|
35
|
+
|
34
36
|
foo = Scissor('foo.mp3')
|
35
37
|
bar = Scissor('bar.wav')
|
36
38
|
|
37
|
-
|
39
|
+
=== concat
|
40
|
+
|
38
41
|
foo + bar > 'foobar.mp3'
|
39
42
|
|
40
|
-
|
43
|
+
=== slice + concat
|
44
|
+
|
41
45
|
foo[10, 1] + bar[2, 3] > 'slicefoobar.mp3'
|
42
46
|
|
43
|
-
|
47
|
+
=== slice + concat + loop
|
48
|
+
|
44
49
|
(foo[10, 1] + bar[2, 3]) * 4 > 'slicefoobarloop.mp3'
|
45
50
|
|
46
|
-
|
51
|
+
=== split
|
52
|
+
|
47
53
|
(Scissor('sequence.mp3') / 16).first.to_file('split.mp3')
|
48
54
|
|
49
|
-
|
55
|
+
=== replace first 10 seconds with 30 seconds of silence
|
56
|
+
|
50
57
|
foo.replace(0, 10, Scissor.silence(30)).to_file('replace.mp3')
|
51
58
|
|
52
|
-
|
59
|
+
=== sequence + loop
|
60
|
+
|
53
61
|
seq = Scissor.sequence('x y xyz', 0.2)
|
54
62
|
seq.apply(:x => foo, :y => Proc.new { bar }, :z => foo.reverse) * 4 > 'sequence.wav'
|
55
63
|
|
56
|
-
|
64
|
+
=== half the pitch
|
65
|
+
|
66
|
+
foo.pitch(50)
|
67
|
+
|
68
|
+
=== mix
|
69
|
+
|
57
70
|
Scissor.mix([foo, bar], 'mix.mp3')
|
58
71
|
|
59
72
|
== Copyright
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ DESCRIPTION = "utility to chop sound files"
|
|
17
17
|
RUBYFORGE_PROJECT = "scissor"
|
18
18
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
19
19
|
BIN_FILES = %w( )
|
20
|
-
VERS = "0.0.
|
20
|
+
VERS = "0.0.21"
|
21
21
|
|
22
22
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
23
23
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
data/lib/scissor/chunk.rb
CHANGED
@@ -150,20 +150,31 @@ module Scissor
|
|
150
150
|
new_instance.add_fragment(Fragment.new(
|
151
151
|
fragment.filename,
|
152
152
|
fragment.start,
|
153
|
-
fragment.
|
154
|
-
!fragment.reversed
|
153
|
+
fragment.true_duration,
|
154
|
+
!fragment.reversed?,
|
155
|
+
fragment.pitch))
|
155
156
|
end
|
156
157
|
|
157
158
|
new_instance
|
158
159
|
end
|
159
160
|
|
160
|
-
def
|
161
|
-
|
161
|
+
def pitch(pitch)
|
162
|
+
new_instance = self.class.new
|
162
163
|
|
163
|
-
|
164
|
-
|
164
|
+
@fragments.each do |fragment|
|
165
|
+
new_instance.add_fragment(Fragment.new(
|
166
|
+
fragment.filename,
|
167
|
+
fragment.start,
|
168
|
+
fragment.true_duration,
|
169
|
+
fragment.reversed?,
|
170
|
+
fragment.pitch * (pitch.to_f / 100)))
|
171
|
+
end
|
165
172
|
|
166
|
-
|
173
|
+
new_instance
|
174
|
+
end
|
175
|
+
|
176
|
+
def to_file(filename, options = {})
|
177
|
+
Scissor.mix([self], filename, options)
|
167
178
|
end
|
168
179
|
|
169
180
|
alias > to_file
|
data/lib/scissor/fragment.rb
CHANGED
@@ -2,17 +2,26 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Scissor
|
4
4
|
class Fragment
|
5
|
-
attr_reader :filename, :start, :
|
5
|
+
attr_reader :filename, :start, :pitch
|
6
6
|
|
7
|
-
def initialize(filename, start, duration, reverse = false)
|
7
|
+
def initialize(filename, start, duration, reverse = false, pitch = 100)
|
8
8
|
@filename = Pathname.new(filename).realpath
|
9
9
|
@start = start
|
10
10
|
@duration = duration
|
11
11
|
@reverse = reverse
|
12
|
+
@pitch = pitch
|
12
13
|
|
13
14
|
freeze
|
14
15
|
end
|
15
16
|
|
17
|
+
def duration
|
18
|
+
@duration * (100 / pitch.to_f)
|
19
|
+
end
|
20
|
+
|
21
|
+
def true_duration
|
22
|
+
@duration
|
23
|
+
end
|
24
|
+
|
16
25
|
def reversed?
|
17
26
|
@reverse
|
18
27
|
end
|
@@ -26,16 +35,20 @@ module Scissor
|
|
26
35
|
if remaining_start + remaining_length >= duration
|
27
36
|
new_fragment = self.class.new(
|
28
37
|
filename,
|
29
|
-
start + remaining_start,
|
30
|
-
duration - remaining_start)
|
38
|
+
start + remaining_start * pitch.to_f / 100,
|
39
|
+
(duration - remaining_start) * pitch.to_f / 100,
|
40
|
+
false,
|
41
|
+
pitch)
|
31
42
|
|
32
|
-
remaining_length -=
|
43
|
+
remaining_length -= duration - remaining_start
|
33
44
|
remaining_start = 0
|
34
45
|
else
|
35
46
|
new_fragment = self.class.new(
|
36
47
|
filename,
|
37
|
-
start + remaining_start,
|
38
|
-
remaining_length
|
48
|
+
start + remaining_start * pitch.to_f / 100,
|
49
|
+
remaining_length * pitch.to_f / 100,
|
50
|
+
false,
|
51
|
+
pitch)
|
39
52
|
|
40
53
|
remaining_start = 0
|
41
54
|
remaining_length = 0
|
data/lib/scissor/writer.rb
CHANGED
@@ -46,8 +46,9 @@ module Scissor
|
|
46
46
|
"-a:#{index} " +
|
47
47
|
"-i:" +
|
48
48
|
(fragment.reversed? ? 'reverse,' : '') +
|
49
|
-
"select,#{fragment.start},#{
|
49
|
+
"select,#{fragment.start},#{fragment.true_duration},\"#{fragment_outfile}\" " +
|
50
50
|
"-o:#{outfile} " +
|
51
|
+
(fragment.pitch.to_f == 100.0 ? "" : "-ei:#{fragment.pitch} ") +
|
51
52
|
"-y:#{position}"
|
52
53
|
|
53
54
|
position += fragment_duration
|