Class: SpotifyWebApi::AudioFeaturesObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::AudioFeaturesObject
- Defined in:
- lib/spotify_web_api/models/audio_features_object.rb
Overview
AudioFeaturesObject Model.
Instance Attribute Summary collapse
-
#acousticness ⇒ Float
A confidence measure from 0.0 to 1.0 of whether the track is acoustic.
-
#analysis_url ⇒ String
A URL to access the full audio analysis of this track.
-
#danceability ⇒ Float
Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity.
-
#duration_ms ⇒ Integer
The duration of the track in milliseconds.
-
#energy ⇒ Float
Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity.
-
#id ⇒ String
The Spotify ID for the track.
-
#instrumentalness ⇒ Float
Predicts whether a track contains no vocals.
-
#key ⇒ Integer
The key the track is in.
-
#liveness ⇒ Float
Detects the presence of an audience in the recording.
-
#loudness ⇒ Float
The overall loudness of a track in decibels (dB).
-
#mode ⇒ Integer
Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived.
-
#speechiness ⇒ Float
Speechiness detects the presence of spoken words in a track.
-
#tempo ⇒ Float
The overall estimated tempo of a track in beats per minute (BPM).
-
#time_signature ⇒ Integer
An estimated time signature.
-
#track_href ⇒ String
A link to the Web API endpoint providing full details of the track.
-
#type ⇒ Type6Enum
The object type.
-
#uri ⇒ String
The Spotify URI for the track.
-
#valence ⇒ Float
A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track.
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(acousticness = SKIP, analysis_url = SKIP, danceability = SKIP, duration_ms = SKIP, energy = SKIP, id = SKIP, instrumentalness = SKIP, key = SKIP, liveness = SKIP, loudness = SKIP, mode = SKIP, speechiness = SKIP, tempo = SKIP, time_signature = SKIP, track_href = SKIP, type = SKIP, uri = SKIP, valence = SKIP) ⇒ AudioFeaturesObject
constructor
A new instance of AudioFeaturesObject.
Methods inherited from BaseModel
Constructor Details
#initialize(acousticness = SKIP, analysis_url = SKIP, danceability = SKIP, duration_ms = SKIP, energy = SKIP, id = SKIP, instrumentalness = SKIP, key = SKIP, liveness = SKIP, loudness = SKIP, mode = SKIP, speechiness = SKIP, tempo = SKIP, time_signature = SKIP, track_href = SKIP, type = SKIP, uri = SKIP, valence = SKIP) ⇒ AudioFeaturesObject
Returns a new instance of AudioFeaturesObject.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 176 def initialize(acousticness = SKIP, analysis_url = SKIP, danceability = SKIP, duration_ms = SKIP, energy = SKIP, id = SKIP, instrumentalness = SKIP, key = SKIP, liveness = SKIP, loudness = SKIP, mode = SKIP, speechiness = SKIP, tempo = SKIP, time_signature = SKIP, track_href = SKIP, type = SKIP, uri = SKIP, valence = SKIP) @acousticness = acousticness unless acousticness == SKIP @analysis_url = analysis_url unless analysis_url == SKIP @danceability = danceability unless danceability == SKIP @duration_ms = duration_ms unless duration_ms == SKIP @energy = energy unless energy == SKIP @id = id unless id == SKIP @instrumentalness = instrumentalness unless instrumentalness == SKIP @key = key unless key == SKIP @liveness = liveness unless liveness == SKIP @loudness = loudness unless loudness == SKIP @mode = mode unless mode == SKIP @speechiness = speechiness unless speechiness == SKIP @tempo = tempo unless tempo == SKIP @time_signature = time_signature unless time_signature == SKIP @track_href = track_href unless track_href == SKIP @type = type unless type == SKIP @uri = uri unless uri == SKIP @valence = valence unless valence == SKIP end |
Instance Attribute Details
#acousticness ⇒ Float
A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic.
15 16 17 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 15 def acousticness @acousticness end |
#analysis_url ⇒ String
A URL to access the full audio analysis of this track. An access token is required to access this data.
20 21 22 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 20 def analysis_url @analysis_url end |
#danceability ⇒ Float
Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable.
27 28 29 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 27 def danceability @danceability end |
#duration_ms ⇒ Integer
The duration of the track in milliseconds.
31 32 33 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 31 def duration_ms @duration_ms end |
#energy ⇒ Float
Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute include dynamic range, perceived loudness, timbre, onset rate, and general entropy.
40 41 42 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 40 def energy @energy end |
#id ⇒ String
The Spotify ID for the track.
44 45 46 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 44 def id @id end |
#instrumentalness ⇒ Float
Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly “vocal”. The closer the instrumentalness value is to 1.0, the greater likelihood the track contains no vocal content. Values above 0.5 are intended to represent instrumental tracks, but confidence is higher as the value approaches 1.0.
53 54 55 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 53 def instrumentalness @instrumentalness end |
#key ⇒ Integer
The key the track is in. Integers map to pitches using standard [Pitch Class notation](en.wikipedia.org/wiki/Pitch_class). E.g. 0 = C, 1
C♯/D♭, 2 = D, and so on. If no key was detected, the value is -1.
59 60 61 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 59 def key @key end |
#liveness ⇒ Float
Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. A value above 0.8 provides strong likelihood that the track is live.
65 66 67 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 65 def liveness @liveness end |
#loudness ⇒ Float
The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typically range between -60 and 0 db.
73 74 75 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 73 def loudness @loudness end |
#mode ⇒ Integer
Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0.
79 80 81 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 79 def mode @mode end |
#speechiness ⇒ Float
Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value. Values above 0.66 describe tracks that are probably made entirely of spoken words. Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either in sections or layered, including such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like tracks.
89 90 91 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 89 def speechiness @speechiness end |
#tempo ⇒ Float
The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration.
95 96 97 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 95 def tempo @tempo end |
#time_signature ⇒ Integer
An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of “3/4”, to “7/4”.
102 103 104 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 102 def time_signature @time_signature end |
#track_href ⇒ String
A link to the Web API endpoint providing full details of the track.
106 107 108 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 106 def track_href @track_href end |
#type ⇒ Type6Enum
The object type.
110 111 112 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 110 def type @type end |
#uri ⇒ String
The Spotify URI for the track.
114 115 116 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 114 def uri @uri end |
#valence ⇒ Float
A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).
121 122 123 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 121 def valence @valence end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 203 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. acousticness = hash.key?('acousticness') ? hash['acousticness'] : SKIP analysis_url = hash.key?('analysis_url') ? hash['analysis_url'] : SKIP danceability = hash.key?('danceability') ? hash['danceability'] : SKIP duration_ms = hash.key?('duration_ms') ? hash['duration_ms'] : SKIP energy = hash.key?('energy') ? hash['energy'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP instrumentalness = hash.key?('instrumentalness') ? hash['instrumentalness'] : SKIP key = hash.key?('key') ? hash['key'] : SKIP liveness = hash.key?('liveness') ? hash['liveness'] : SKIP loudness = hash.key?('loudness') ? hash['loudness'] : SKIP mode = hash.key?('mode') ? hash['mode'] : SKIP speechiness = hash.key?('speechiness') ? hash['speechiness'] : SKIP tempo = hash.key?('tempo') ? hash['tempo'] : SKIP time_signature = hash.key?('time_signature') ? hash['time_signature'] : SKIP track_href = hash.key?('track_href') ? hash['track_href'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP uri = hash.key?('uri') ? hash['uri'] : SKIP valence = hash.key?('valence') ? hash['valence'] : SKIP # Create object from extracted values. AudioFeaturesObject.new(acousticness, analysis_url, danceability, duration_ms, energy, id, instrumentalness, key, liveness, loudness, mode, speechiness, tempo, time_signature, track_href, type, uri, valence) end |
.names ⇒ Object
A mapping from model property names to API property names.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 124 def self.names @_hash = {} if @_hash.nil? @_hash['acousticness'] = 'acousticness' @_hash['analysis_url'] = 'analysis_url' @_hash['danceability'] = 'danceability' @_hash['duration_ms'] = 'duration_ms' @_hash['energy'] = 'energy' @_hash['id'] = 'id' @_hash['instrumentalness'] = 'instrumentalness' @_hash['key'] = 'key' @_hash['liveness'] = 'liveness' @_hash['loudness'] = 'loudness' @_hash['mode'] = 'mode' @_hash['speechiness'] = 'speechiness' @_hash['tempo'] = 'tempo' @_hash['time_signature'] = 'time_signature' @_hash['track_href'] = 'track_href' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash['valence'] = 'valence' @_hash end |
.nullables ⇒ Object
An array for nullable fields
172 173 174 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 172 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/spotify_web_api/models/audio_features_object.rb', line 148 def self.optionals %w[ acousticness analysis_url danceability duration_ms energy id instrumentalness key liveness loudness mode speechiness tempo time_signature track_href type uri valence ] end |