Class: SpectrumAnalyzer::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/spectrum-analyzer/clients/generator.rb

Instance Method Summary collapse

Constructor Details

#initializeGenerator



3
4
5
6
7
8
# File 'lib/spectrum-analyzer/clients/generator.rb', line 3

def initialize
  @config = SpectrumAnalyzer.configuration
  @file = build_file_info
  @spectrum = SpectrumAnalyzer.spectrum
  @window_functions = SpectrumAnalyzer::WindowFunctions.new(@config.window_size)
end

Instance Method Details

#build_spectrumObject



30
31
32
33
# File 'lib/spectrum-analyzer/clients/generator.rb', line 30

def build_spectrum
  generate_spectrum()
  analyze_spectrum()
end

#quick_analyzeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/spectrum-analyzer/clients/generator.rb', line 14

def quick_analyze
  begin
    buffer = RubyAudio::Buffer.float(@config.window_size)
    RubyAudio::Sound.open(@config.file_name) do |snd|
      while snd.read(buffer) != 0
        domain = generate_domain(buffer)
        return true if domain_contains_frequencies?(domain)
      end
    end

  rescue => error
    p "Error: " + error.to_s
    exit
  end
end

#set_file(file) ⇒ Object



10
11
12
# File 'lib/spectrum-analyzer/clients/generator.rb', line 10

def set_file(file)
  @file = file
end