Class: Vizcore::Shape::AudioContext

Inherits:
Object
  • Object
show all
Defined in:
lib/vizcore/shape.rb

Overview

Hash-like audio accessor for custom shape contexts.

Instance Method Summary collapse

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

#amplitudeObject



317
318
319
# File 'lib/vizcore/shape.rb', line 317

def amplitude
  numeric(@payload[:amplitude])
end

#bar_countObject



365
366
367
368
369
# File 'lib/vizcore/shape.rb', line 365

def bar_count
  Integer(@payload[:bar_count] || 0)
rescue ArgumentError, TypeError
  0
end

#bar_phaseObject



361
362
363
# File 'lib/vizcore/shape.rb', line 361

def bar_phase
  numeric(@payload[:bar_phase])
end

#bassObject



321
322
323
# File 'lib/vizcore/shape.rb', line 321

def bass
  numeric(band(:low))
end

#bass_peakObject



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

def bass_peak
  numeric(band_peak(:low))
end

#beat?Boolean

Returns:

  • (Boolean)


349
350
351
# File 'lib/vizcore/shape.rb', line 349

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

#beat_phaseObject



357
358
359
# File 'lib/vizcore/shape.rb', line 357

def beat_phase
  numeric(@payload[:beat_phase])
end

#beat_pulseObject



353
354
355
# File 'lib/vizcore/shape.rb', line 353

def beat_pulse
  numeric(@payload[:beat_pulse])
end

#bpmObject



389
390
391
# File 'lib/vizcore/shape.rb', line 389

def bpm
  numeric(@payload[:bpm])
end

#fftObject



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

def fft
  Array(@payload[:fft])
end

#highObject



337
338
339
# File 'lib/vizcore/shape.rb', line 337

def high
  numeric(band(:high))
end

#high_peakObject



341
342
343
# File 'lib/vizcore/shape.rb', line 341

def high_peak
  numeric(band_peak(:high))
end

#hihatObject



385
386
387
# File 'lib/vizcore/shape.rb', line 385

def hihat
  numeric(drum(:hihat))
end

#kickObject



377
378
379
# File 'lib/vizcore/shape.rb', line 377

def kick
  numeric(drum(:kick))
end

#midObject



329
330
331
# File 'lib/vizcore/shape.rb', line 329

def mid
  numeric(band(:mid))
end

#mid_peakObject



333
334
335
# File 'lib/vizcore/shape.rb', line 333

def mid_peak
  numeric(band_peak(:mid))
end

#phrase_countObject



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

#snareObject



381
382
383
# File 'lib/vizcore/shape.rb', line 381

def snare
  numeric(drum(:snare))
end