Class: SpotifyWebApi::AudioAnalysisObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::AudioAnalysisObject
- Defined in:
- lib/spotify_web_api/models/audio_analysis_object.rb
Overview
AudioAnalysisObject Model.
Instance Attribute Summary collapse
-
#bars ⇒ Array[TimeIntervalObject]
The time intervals of the bars throughout the track.
-
#beats ⇒ Array[TimeIntervalObject]
The time intervals of beats throughout the track.
-
#meta ⇒ Meta
TODO: Write general description for this method.
-
#sections ⇒ Array[SectionObject]
Sections are defined by large variations in rhythm or timbre, e.g.
-
#segments ⇒ Array[SegmentObject]
Each segment contains a roughly conisistent sound throughout its duration.
-
#tatums ⇒ Array[TimeIntervalObject]
A tatum represents the lowest regular pulse train that a listener intuitively infers from the timing of perceived musical events (segments).
-
#track ⇒ Track
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(meta = SKIP, track = SKIP, bars = SKIP, beats = SKIP, sections = SKIP, segments = SKIP, tatums = SKIP) ⇒ AudioAnalysisObject
constructor
A new instance of AudioAnalysisObject.
Methods inherited from BaseModel
Constructor Details
#initialize(meta = SKIP, track = SKIP, bars = SKIP, beats = SKIP, sections = SKIP, segments = SKIP, tatums = SKIP) ⇒ AudioAnalysisObject
Returns a new instance of AudioAnalysisObject.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 77 def initialize( = SKIP, track = SKIP, = SKIP, beats = SKIP, sections = SKIP, segments = SKIP, tatums = SKIP) @meta = unless == SKIP @track = track unless track == SKIP @bars = unless == SKIP @beats = beats unless beats == SKIP @sections = sections unless sections == SKIP @segments = segments unless segments == SKIP @tatums = tatums unless tatums == SKIP end |
Instance Attribute Details
#bars ⇒ Array[TimeIntervalObject]
The time intervals of the bars throughout the track. A bar (or measure) is a segment of time defined as a given number of beats.
23 24 25 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 23 def @bars end |
#beats ⇒ Array[TimeIntervalObject]
The time intervals of beats throughout the track. A beat is the basic time unit of a piece of music; for example, each tick of a metronome. Beats are typically multiples of tatums.
29 30 31 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 29 def beats @beats end |
#meta ⇒ Meta
TODO: Write general description for this method
14 15 16 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 14 def @meta end |
#sections ⇒ Array[SectionObject]
Sections are defined by large variations in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode, time_signature, and loudness.
35 36 37 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 35 def sections @sections end |
#segments ⇒ Array[SegmentObject]
Each segment contains a roughly conisistent sound throughout its duration.
39 40 41 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 39 def segments @segments end |
#tatums ⇒ Array[TimeIntervalObject]
A tatum represents the lowest regular pulse train that a listener intuitively infers from the timing of perceived musical events (segments).
44 45 46 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 44 def tatums @tatums end |
#track ⇒ Track
TODO: Write general description for this method
18 19 20 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 18 def track @track end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 89 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. = Meta.from_hash(hash['meta']) if hash['meta'] track = Track.from_hash(hash['track']) if hash['track'] # Parameter is an array, so we need to iterate through it = nil unless hash['bars'].nil? = [] hash['bars'].each do |structure| << (TimeIntervalObject.from_hash(structure) if structure) end end = SKIP unless hash.key?('bars') # Parameter is an array, so we need to iterate through it beats = nil unless hash['beats'].nil? beats = [] hash['beats'].each do |structure| beats << (TimeIntervalObject.from_hash(structure) if structure) end end beats = SKIP unless hash.key?('beats') # Parameter is an array, so we need to iterate through it sections = nil unless hash['sections'].nil? sections = [] hash['sections'].each do |structure| sections << (SectionObject.from_hash(structure) if structure) end end sections = SKIP unless hash.key?('sections') # Parameter is an array, so we need to iterate through it segments = nil unless hash['segments'].nil? segments = [] hash['segments'].each do |structure| segments << (SegmentObject.from_hash(structure) if structure) end end segments = SKIP unless hash.key?('segments') # Parameter is an array, so we need to iterate through it tatums = nil unless hash['tatums'].nil? tatums = [] hash['tatums'].each do |structure| tatums << (TimeIntervalObject.from_hash(structure) if structure) end end tatums = SKIP unless hash.key?('tatums') # Create object from extracted values. AudioAnalysisObject.new(, track, , beats, sections, segments, tatums) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['meta'] = 'meta' @_hash['track'] = 'track' @_hash['bars'] = 'bars' @_hash['beats'] = 'beats' @_hash['sections'] = 'sections' @_hash['segments'] = 'segments' @_hash['tatums'] = 'tatums' @_hash end |
.nullables ⇒ Object
An array for nullable fields
73 74 75 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 73 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/spotify_web_api/models/audio_analysis_object.rb', line 60 def self.optionals %w[ meta track bars beats sections segments tatums ] end |