Method: Platform#audio_level
- Defined in:
- lib/platform/platform.rb
#audio_level(args = {}) ⇒ Object
Public: Gets audio level from the device.
sample_length - Integer milliseconds to sample audio (default: 5000). threshold - Integer unit of PCM to return no audio. Humans can’t hear under 1000 (default: 100)
Returns the Integer peak audio level 0 - 32k, where 0 indicates no audio,
or nil if the level could not be determined.
486 487 488 489 490 |
# File 'lib/platform/platform.rb', line 486 def audio_level(args={}) lvls = audio_levels(args) lev = [lvls[:left], lvls[:right]].max (lev > args.fetch(:threshold, 100)) ? lev : 0 end |