Class: FMOD::Core::SpectrumData

Inherits:
Structure
  • Object
show all
Defined in:
lib/fmod/core/spectrum_data.rb

Overview

Describes spectrum values between 0.0 and 1.0 for each “FFT bin”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Structure

#inspect, #names, #values

Constructor Details

#initialize(address = nil) ⇒ SpectrumData

Returns a new instance of SpectrumData.

Parameters:

  • address (Pointer, Integer, String, nil) (defaults to: nil)

    The address in memory where the structure will be created from. If no address is given, new memory will be allocated.



12
13
14
15
16
# File 'lib/fmod/core/spectrum_data.rb', line 12

def initialize(address = nil)
  types = [TYPE_INT, TYPE_INT, [TYPE_FLOAT, 32]]
  members = [:length, :channel_count, :spectrum]
  super(address, types, members)
end

Instance Attribute Details

#channel_countInteger (readonly)

Returns the number of channels in the spectrum.

Returns:

  • (Integer)

    the number of channels in the spectrum.

Since:

  • 0.9.2



# File 'lib/fmod/core/spectrum_data.rb', line 23

#lengthInteger (readonly)

Returns the number of entries in this spectrum window. Divide this by the output rate to get the hz per entry.

Returns:

  • (Integer)

    the number of entries in this spectrum window. Divide this by the output rate to get the hz per entry.

Since:

  • 0.9.2



# File 'lib/fmod/core/spectrum_data.rb', line 18

#spectrumArray<Float> (readonly)

TODO:

Test for proper structure

Values inside the float buffer are typically between 0.0 and 1.0.

Each top level array represents one PCM channel of data.

Address data as spectrum[bin]. A bin is 1 FFT window entry.

Only read/display half of the buffer typically for analysis as the 2nd half is usually the same data reversed due to the nature of the way FFT works.

Returns:

  • (Array<Float>)

    per channel spectrum arrays.

Since:

  • 0.9.2



42
43
44
# File 'lib/fmod/core/spectrum_data.rb', line 42

[:length, :channel_count, :spectrum].each do |symbol|
  define_method(symbol) { self[symbol] }
end