Permalink
Browse files

Added the artist, album and track title to analysis results, includin…

…g RSpec tests and updated test .json
  • Loading branch information...
1 parent 3ebd63b commit 6fb020354d3f7fecff1d8765ffb100a5b4a87702 @chrism chrism committed Apr 17, 2013
Showing with 55 additions and 27 deletions.
  1. +16 −0 lib/echonest/analysis.rb
  2. +37 −25 spec/analysis_spec.rb
  3. +2 −2 spec/fixtures/analysis.json
View
@@ -18,6 +18,18 @@ def self.new_from_url(url)
end
end
+ def artist
+ meta_info['artist']
+ end
+
+ def album
+ meta_info['album']
+ end
+
+ def title
+ meta_info['title']
+ end
+
def tempo
track_info['tempo']
end
@@ -94,5 +106,9 @@ def segments
def track_info
@body['track']
end
+
+ def meta_info
+ @body['meta']
+ end
end
end
View
@@ -7,44 +7,56 @@
@analysis = Echonest::Analysis.new(open(fixture('analysis.json')).read)
end
+ it "should have artist" do
+ @analysis.artist.should eql("Philip Glass")
+ end
+
+ it "should have album" do
+ @analysis.album.should eql("The Orange Mountain Music Philip Glass Sampler Vol.I")
+ end
+
+ it "should have title" do
+ @analysis.title.should eql("Neverwas Restored (from Neverwas Soundtrack)")
+ end
+
it "should have beats" do
beats = @analysis.beats
- beats.size.should eql(324)
- beats.first.start.should eql(0.27661)
- beats.first.duration.should eql(0.36476)
- beats.first.confidence.should eql(0.468)
+ beats.size.should eql(301)
+ beats.first.start.should eql(0.14982)
+ beats.first.duration.should eql(0.42958)
+ beats.first.confidence.should eql(0.0)
end
it "should have segments" do
segments = @analysis.segments
segment = segments.first
- segments.size.should eql(274)
+ segments.size.should eql(339)
segment.start.should eql(0.0)
- segment.duration.should eql(0.43909)
- segment.confidence.should eql(1.0)
+ segment.duration.should eql(0.10308)
+ segment.confidence.should eql(0.0)
segment.loudness.time.should eql(0.0)
segment.loudness.value.should eql(-60.0)
- segment.max_loudness.time.should eql(0.11238)
- segment.max_loudness.value.should eql(-33.563)
+ segment.max_loudness.time.should eql(0.07546)
+ segment.max_loudness.value.should eql(-57.86)
segment.pitches.size.should eql(12)
- segment.pitches.first.should eql(0.138)
+ segment.pitches.first.should eql(1.0)
segment.timbre.size.should eql(12)
- segment.timbre.first.should eql(11.525)
+ segment.timbre.first.should eql(1.178)
end
it "should have bars" do
bars = @analysis.bars
- bars.size.should eql(80)
- bars.first.start.should eql(1.00704)
- bars.first.duration.should eql(1.48532)
- bars.first.confidence.should eql(0.188)
+ bars.size.should eql(75)
+ bars.first.start.should eql(0.14982)
+ bars.first.duration.should eql(1.7004)
+ bars.first.confidence.should eql(0.132)
end
it "should have tempo" do
- @analysis.tempo.should eql(168.460)
+ @analysis.tempo.should eql(151.019)
end
it "should have sections" do
@@ -53,28 +65,28 @@
sections.size.should eql(7)
section.start.should eql(0.0)
- section.duration.should eql(20.04271)
+ section.duration.should eql(21.14804)
section.confidence.should eql(1.0)
end
it "should have durtion" do
- @analysis.duration.should eql(120.68526)
+ @analysis.duration.should eql(120.68)
end
it "should have end of fade in" do
- @analysis.end_of_fade_in.should eql(0.0)
+ @analysis.end_of_fade_in.should eql(0.10308)
end
it "should have start of fade out" do
- @analysis.start_of_fade_out.should eql(113.557)
+ @analysis.start_of_fade_out.should eql(115.7863)
end
it "should have key" do
@analysis.key.should eql(7)
end
it "should have loudness" do
- @analysis.loudness.should eql(-19.140)
+ @analysis.loudness.should eql(-18.825)
end
it "should have mode" do
@@ -88,9 +100,9 @@
it "should have tatums" do
tatums = @analysis.tatums
- tatums.size.should eql(648)
- tatums.first.start.should eql(0.09469)
- tatums.first.duration.should eql(0.18193)
- tatums.first.confidence.should eql(0.286)
+ tatums.size.should eql(601)
+ tatums.first.start.should eql(0.14982)
+ tatums.first.duration.should eql(0.21743)
+ tatums.first.confidence.should eql(0.311)
end
end

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit 6fb0203

Please sign in to comment.