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.



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

def initialize(payload)
  @payload = symbolize_hash(payload)
end

Instance Method Details

#amplitudeObject



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

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

#bassObject



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

def bass
  numeric(band(:low))
end

#beat?Boolean

Returns:

  • (Boolean)


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

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

#beat_pulseObject



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

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

#bpmObject



364
365
366
# File 'lib/vizcore/shape.rb', line 364

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

#fftObject



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

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

#highObject



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

def high
  numeric(band(:high))
end

#hihatObject



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

def hihat
  numeric(drum(:hihat))
end

#kickObject



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

def kick
  numeric(drum(:kick))
end

#midObject



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

def mid
  numeric(band(:mid))
end

#snareObject



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

def snare
  numeric(drum(:snare))
end