youpy-scissor 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/Rakefile +1 -1
- data/lib/scissor.rb +32 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -48,9 +48,9 @@ supported file format:
|
|
48
48
|
# replace first 10 seconds with 30 seconds of silence
|
49
49
|
foo.replace(0, 10, Scissor.silence(30)).to_file('replace.mp3')
|
50
50
|
|
51
|
-
#
|
52
|
-
|
53
|
-
(
|
51
|
+
# sequence + loop
|
52
|
+
seq = Scissor.sequence('x y xyz', 0.2)
|
53
|
+
seq.apply(:x => foo, :y => bar, :z => foo.reverse) * 4 > 'sequence.wav'
|
54
54
|
|
55
55
|
== Copyright
|
56
56
|
|
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.14"
|
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.rb
CHANGED
@@ -267,6 +267,10 @@ class Scissor
|
|
267
267
|
slice(0, 1).
|
268
268
|
fill(duration)
|
269
269
|
end
|
270
|
+
|
271
|
+
def sequence(*args)
|
272
|
+
Sequence.new(*args)
|
273
|
+
end
|
270
274
|
end
|
271
275
|
|
272
276
|
class SoundFile
|
@@ -314,4 +318,32 @@ class Scissor
|
|
314
318
|
@reverse
|
315
319
|
end
|
316
320
|
end
|
321
|
+
|
322
|
+
class Sequence
|
323
|
+
def initialize(pattern, duration_per_step)
|
324
|
+
@pattern = pattern
|
325
|
+
@duration_per_step = duration_per_step
|
326
|
+
end
|
327
|
+
|
328
|
+
def apply(scissors)
|
329
|
+
result = Scissor.new
|
330
|
+
|
331
|
+
@pattern.split(//).each do |c|
|
332
|
+
if scissors.include?(c.to_sym)
|
333
|
+
scissor = scissors[c.to_sym]
|
334
|
+
|
335
|
+
if @duration_per_step > scissor.duration
|
336
|
+
result += scissor
|
337
|
+
result += Scissor.silence(@duration_per_step - scissor.duration)
|
338
|
+
else
|
339
|
+
result += scissors[c.to_sym].slice(0, @duration_per_step)
|
340
|
+
end
|
341
|
+
else
|
342
|
+
result += Scissor.silence(@duration_per_step)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
result
|
347
|
+
end
|
348
|
+
end
|
317
349
|
end
|