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:) ⇒ 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)


110
111
112
113
114
115
116
117
118
# File 'lib/vizcore/dsl/transition_controller.rb', line 110

def initialize(audio, frame_count:)
  @audio = symbolize_hash(audio)
  @bands = symbolize_hash(@audio[:bands])
  @onsets = symbolize_hash(@audio[:onsets])
  @drums = symbolize_hash(@audio[:drums])
  @frame_count = Integer(frame_count)
rescue StandardError
  @frame_count = 0
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)


121
122
123
# File 'lib/vizcore/dsl/transition_controller.rb', line 121

def amplitude
  @audio[:amplitude].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)


142
143
144
# File 'lib/vizcore/dsl/transition_controller.rb', line 142

def bass
  frequency_band(: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)


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

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)


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

def beat?
  !!@audio[:beat]
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)


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

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)


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

def beat_count
  Integer(@audio[:beat_count] || 0)
rescue StandardError
  0
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)


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

def beat_pulse
  @audio[:beat_pulse].to_f
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)


217
218
219
# File 'lib/vizcore/dsl/transition_controller.rb', line 217

def bpm
  @audio[:bpm].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>)


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

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)


222
223
224
# File 'lib/vizcore/dsl/transition_controller.rb', line 222

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)


127
128
129
# File 'lib/vizcore/dsl/transition_controller.rb', line 127

def frequency_band(name)
  @bands[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)


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

def high
  frequency_band(: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)


185
186
187
# File 'lib/vizcore/dsl/transition_controller.rb', line 185

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)


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

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)


137
138
139
# File 'lib/vizcore/dsl/transition_controller.rb', line 137

def low
  frequency_band(: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)


147
148
149
# File 'lib/vizcore/dsl/transition_controller.rb', line 147

def mid
  frequency_band(: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)


168
169
170
171
172
# File 'lib/vizcore/dsl/transition_controller.rb', line 168

def onset(name = nil)
  return @audio[:onset].to_f if name.nil?

  @onsets[name.to_sym].to_f
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 at the default runtime frame rate.

Returns:

  • (Float)

    scene-local elapsed seconds at the default runtime frame rate



227
228
229
# File 'lib/vizcore/dsl/transition_controller.rb', line 227

def 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)


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

def snare
  @drums[:snare].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)


132
133
134
# File 'lib/vizcore/dsl/transition_controller.rb', line 132

def sub
  frequency_band(: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)


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

def treble
  frequency_band(:high)
end