Class: Vizcore::Shape::AudioContext
- Inherits:
-
Object
- Object
- Vizcore::Shape::AudioContext
- Defined in:
- lib/vizcore/shape.rb
Overview
Hash-like audio accessor for custom shape contexts.
Instance Method Summary collapse
- #amplitude ⇒ Object
- #bar_count ⇒ Object
- #bar_phase ⇒ Object
- #bass ⇒ Object
- #bass_peak ⇒ Object
- #beat? ⇒ Boolean
- #beat_phase ⇒ Object
- #beat_pulse ⇒ Object
- #bpm ⇒ Object
- #fft ⇒ Object
- #high ⇒ Object
- #high_peak ⇒ Object
- #hihat ⇒ Object
-
#initialize(payload) ⇒ AudioContext
constructor
A new instance of AudioContext.
- #kick ⇒ Object
- #mid ⇒ Object
- #mid_peak ⇒ Object
- #phrase_count ⇒ Object
- #snare ⇒ Object
Constructor Details
#initialize(payload) ⇒ AudioContext
Returns a new instance of AudioContext.
313 314 315 |
# File 'lib/vizcore/shape.rb', line 313 def initialize(payload) @payload = symbolize_hash(payload) end |
Instance Method Details
#amplitude ⇒ Object
317 318 319 |
# File 'lib/vizcore/shape.rb', line 317 def amplitude numeric(@payload[:amplitude]) end |
#bar_count ⇒ Object
365 366 367 368 369 |
# File 'lib/vizcore/shape.rb', line 365 def Integer(@payload[:bar_count] || 0) rescue ArgumentError, TypeError 0 end |
#bar_phase ⇒ Object
361 362 363 |
# File 'lib/vizcore/shape.rb', line 361 def numeric(@payload[:bar_phase]) end |
#bass ⇒ Object
321 322 323 |
# File 'lib/vizcore/shape.rb', line 321 def bass numeric(band(:low)) end |
#bass_peak ⇒ Object
325 326 327 |
# File 'lib/vizcore/shape.rb', line 325 def bass_peak numeric(band_peak(:low)) end |
#beat? ⇒ Boolean
349 350 351 |
# File 'lib/vizcore/shape.rb', line 349 def beat? !!@payload[:beat] end |
#beat_phase ⇒ Object
357 358 359 |
# File 'lib/vizcore/shape.rb', line 357 def beat_phase numeric(@payload[:beat_phase]) end |
#beat_pulse ⇒ Object
353 354 355 |
# File 'lib/vizcore/shape.rb', line 353 def beat_pulse numeric(@payload[:beat_pulse]) end |
#bpm ⇒ Object
389 390 391 |
# File 'lib/vizcore/shape.rb', line 389 def bpm numeric(@payload[:bpm]) end |
#fft ⇒ Object
345 346 347 |
# File 'lib/vizcore/shape.rb', line 345 def fft Array(@payload[:fft]) end |
#high ⇒ Object
337 338 339 |
# File 'lib/vizcore/shape.rb', line 337 def high numeric(band(:high)) end |
#high_peak ⇒ Object
341 342 343 |
# File 'lib/vizcore/shape.rb', line 341 def high_peak numeric(band_peak(:high)) end |
#hihat ⇒ Object
385 386 387 |
# File 'lib/vizcore/shape.rb', line 385 def hihat numeric(drum(:hihat)) end |
#kick ⇒ Object
377 378 379 |
# File 'lib/vizcore/shape.rb', line 377 def kick numeric(drum(:kick)) end |
#mid ⇒ Object
329 330 331 |
# File 'lib/vizcore/shape.rb', line 329 def mid numeric(band(:mid)) end |
#mid_peak ⇒ Object
333 334 335 |
# File 'lib/vizcore/shape.rb', line 333 def mid_peak numeric(band_peak(:mid)) end |
#phrase_count ⇒ Object
371 372 373 374 375 |
# File 'lib/vizcore/shape.rb', line 371 def phrase_count Integer(@payload[:phrase_count] || 0) rescue ArgumentError, TypeError 0 end |
#snare ⇒ Object
381 382 383 |
# File 'lib/vizcore/shape.rb', line 381 def snare numeric(drum(:snare)) end |