Class: Wavesync::Analyzer
- Inherits:
-
Object
- Object
- Wavesync::Analyzer
- Defined in:
- lib/wavesync/analyzer.rb
Constant Summary collapse
- CONFIRM_MESSAGE =
'wavesync analyze will add bpm meta data to files in library. Continue? [y/N] '- SETUP_INSTRUCTIONS =
'brew install python@3.11 && python3.11 -m venv ~/.wavesync-venv && ~/.wavesync-venv/bin/pip install essentia'
Instance Method Summary collapse
-
#analyze(overwrite: false) ⇒ Object
: (?overwrite: bool) -> void.
-
#initialize(library_path) ⇒ Analyzer
constructor
: (String library_path) -> void.
Constructor Details
Instance Method Details
#analyze(overwrite: false) ⇒ Object
: (?overwrite: bool) -> void
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wavesync/analyzer.rb', line 17 def analyze(overwrite: false) unless BpmDetector.available? puts "Error: essentia is not installed. Set up the Python venv with:\n #{SETUP_INSTRUCTIONS}" exit 1 end return unless @ui.confirm(CONFIRM_MESSAGE) @audio_files.each_with_index do |file, index| audio = Audio.new(file) if audio.bpm && !overwrite @ui.analyze_progress(index, @audio_files.size) @ui.analyze_skip(file, audio.bpm) next end bpm = BpmDetector.detect(file) audio.write_bpm(bpm) if bpm @ui.analyze_progress(index, @audio_files.size) @ui.analyze_result(file, bpm) end end |