youpy-scissor-echonest 0.0.2 → 0.0.3
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/Rakefile +3 -3
- data/lib/scissor/echonest.rb +7 -2
- data/lib/scissor/echonest/meta.rb +32 -0
- data/spec/scissor-echonest_spec.rb +10 -2
- data/spec/spec_helper.rb +2 -1
- metadata +6 -4
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.3"
|
25
25
|
|
26
26
|
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
27
27
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
@@ -61,8 +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
|
-
s.add_dependency('scissor', '>=0.0.19')
|
65
|
-
s.add_dependency('ruby-echonest', '>=0.0.3')
|
64
|
+
s.add_dependency('youpy-scissor', '>=0.0.19')
|
65
|
+
s.add_dependency('youpy-ruby-echonest', '>=0.0.3')
|
66
66
|
#s.required_ruby_version = '>= 1.8.2'
|
67
67
|
|
68
68
|
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
data/lib/scissor/echonest.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'scissor'
|
2
2
|
require 'echonest'
|
3
|
+
require 'scissor/echonest/meta'
|
3
4
|
|
4
5
|
module Scissor
|
5
6
|
def self.echonest_api_key=(echonest_api_key)
|
@@ -22,7 +23,9 @@ module Scissor
|
|
22
23
|
|
23
24
|
beats = echonest.get_beats(tmpfile)
|
24
25
|
beats.inject do |m, beat|
|
25
|
-
|
26
|
+
chunk = self[m.start, beat.start - m.start]
|
27
|
+
Echonest::Meta::Beat.init(chunk, m)
|
28
|
+
chunks << chunk
|
26
29
|
beat
|
27
30
|
end
|
28
31
|
|
@@ -36,7 +39,9 @@ module Scissor
|
|
36
39
|
|
37
40
|
segments = echonest.get_segments(tmpfile)
|
38
41
|
segments.inject([]) do |chunks, segment|
|
39
|
-
|
42
|
+
chunk = self[segment.start, segment.duration]
|
43
|
+
Echonest::Meta::Segment.init(chunk, segment)
|
44
|
+
chunks << chunk
|
40
45
|
chunks
|
41
46
|
end
|
42
47
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Scissor
|
2
|
+
module Echonest
|
3
|
+
module Meta
|
4
|
+
module Beat
|
5
|
+
def self.init(obj, beat)
|
6
|
+
obj.extend self
|
7
|
+
obj.instance_eval {
|
8
|
+
@confidence = beat.confidence
|
9
|
+
@start = beat.start
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :confidence, :start
|
14
|
+
end
|
15
|
+
|
16
|
+
module Segment
|
17
|
+
def self.init(obj, segment)
|
18
|
+
obj.extend self
|
19
|
+
obj.instance_eval {
|
20
|
+
@start = segment.start
|
21
|
+
@loudness = segment.loudness
|
22
|
+
@max_loudness = segment.max_loudness
|
23
|
+
@pitches = segment.pitches
|
24
|
+
@timbre = segment.timbre
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_reader :start, :loudness, :max_loudness, :pitches, :timbre
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -24,7 +24,8 @@ describe Scissor do
|
|
24
24
|
beats.size.should eql(384)
|
25
25
|
beats[0].should be_an_instance_of(Scissor::Chunk)
|
26
26
|
beats[0].duration.should eql(0.47604)
|
27
|
-
beats[0].fragments.first.filename.
|
27
|
+
beats[0].fragments.first.filename.should eql(fixture('sample.mp3'))
|
28
|
+
beats[0].confidence.should eql(0.296)
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'should get segments' do
|
@@ -40,6 +41,13 @@ describe Scissor do
|
|
40
41
|
segments.size.should eql(830)
|
41
42
|
segments[0].should be_an_instance_of(Scissor::Chunk)
|
42
43
|
segments[0].duration.should eql(0.30327)
|
43
|
-
segments[0].fragments.first.filename.
|
44
|
+
segments[0].fragments.first.filename.should eql(fixture('sample.mp3'))
|
45
|
+
segments[0].start.should eql(0.0)
|
46
|
+
segments[0].loudness.time.should eql(0.0)
|
47
|
+
segments[0].loudness.value.should eql(-60.0)
|
48
|
+
segments[0].max_loudness.time.should eql(0.31347)
|
49
|
+
segments[0].max_loudness.value.should eql(-56.818)
|
50
|
+
segments[0].pitches.first.should eql(0.835)
|
51
|
+
segments[0].timbre.first.should eql(0.079)
|
44
52
|
end
|
45
53
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__) + '/../lib/'
|
2
2
|
|
3
3
|
require "scissor/echonest"
|
4
|
+
require "pathname"
|
4
5
|
|
5
6
|
module SpecHelper
|
6
7
|
def fixture(filename)
|
7
|
-
File.dirname(__FILE__) + '/fixtures/' + filename
|
8
|
+
Pathname.new(File.dirname(__FILE__) + '/fixtures/' + filename).realpath
|
8
9
|
end
|
9
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youpy-scissor-echonest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youpy
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: scissor
|
16
|
+
name: youpy-scissor
|
17
17
|
type: :runtime
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: 0.0.19
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name: ruby-echonest
|
26
|
+
name: youpy-ruby-echonest
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -53,6 +53,8 @@ files:
|
|
53
53
|
- spec/spec.opts
|
54
54
|
- spec/spec_helper.rb
|
55
55
|
- lib/scissor
|
56
|
+
- lib/scissor/echonest
|
57
|
+
- lib/scissor/echonest/meta.rb
|
56
58
|
- lib/scissor/echonest.rb
|
57
59
|
has_rdoc: true
|
58
60
|
homepage: http://scissorechonest.rubyforge.org
|