youpy-scissor 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +4 -0
  2. data/Rakefile +1 -1
  3. data/lib/scissor.rb +33 -5
  4. metadata +1 -1
data/README.rdoc CHANGED
@@ -41,6 +41,10 @@ utility to chop mp3 files
41
41
  # replace first 10 seconds with 30 seconds of silence
42
42
  foo.replace(0, 10, Scissor.silence(30)).to_file('replace.mp3')
43
43
 
44
+ # reverse + concat + loop
45
+ beat = foo.slice(0, 1)
46
+ ((beat * 3) + beat.reverse) * 80
47
+
44
48
  == Copyright
45
49
 
46
50
  Author:: youpy <youpy@buycheapviagraonlinenow.com>
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ DESCRIPTION = "utility to chop mp3 files"
17
17
  RUBYFORGE_PROJECT = "scissor"
18
18
  HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
19
19
  BIN_FILES = %w( )
20
- VERS = "0.0.9"
20
+ VERS = "0.0.10"
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
@@ -52,7 +52,8 @@ class Scissor
52
52
  new_instance.add_fragment(Fragment.new(
53
53
  fragment.filename,
54
54
  fragment.start + start,
55
- remain))
55
+ remain,
56
+ fragment.reversed?))
56
57
 
57
58
  break
58
59
  else
@@ -60,7 +61,8 @@ class Scissor
60
61
  new_instance.add_fragment(Fragment.new(
61
62
  fragment.filename,
62
63
  fragment.start + start,
63
- fragment.duration - start))
64
+ fragment.duration - start,
65
+ fragment.reversed?))
64
66
 
65
67
  start = 0
66
68
  end
@@ -146,6 +148,20 @@ class Scissor
146
148
  new_instance
147
149
  end
148
150
 
151
+ def reverse
152
+ new_instance = self.class.new
153
+
154
+ @fragments.reverse.each do |fragment|
155
+ new_instance.add_fragment(Fragment.new(
156
+ fragment.filename,
157
+ fragment.start,
158
+ fragment.duration,
159
+ !fragment.reversed?))
160
+ end
161
+
162
+ new_instance
163
+ end
164
+
149
165
  def to_file(filename, options = {})
150
166
  if @fragments.empty?
151
167
  raise EmptyFragment
@@ -176,6 +192,11 @@ class Scissor
176
192
 
177
193
  begin
178
194
  @fragments.each_with_index do |fragment, index|
195
+ if !index.zero? && (index % 80).zero?
196
+ run_command(cmd.join(' '))
197
+ cmd = %w/ecasound/
198
+ end
199
+
179
200
  fragment_tmpfile =
180
201
  tmpdir + (Digest::MD5.hexdigest(fragment.filename) + '.wav')
181
202
 
@@ -185,8 +206,10 @@ class Scissor
185
206
 
186
207
  cmd <<
187
208
  "-a:#{index} " +
188
- "-i:select,#{fragment.start},#{fragment.duration},\"#{fragment_tmpfile}\" " +
189
- "-o #{tmpfile} " +
209
+ "-i:" +
210
+ (fragment.reversed? ? 'reverse,' : '') +
211
+ "select,#{fragment.start},#{fragment.duration},\"#{fragment_tmpfile}\" " +
212
+ "-o:#{tmpfile} " +
190
213
  "-y:#{position}"
191
214
 
192
215
  position += fragment.duration
@@ -225,12 +248,17 @@ class Scissor
225
248
  class Fragment
226
249
  attr_reader :filename, :start, :duration
227
250
 
228
- def initialize(filename, start, duration)
251
+ def initialize(filename, start, duration, reverse = false)
229
252
  @filename = filename
230
253
  @start = start
231
254
  @duration = duration
255
+ @reverse = reverse
232
256
 
233
257
  freeze
234
258
  end
259
+
260
+ def reversed?
261
+ @reverse
262
+ end
235
263
  end
236
264
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youpy-scissor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - youpy