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
- #bass ⇒ Float private
- #beat ⇒ Boolean private
- #beat? ⇒ Boolean private
- #beat_confidence ⇒ Float private
- #beat_count ⇒ Integer private
- #beat_pulse ⇒ Float private
- #bpm ⇒ Float private
- #fft_spectrum ⇒ Array<Float> private
- #frame_count ⇒ Integer private
- #frequency_band(name) ⇒ Float private
- #high ⇒ Float private
- #hihat ⇒ Float private
-
#initialize(audio, frame_count:) ⇒ TriggerContext
constructor
private
A new instance of TriggerContext.
- #kick ⇒ Float private
- #low ⇒ Float private
- #mid ⇒ Float private
- #onset(name = nil) ⇒ Float private
-
#seconds ⇒ Float
private
Scene-local elapsed seconds at the default runtime frame rate.
- #snare ⇒ Float private
- #sub ⇒ Float private
- #treble ⇒ Float private
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.
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
#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.
121 122 123 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 121 def amplitude @audio[:amplitude].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.
142 143 144 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 142 def bass frequency_band(: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.
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.
190 191 192 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 190 def beat? !!@audio[:beat] 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.
200 201 202 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 200 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.
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_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.
205 206 207 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 205 def beat_pulse @audio[:beat_pulse].to_f 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.
217 218 219 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 217 def bpm @audio[:bpm].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.
162 163 164 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 162 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.
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.
127 128 129 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 127 def frequency_band(name) @bands[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.
152 153 154 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 152 def high frequency_band(: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.
185 186 187 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 185 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.
175 176 177 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 175 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.
137 138 139 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 137 def low frequency_band(: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.
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.
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 |
#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 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 |
#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.
180 181 182 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 180 def snare @drums[:snare].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.
132 133 134 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 132 def sub frequency_band(: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.
157 158 159 |
# File 'lib/vizcore/dsl/transition_controller.rb', line 157 def treble frequency_band(:high) end |