Class: Vizcore::DSL::TransitionController::TriggerContext Private

Inherits:
Object
  • Object
show all
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

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.

Parameters:

  • audio (Hash)
  • frame_count (Integer)
  • elapsed_seconds (Numeric, nil) (defaults to: nil)


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

#amplitudeFloat

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:

  • (Float)


129
130
131
# File 'lib/vizcore/dsl/transition_controller.rb', line 129

def amplitude
  @audio[:amplitude].to_f
end

#bar_countInteger

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:

  • (Integer)


301
302
303
304
305
# File 'lib/vizcore/dsl/transition_controller.rb', line 301

def bar_count
  Integer(@audio[:bar_count] || 0)
rescue StandardError
  0
end

#bar_phaseFloat

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:

  • (Float)


296
297
298
# File 'lib/vizcore/dsl/transition_controller.rb', line 296

def bar_phase
  @audio[:bar_phase].to_f
end

#bassFloat

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:

  • (Float)


171
172
173
# File 'lib/vizcore/dsl/transition_controller.rb', line 171

def bass
  frequency_band(:low)
end

#bass_peakFloat

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:

  • (Float)


176
177
178
# File 'lib/vizcore/dsl/transition_controller.rb', line 176

def bass_peak
  frequency_band_peak(:low)
end

#beatBoolean

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:

  • (Boolean)


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.

Returns:

  • (Boolean)


239
240
241
# File 'lib/vizcore/dsl/transition_controller.rb', line 239

def beat?
  !!@audio[:beat]
end

#beat_2Boolean

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:

  • (Boolean)


271
272
273
# File 'lib/vizcore/dsl/transition_controller.rb', line 271

def beat_2
  !!@audio[:beat_2]
end

#beat_4Boolean

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:

  • (Boolean)


276
277
278
# File 'lib/vizcore/dsl/transition_controller.rb', line 276

def beat_4
  !!@audio[:beat_4]
end

#beat_8Boolean

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:

  • (Boolean)


281
282
283
# File 'lib/vizcore/dsl/transition_controller.rb', line 281

def beat_8
  !!@audio[:beat_8]
end

#beat_confidenceFloat

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:

  • (Float)


249
250
251
# File 'lib/vizcore/dsl/transition_controller.rb', line 249

def beat_confidence
  @audio[:beat_confidence].to_f
end

#beat_countInteger

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:

  • (Integer)


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_phaseFloat

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:

  • (Float)


266
267
268
# File 'lib/vizcore/dsl/transition_controller.rb', line 266

def beat_phase
  @audio[:beat_phase].to_f
end

#beat_pulseFloat

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:

  • (Float)


254
255
256
# File 'lib/vizcore/dsl/transition_controller.rb', line 254

def beat_pulse
  @audio[:beat_pulse].to_f
end

#beat_tripletBoolean

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:

  • (Boolean)


286
287
288
# File 'lib/vizcore/dsl/transition_controller.rb', line 286

def beat_triplet
  !!@audio[:beat_triplet]
end

#bpmFloat

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:

  • (Float)


315
316
317
# File 'lib/vizcore/dsl/transition_controller.rb', line 315

def bpm
  @audio[:bpm].to_f
end

#bpm_confidenceFloat

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:

  • (Float)


320
321
322
# File 'lib/vizcore/dsl/transition_controller.rb', line 320

def bpm_confidence
  @audio[:bpm_confidence].to_f
end

#fft_spectrumArray<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:

  • (Array<Float>)


211
212
213
# File 'lib/vizcore/dsl/transition_controller.rb', line 211

def fft_spectrum
  Array(@audio[:fft])
end

#frame_countInteger

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:

  • (Integer)


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.

Parameters:

  • name (Symbol, String)

Returns:

  • (Float)


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.

Parameters:

  • name (Symbol, String)

Returns:

  • (Float)


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

#highFloat

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:

  • (Float)


191
192
193
# File 'lib/vizcore/dsl/transition_controller.rb', line 191

def high
  frequency_band(:high)
end

#high_peakFloat

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:

  • (Float)


196
197
198
# File 'lib/vizcore/dsl/transition_controller.rb', line 196

def high_peak
  frequency_band_peak(:high)
end

#hihatFloat

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:

  • (Float)


234
235
236
# File 'lib/vizcore/dsl/transition_controller.rb', line 234

def hihat
  @drums[:hihat].to_f
end

#kickFloat

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:

  • (Float)


224
225
226
# File 'lib/vizcore/dsl/transition_controller.rb', line 224

def kick
  @drums[:kick].to_f
end

#lowFloat

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:

  • (Float)


161
162
163
# File 'lib/vizcore/dsl/transition_controller.rb', line 161

def low
  frequency_band(:low)
end

#low_peakFloat

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:

  • (Float)


166
167
168
# File 'lib/vizcore/dsl/transition_controller.rb', line 166

def low_peak
  frequency_band_peak(:low)
end

#midFloat

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:

  • (Float)


181
182
183
# File 'lib/vizcore/dsl/transition_controller.rb', line 181

def mid
  frequency_band(:mid)
end

#mid_peakFloat

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:

  • (Float)


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.

Parameters:

  • name (Symbol, String, nil) (defaults to: nil)

Returns:

  • (Float)


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

#peakFloat

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:

  • (Float)


134
135
136
# File 'lib/vizcore/dsl/transition_controller.rb', line 134

def peak
  @audio[:peak].to_f
end

#phrase_countInteger

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:

  • (Integer)


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

#secondsFloat

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.

Returns:

  • (Float)

    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

#snareFloat

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:

  • (Float)


229
230
231
# File 'lib/vizcore/dsl/transition_controller.rb', line 229

def snare
  @drums[:snare].to_f
end

#spectral_centroidFloat

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:

  • (Float)


325
326
327
# File 'lib/vizcore/dsl/transition_controller.rb', line 325

def spectral_centroid
  @audio[:spectral_centroid].to_f
end

#spectral_flatnessFloat

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:

  • (Float)


335
336
337
# File 'lib/vizcore/dsl/transition_controller.rb', line 335

def spectral_flatness
  @audio[:spectral_flatness].to_f
end

#spectral_fluxFloat

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:

  • (Float)


340
341
342
# File 'lib/vizcore/dsl/transition_controller.rb', line 340

def spectral_flux
  @audio[:spectral_flux].to_f
end

#spectral_rolloffFloat

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:

  • (Float)


330
331
332
# File 'lib/vizcore/dsl/transition_controller.rb', line 330

def spectral_rolloff
  @audio[:spectral_rolloff].to_f
end

#subFloat

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:

  • (Float)


151
152
153
# File 'lib/vizcore/dsl/transition_controller.rb', line 151

def sub
  frequency_band(:sub)
end

#sub_peakFloat

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:

  • (Float)


156
157
158
# File 'lib/vizcore/dsl/transition_controller.rb', line 156

def sub_peak
  frequency_band_peak(:sub)
end

#trebleFloat

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:

  • (Float)


201
202
203
# File 'lib/vizcore/dsl/transition_controller.rb', line 201

def treble
  frequency_band(:high)
end

#treble_peakFloat

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:

  • (Float)


206
207
208
# File 'lib/vizcore/dsl/transition_controller.rb', line 206

def treble_peak
  frequency_band_peak(:high)
end

#tripletBoolean

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:

  • (Boolean)


291
292
293
# File 'lib/vizcore/dsl/transition_controller.rb', line 291

def triplet
  beat_triplet
end

#zero_crossing_rateFloat

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:

  • (Float)


345
346
347
# File 'lib/vizcore/dsl/transition_controller.rb', line 345

def zero_crossing_rate
  @audio[:zero_crossing_rate].to_f
end