Class: Vizcore::DSL::TransitionController::TriggerContext Private
- Inherits:
-
Object
- Object
- Vizcore::DSL::TransitionController::TriggerContext
- Defined in:
- lib/vizcore/dsl/transition_controller.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Runtime DSL context exposed to transition trigger blocks.
Instance Method Summary collapse
- #amplitude ⇒ Float private
- #bar_count ⇒ Integer private
- #bar_phase ⇒ Float private
- #bass ⇒ Float private
- #bass_peak ⇒ Float private
- #beat ⇒ Boolean private
- #beat? ⇒ Boolean private
- #beat_2 ⇒ Boolean private
- #beat_4 ⇒ Boolean private
- #beat_8 ⇒ Boolean private
- #beat_confidence ⇒ Float private
- #beat_count ⇒ Integer private
- #beat_phase ⇒ Float private
- #beat_pulse ⇒ Float private
- #beat_triplet ⇒ Boolean private
- #bpm ⇒ Float private
- #bpm_confidence ⇒ Float private
- #fft_spectrum ⇒ Array<Float> private
- #frame_count ⇒ Integer private
- #frequency_band(name) ⇒ Float private
- #frequency_band_peak(name) ⇒ Float private
- #high ⇒ Float private
- #high_peak ⇒ Float private
- #hihat ⇒ Float private
-
#initialize(audio, frame_count:, elapsed_seconds: nil) ⇒ TriggerContext
constructor
private
A new instance of TriggerContext.
- #kick ⇒ Float private
- #low ⇒ Float private
- #low_peak ⇒ Float private
- #mid ⇒ Float private
- #mid_peak ⇒ Float private
- #onset(name = nil) ⇒ Float private
- #peak ⇒ Float private
- #phrase_count ⇒ Integer private
-
#seconds ⇒ Float
private
Scene-local elapsed seconds.
- #snare ⇒ Float private
- #spectral_centroid ⇒ Float private
- #spectral_flatness ⇒ Float private
- #spectral_flux ⇒ Float private
- #spectral_rolloff ⇒ Float private
- #sub ⇒ Float private
- #sub_peak ⇒ Float private
- #treble ⇒ Float private
- #treble_peak ⇒ Float private
- #triplet ⇒ Boolean private
- #zero_crossing_rate ⇒ Float private
Constructor Details
#initialize(audio, frame_count:, elapsed_seconds: nil) ⇒ TriggerContext
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TriggerContext.
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 115 def initialize(audio, frame_count:, elapsed_seconds: nil) @audio = symbolize_hash(audio) @bands = symbolize_hash(@audio[:bands]) @band_peaks = symbolize_hash(@audio[:band_peaks]) @onsets = symbolize_hash(@audio[:onsets]) @drums = symbolize_hash(@audio[:drums]) @frame_count = Integer(frame_count) @elapsed_seconds = normalize_elapsed_seconds(elapsed_seconds) rescue StandardError @frame_count = 0 @elapsed_seconds = nil end |
Instance Method Details
#amplitude ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
129 130 131 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 129 def amplitude @audio[:amplitude].to_f end |
#bar_count ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
301 302 303 304 305 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 301 def Integer(@audio[:bar_count] || 0) rescue StandardError 0 end |
#bar_phase ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
296 297 298 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 296 def @audio[:bar_phase].to_f end |
#bass ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
171 172 173 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 171 def bass frequency_band(:low) end |
#bass_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
176 177 178 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 176 def bass_peak frequency_band_peak(:low) end |
#beat ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
244 245 246 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 244 def beat beat? end |
#beat? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
239 240 241 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 239 def beat? !!@audio[:beat] end |
#beat_2 ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
271 272 273 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 271 def beat_2 !!@audio[:beat_2] end |
#beat_4 ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
276 277 278 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 276 def beat_4 !!@audio[:beat_4] end |
#beat_8 ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
281 282 283 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 281 def beat_8 !!@audio[:beat_8] end |
#beat_confidence ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
249 250 251 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 249 def beat_confidence @audio[:beat_confidence].to_f end |
#beat_count ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
259 260 261 262 263 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 259 def beat_count Integer(@audio[:beat_count] || 0) rescue StandardError 0 end |
#beat_phase ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
266 267 268 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 266 def beat_phase @audio[:beat_phase].to_f end |
#beat_pulse ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
254 255 256 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 254 def beat_pulse @audio[:beat_pulse].to_f end |
#beat_triplet ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
286 287 288 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 286 def beat_triplet !!@audio[:beat_triplet] end |
#bpm ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
315 316 317 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 315 def bpm @audio[:bpm].to_f end |
#bpm_confidence ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
320 321 322 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 320 def bpm_confidence @audio[:bpm_confidence].to_f end |
#fft_spectrum ⇒ Array<Float>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
211 212 213 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 211 def fft_spectrum Array(@audio[:fft]) end |
#frame_count ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
350 351 352 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 350 def frame_count @frame_count end |
#frequency_band(name) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 140 def frequency_band(name) @bands[name.to_sym].to_f end |
#frequency_band_peak(name) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
146 147 148 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 146 def frequency_band_peak(name) @band_peaks[name.to_sym].to_f end |
#high ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
191 192 193 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 191 def high frequency_band(:high) end |
#high_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
196 197 198 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 196 def high_peak frequency_band_peak(:high) end |
#hihat ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
234 235 236 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 234 def hihat @drums[:hihat].to_f end |
#kick ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
224 225 226 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 224 def kick @drums[:kick].to_f end |
#low ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 161 def low frequency_band(:low) end |
#low_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
166 167 168 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 166 def low_peak frequency_band_peak(:low) end |
#mid ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
181 182 183 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 181 def mid frequency_band(:mid) end |
#mid_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
186 187 188 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 186 def mid_peak frequency_band_peak(:mid) end |
#onset(name = nil) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
217 218 219 220 221 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 217 def onset(name = nil) return @audio[:onset].to_f if name.nil? @onsets[name.to_sym].to_f end |
#peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 134 def peak @audio[:peak].to_f end |
#phrase_count ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
308 309 310 311 312 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 308 def phrase_count Integer(@audio[:phrase_count] || 0) rescue StandardError 0 end |
#seconds ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns scene-local elapsed seconds.
355 356 357 358 359 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 355 def seconds return @elapsed_seconds if @elapsed_seconds @frame_count / DEFAULT_FRAME_RATE end |
#snare ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
229 230 231 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 229 def snare @drums[:snare].to_f end |
#spectral_centroid ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
325 326 327 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 325 def spectral_centroid @audio[:spectral_centroid].to_f end |
#spectral_flatness ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
335 336 337 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 335 def spectral_flatness @audio[:spectral_flatness].to_f end |
#spectral_flux ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
340 341 342 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 340 def spectral_flux @audio[:spectral_flux].to_f end |
#spectral_rolloff ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
330 331 332 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 330 def spectral_rolloff @audio[:spectral_rolloff].to_f end |
#sub ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
151 152 153 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 151 def sub frequency_band(:sub) end |
#sub_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
156 157 158 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 156 def sub_peak frequency_band_peak(:sub) end |
#treble ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
201 202 203 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 201 def treble frequency_band(:high) end |
#treble_peak ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
206 207 208 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 206 def treble_peak frequency_band_peak(:high) end |
#triplet ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
291 292 293 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 291 def triplet beat_triplet end |
#zero_crossing_rate ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
345 346 347 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 345 def zero_crossing_rate @audio[:zero_crossing_rate].to_f end |