Class: Wavesync::BpmDetector
- Inherits:
-
Object
- Object
- Wavesync::BpmDetector
- Defined in:
- lib/wavesync/bpm_detector.rb
Class Method Summary collapse
Class Method Details
.available? ⇒ Boolean
7 8 9 |
# File 'lib/wavesync/bpm_detector.rb', line 7 def self.available? system('which bpm > /dev/null 2>&1') && system('which ffmpeg > /dev/null 2>&1') end |
.detect(file_path) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/wavesync/bpm_detector.rb', line 11 def self.detect(file_path) output = `ffmpeg -i #{Shellwords.escape(file_path)} -ac 1 -ar 44100 -f f32le - 2>/dev/null | bpm` bpm = output.strip.to_f bpm.positive? ? bpm.round : nil rescue StandardError nil end |