youpy-scissor-echonest 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +7 -5
- data/Rakefile +3 -2
- data/lib/scissor/echonest.rb +27 -8
- data/spec/fixtures/get_segments.xml +2 -0
- data/spec/scissor-echonest_spec.rb +17 -1
- data/spec/spec.opts +2 -1
- metadata +25 -5
data/README.rdoc
CHANGED
@@ -21,15 +21,17 @@ Scissor extension to use Echo Nest Developers API
|
|
21
21
|
|
22
22
|
== Synopsis
|
23
23
|
|
24
|
+
require 'rubygems'
|
24
25
|
require 'scissor/echonest'
|
25
26
|
|
26
27
|
Scissor.echonest_api_key = 'YOUR_API_KEY'
|
27
|
-
beats = Scissor('trans_europe_express.mp3').beats
|
28
28
|
|
29
|
-
# sort beats by duration
|
30
|
-
beats.
|
31
|
-
sort_by {|beat| beat.duration }
|
32
|
-
|
29
|
+
# sort beats by duration
|
30
|
+
beats = Scissor('trans_europe_express.mp3').beats.
|
31
|
+
sort_by {|beat| beat.duration }
|
32
|
+
|
33
|
+
# join beats and write into file
|
34
|
+
Scissor.join(beats) > 'sorted.mp3'
|
33
35
|
|
34
36
|
== Copyright
|
35
37
|
|
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ DESCRIPTION = "Scissor extension to use Echo Nest Developers API"
|
|
21
21
|
RUBYFORGE_PROJECT = "scissorechonest"
|
22
22
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
23
23
|
BIN_FILES = %w( )
|
24
|
-
VERS = "0.0.
|
24
|
+
VERS = "0.0.2"
|
25
25
|
|
26
26
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
27
27
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
@@ -61,7 +61,8 @@ spec = Gem::Specification.new do |s|
|
|
61
61
|
s.require_path = "lib"
|
62
62
|
s.test_files = Dir["test/test_*.rb"]
|
63
63
|
|
64
|
-
|
64
|
+
s.add_dependency('scissor', '>=0.0.19')
|
65
|
+
s.add_dependency('ruby-echonest', '>=0.0.3')
|
65
66
|
#s.required_ruby_version = '>= 1.8.2'
|
66
67
|
|
67
68
|
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
data/lib/scissor/echonest.rb
CHANGED
@@ -16,18 +16,37 @@ module Scissor
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def beats
|
19
|
-
|
20
|
-
|
19
|
+
tempfile_for_echonest do |tmpfile|
|
20
|
+
chunks = []
|
21
|
+
scissor = to_file(tmpfile)
|
22
|
+
|
23
|
+
beats = echonest.get_beats(tmpfile)
|
24
|
+
beats.inject do |m, beat|
|
25
|
+
chunks << self[m.start, beat.start - m.start]
|
26
|
+
beat
|
27
|
+
end
|
28
|
+
|
29
|
+
chunks
|
30
|
+
end
|
31
|
+
end
|
21
32
|
|
22
|
-
|
33
|
+
def segments
|
34
|
+
tempfile_for_echonest do |tmpfile|
|
35
|
+
scissor = to_file(tmpfile)
|
23
36
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
segments = echonest.get_segments(tmpfile)
|
38
|
+
segments.inject([]) do |chunks, segment|
|
39
|
+
chunks << self[segment.start, segment.duration]
|
40
|
+
chunks
|
41
|
+
end
|
28
42
|
end
|
43
|
+
end
|
29
44
|
|
30
|
-
|
45
|
+
private
|
46
|
+
|
47
|
+
def tempfile_for_echonest
|
48
|
+
tmpfile = Pathname.new('/tmp/scissor_echonest_temp_' + $$.to_s + '.mp3')
|
49
|
+
yield tmpfile
|
31
50
|
ensure
|
32
51
|
tmpfile.unlink
|
33
52
|
end
|