Class: WSK::Actions::DrawFct

Inherits:
Object
  • Object
show all
Includes:
Common, Functions
Defined in:
lib/WSK/Actions/DrawFct.rb

Constant Summary

Constants included from Functions

Functions::FCTTYPE_PIECEWISE_LINEAR

Instance Method Summary collapse

Methods included from Common

#accessInputWaveFile, #accessOutputWaveFile, #getWaveFileAccesses, #parsePlugins, #readDuration, #readFFTProfile, #readThresholds, #val2db

Instance Method Details

#execute(iInputData, oOutputData) ⇒ Object

Execute

Parameters
  • iInputData (WSK::Model::InputData): The input data

  • oOutputData (Object): The output data to fill

Return
  • Exception: An error, or nil if success



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/WSK/Actions/DrawFct.rb', line 39

def execute(iInputData, oOutputData)
  rError = nil

  # Then draw it
  lMaxY = @Function.get_bounds[3]
  if (@UnitDB == 1)
    lMaxY = (2**(lMaxY.to_f/6)).to_r
  end
  lMedianValue = ((2**(iInputData.Header.NbrBitsPerSample-1)-1)/lMaxY).to_i
  log_info "Draw function with maximal ratio #{lMaxY.to_f}, using median value #{lMedianValue}"
  # Take the median value as a fraction of the maximal value
  @Function.draw(iInputData, oOutputData, 0, @NbrSamplesOut-1, (@UnitDB == 1), lMedianValue)

  return rError
end

#get_nbr_samples(iInputData) ⇒ Object

Get the number of samples that will be written. This is called before execute, as it is needed to write the output file. It is possible to give a majoration: it will be padded with silence.

Parameters
  • iInputData (WSK::Model::InputData): The input data

Return
  • Integer: The number of samples to be written



23
24
25
26
27
28
29
30
# File 'lib/WSK/Actions/DrawFct.rb', line 23

def get_nbr_samples(iInputData)
  @Function = WSK::Functions::Function.new
  @Function.read_from_file(@FctFileName)
  lMinX, _, lMaxX, _ = @Function.get_bounds
  @NbrSamplesOut = lMaxX.to_i-lMinX.to_i+1

  return @NbrSamplesOut
end